From 2573fba5fae8a57605a4f025626edb288b993aba Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Sun, 13 Nov 2016 13:49:30 -0500 Subject: [PATCH] Address #746 comments --- docs/source/usersguide/input.rst | 2 +- openmc/statepoint.py | 4 +- openmc/tallies.py | 6 +- openmc/tally_derivative.py | 77 ++---- src/tally.F90 | 197 +++++++++------ src/tally_header.F90 | 2 +- tests/test_diff_tally/inputs_true.dat | 2 +- tests/test_diff_tally/results_true.dat | 304 +++++++++++++---------- tests/test_diff_tally/test_diff_tally.py | 18 +- 9 files changed, 338 insertions(+), 274 deletions(-) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index 3c8860475d..4a81615a10 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -1973,7 +1973,7 @@ the following attributes/sub-elements: density of a particular nuclide in units of [atom / b / cm]. A "temperature" derivative is with respect to a material temperature in units of [K]. The temperature derivative requires windowed multipole to be - turned on. Note also that the temperature derivative only acconuts for + turned on. Note also that the temperature derivative only accounts for resolved resonance Doppler broadening. It does not account for thermal expansion, S(a, b) scattering, resonance scattering, or unresolved Doppler broadening. diff --git a/openmc/statepoint.py b/openmc/statepoint.py index d0e4dbdd53..5a677a8e2f 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -479,7 +479,7 @@ class StatePoint(object): if 'derivatives' in self._f['tallies']: # Read the derivative ids. base = 'tallies/derivatives' - deriv_ids = [int(k.split(' ')[1]) for k in self._f[base].keys()] + deriv_ids = [int(k.split(' ')[1]) for k in self._f[base]] # Create each derivative object and add it to the dictionary. for d_id in deriv_ids: @@ -497,7 +497,7 @@ class StatePoint(object): deriv.material = self._f[base + '/material'].value else: raise RuntimeError('Unrecognized tally differential ' - 'variable') + 'variable') self._derivs[d_id] = deriv self._derivs_read = True diff --git a/openmc/tallies.py b/openmc/tallies.py index 3ba24b7827..1f02129c0d 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -103,7 +103,7 @@ class Tally(object): sparse : bool Whether or not the tally uses SciPy's LIL sparse matrix format for compressed data storage - derivative : openmc.tally_derivative.TallyDerivative + derivative : openmc.TallyDerivative A material perturbation derivative to apply to all scores in the tally. """ @@ -453,7 +453,7 @@ class Tally(object): def derivative(self, deriv): if deriv is not None: cv.check_type('tally derivative', deriv, openmc.TallyDerivative) - self._derivative = deriv + self._derivative = deriv @filters.setter def filters(self, filters): @@ -3608,7 +3608,7 @@ class Tallies(cv.CheckedList): # Add the derivatives to the XML tree. for d in derivs: - self._tallies_file.append(d.get_derivative_xml()) + self._tallies_file.append(d.to_xml_element()) def export_to_xml(self): """Create a tallies.xml file that can be used for a simulation. diff --git a/openmc/tally_derivative.py b/openmc/tally_derivative.py index 3c48cf0309..1c8a316cf5 100644 --- a/openmc/tally_derivative.py +++ b/openmc/tally_derivative.py @@ -7,6 +7,7 @@ from xml.etree import ElementTree as ET from six import string_types import openmc.checkvalue as cv +from openmc.mixin import EqualityMixin # "Static" variable for auto-generated TallyDerivative IDs @@ -17,7 +18,7 @@ def reset_auto_tally_deriv_id(): AUTO_TALLY_DERIV_ID = 10000 -class TallyDerivative(object): +class TallyDerivative(EqualityMixin): """A material perturbation derivative to apply to a tally. Parameters @@ -25,6 +26,13 @@ class TallyDerivative(object): derivative_id : Integral, optional Unique identifier for the tally derivative. If none is specified, an identifier will automatically be assigned + variable : str, optional + Accepted values are 'density', 'nuclide_density', and 'temperature' + material : Integral, optional + The perturubed material ID + nuclide : str, optional + The perturbed nuclide. Only needed for 'nuclide_density' derivatives. + Ex: 'Xe135' Attributes ---------- @@ -33,71 +41,36 @@ class TallyDerivative(object): variable : str Accepted values are 'density', 'nuclide_density', and 'temperature' material : Integral - The perturubed material + The perturubed material ID nuclide : str The perturbed nuclide. Only needed for 'nuclide_density' derivatives. - Ex: 'Xe-135' + Ex: 'Xe135' """ - def __init__(self, derivative_id=None): + def __init__(self, derivative_id=None, variable=None, material=None, + nuclide=None): # Initialize Tally class attributes self.id = derivative_id - self._variable = None - self._material = None - self._nuclide = None - - def __deepcopy__(self, memo): - existing = memo.get(id(self)) - - # If this is the first time we have tried to copy this object, create a - # copy - if existing is None: - clone = type(self).__new__(type(self)) - clone.id = self.id - clone.variable = self.variable - clone.material = self.material - clone.nuclide = self.nuclide - - memo[id(self)] = clone - - return clone - - # If this object has been copied before, return the first copy made - else: - return existing - - def __eq__(self, other): - if not isinstance(other, TallyDerivative): - return False - - return (self.variable == other.variable and - self.material == other.material and - self.nuclide == other.nuclide) - - def __ne__(self, other): - return not self == other + self.variable = variable + self.material = material + self.nuclide = nuclide def __hash__(self): return hash(repr(self)) def __repr__(self): string = 'Tally Derivative\n' - string += '{0: <16}{1}{2}\n'.format('\tID', '=\t', self.id) - string += '{0: <16}{1}{2}\n'.format('\tVariable', '=\t', - self.variable) + string += '{: <16}=\t{}\n'.format('\tID', self.id) + string += '{: <16}=\t{}\n'.format('\tVariable', self.variable) if self.variable == 'density': - string += '{0: <16}{1}{2}\n'.format('\tMaterial', '=\t', - self.material) + string += '{: <16}=\t{}\n'.format('\tMaterial', self.material) elif self.variable == 'nuclide_density': - string += '{0: <16}{1}{2}\n'.format('\tMaterial', '=\t', - self.material) - string += '{0: <16}{1}{2}\n'.format('\tNuclide', '=\t', - self.nuclide) + string += '{: <16}=\t{}\n'.format('\tMaterial', self.material) + string += '{: <16}=\t{}\n'.format('\tNuclide', self.nuclide) elif self.variable == 'temperature': - string += '{0: <16}{1}{2}\n'.format('\tMaterial', '=\t', - self.material) + string += '{: <16}=\t{}\n'.format('\tMaterial', self.material) return string @@ -133,8 +106,8 @@ class TallyDerivative(object): def variable(self, var): if var is not None: cv.check_type('derivative variable', var, string_types) - cv.check_value('derivative variable', var, ('density', - 'nuclide_density', 'temperature')) + cv.check_value('derivative variable', var, + ('density', 'nuclide_density', 'temperature')) self._variable = var @material.setter @@ -149,7 +122,7 @@ class TallyDerivative(object): cv.check_type('derivative nuclide', nuc, string_types) self._nuclide = nuc - def get_derivative_xml(self): + def to_xml_element(self): """Return XML representation of the tally derivative Returns diff --git a/src/tally.F90 b/src/tally.F90 index 5b8adf1c20..df8efa0c02 100644 --- a/src/tally.F90 +++ b/src/tally.F90 @@ -3144,21 +3144,47 @@ contains if (score == ZERO) return + ! If our score was previously c then the new score is + ! c * (1/f * d_f/d_p + 1/c * d_c/d_p) + ! where (1/f * d_f/d_p) is the (logarithmic) flux derivative and p is the + ! perturbated variable. + associate(deriv => tally_derivs(t % deriv)) flux_deriv = deriv % flux_deriv select case (tally_derivs(t % deriv) % variable) + !========================================================================= + ! Density derivative: + ! c = Sigma_MT + ! c = sigma_MT * N + ! c = sigma_MT * rho * const + ! d_c / d_rho = sigma_MT * const + ! (1 / c) * (d_c / d_rho) = 1 / rho + case (DIFF_DENSITY) select case (t % estimator) case (ESTIMATOR_ANALOG) - if (materials(p % material) % id == deriv % diff_material) then - score = score * (flux_deriv + ONE & - / materials(p % material) % density_gpcc) - else + + select case (score_bin) + + case (SCORE_FLUX) score = score * flux_deriv - end if + + case (SCORE_TOTAL, SCORE_SCATTER, SCORE_ABSORPTION, SCORE_FISSION, & + SCORE_NU_FISSION) + if (materials(p % material) % id == deriv % diff_material) then + score = score * (flux_deriv + ONE & + / materials(p % material) % density_gpcc) + else + score = score * flux_deriv + end if + + case default + call fatal_error('Tally derivative not defined for a score on & + &tally ' // trim(to_str(t % id))) + end select case (ESTIMATOR_COLLISION) @@ -3167,46 +3193,9 @@ contains case (SCORE_FLUX) score = score * flux_deriv - case (SCORE_TOTAL) - if (materials(p % material) % id == deriv % diff_material & - .and. material_xs % total /= ZERO) then - score = score * (flux_deriv + ONE & - / materials(p % material) % density_gpcc) - else - score = score * flux_deriv - end if - - case (SCORE_SCATTER) - if (materials(p % material) % id == deriv % diff_material & - .and. material_xs % total - material_xs % absorption /= ZERO) & - then - score = score * (flux_deriv + ONE & - / materials(p % material) % density_gpcc) - else - score = score * flux_deriv - end if - - case (SCORE_ABSORPTION) - if (materials(p % material) % id == deriv % diff_material & - .and. material_xs % absorption /= ZERO) then - score = score * (flux_deriv + ONE & - / materials(p % material) % density_gpcc) - else - score = score * flux_deriv - end if - - case (SCORE_FISSION) - if (materials(p % material) % id == deriv % diff_material & - .and. material_xs % fission /= ZERO) then - score = score * (flux_deriv + ONE & - / materials(p % material) % density_gpcc) - else - score = score * flux_deriv - end if - - case (SCORE_NU_FISSION) - if (materials(p % material) % id == deriv % diff_material & - .and. material_xs % nu_fission /= ZERO) then + case (SCORE_TOTAL, SCORE_SCATTER, SCORE_ABSORPTION, SCORE_FISSION, & + SCORE_NU_FISSION) + if (materials(p % material) % id == deriv % diff_material) then score = score * (flux_deriv + ONE & / materials(p % material) % density_gpcc) else @@ -3223,24 +3212,50 @@ contains &analog and collision estimators.") end select + !========================================================================= + ! Nuclide density derivative: + ! If we are scoring a reaction rate for a single nuclide then + ! c = Sigma_MT_i + ! c = sigma_MT_i * N_i + ! d_c / d_N_i = sigma_MT_i + ! (1 / c) * (d_c / d_N_i) = 1 / N_i + ! If the score is for the total material (i_nuclide = -1) + ! c = Sum_i(Sigma_MT_i) + ! d_c / d_N_i = sigma_MT_i + ! (1 / c) * (d_c / d_N) = sigma_MT_i / Sigma_MT + ! where i is the perturbed nuclide. + case (DIFF_NUCLIDE_DENSITY) select case (t % estimator) case (ESTIMATOR_ANALOG) - if (materials(p % material) % id == deriv % diff_material & - .and. p % event_nuclide == deriv % diff_nuclide) then - associate(mat => materials(p % material)) - ! Search for the index of the perturbed nuclide. - do l = 1, mat % n_nuclides - if (mat % nuclide(l) == deriv % diff_nuclide) exit - end do - score = score * (flux_deriv & - + ONE / mat % atom_density(l)) - end associate - else + select case (score_bin) + + case (SCORE_FLUX) score = score * flux_deriv - end if + + case (SCORE_TOTAL, SCORE_SCATTER, SCORE_ABSORPTION, SCORE_FISSION, & + SCORE_NU_FISSION) + if (materials(p % material) % id == deriv % diff_material & + .and. p % event_nuclide == deriv % diff_nuclide) then + associate(mat => materials(p % material)) + ! Search for the index of the perturbed nuclide. + do l = 1, mat % n_nuclides + if (mat % nuclide(l) == deriv % diff_nuclide) exit + end do + + score = score * (flux_deriv & + + ONE / mat % atom_density(l)) + end associate + else + score = score * flux_deriv + end if + + case default + call fatal_error('Tally derivative not defined for a score on & + &tally ' // trim(to_str(t % id))) + end select case (ESTIMATOR_COLLISION) scoring_diff_nuclide = & @@ -3334,6 +3349,19 @@ contains &analog and collision estimators.") end select + !========================================================================= + ! Temperature derivative: + ! If we are scoring a reaction rate for a single nuclide then + ! c = Sigma_MT_i + ! c = sigma_MT_i * N_i + ! d_c / d_T = (d_sigma_Mt_i / d_T) * N_i + ! (1 / c) * (d_c / d_T) = (d_sigma_MT_i / d_T) / sigma_MT_i + ! If the score is for the total material (i_nuclide = -1) + ! (1 / c) * (d_c / d_T) = Sum_i((d_sigma_MT_i / d_T) * N_i) / Sigma_MT_i + ! where i is the perturbed nuclide. The d_sigma_MT_i / d_T term is + ! computed by multipole_deriv_eval. It only works for the resolved + ! resonance range and requires multipole data. + case (DIFF_TEMPERATURE) select case (t % estimator) @@ -3718,7 +3746,7 @@ contains case (DIFF_DENSITY) associate (mat => materials(p % material)) if (mat % id == deriv % diff_material) then - ! phi = e^(-Sigma_tot * dist) + ! phi is proportional to e^(-Sigma_tot * dist) ! (1 / phi) * (d_phi / d_rho) = - (d_Sigma_tot / d_rho) * dist ! (1 / phi) * (d_phi / d_rho) = - Sigma_tot / rho * dist deriv % flux_deriv = deriv % flux_deriv & @@ -3729,7 +3757,7 @@ contains case (DIFF_NUCLIDE_DENSITY) associate (mat => materials(p % material)) if (mat % id == deriv % diff_material) then - ! phi = e^(-Sigma_tot * dist) + ! phi is proportional to e^(-Sigma_tot * dist) ! (1 / phi) * (d_phi / d_N) = - (d_Sigma_tot / d_N) * dist ! (1 / phi) * (d_phi / d_N) = - sigma_tot * dist deriv % flux_deriv = deriv % flux_deriv & @@ -3745,6 +3773,9 @@ contains if (nuc % mp_present .and. & p % E >= nuc % multipole % start_E .and. & p % E <= nuc % multipole % end_E) then + ! phi is proportional to e^(-Sigma_tot * dist) + ! (1 / phi) * (d_phi / d_T) = - (d_Sigma_tot / d_T) * dist + ! (1 / phi) * (d_phi / d_T) = - N (d_sigma_tot / d_T) * dist call multipole_deriv_eval(nuc % multipole, p % E, & p % sqrtkT, dsigT, dsigA, dsigF) deriv % flux_deriv = deriv % flux_deriv & @@ -3761,7 +3792,18 @@ contains !=============================================================================== ! SCORE_COLLISION_DERIVATIVE Adjust flux derivatives on differential tallies to -! account for a neutron colliding in the perturbed material. +! account for a neutron scattering in the perturbed material. Note that this +! subroutine will be called after absorption events in addition to scattering +! events, but any flux derivatives scored after an absorption will never be +! tallied. This is because the order of operations is +! 1. Particle is moved. +! 2. score_track_derivative is called. +! 3. Collision physics are computed, and the particle is labeled absorbed. +! 4. Analog- and collision-estimated tallies are scored. +! 5. This subroutine is called. +! 6. Particle is killed and no more tallies are scored. +! Hence, it is safe to assume that only derivative of the scattering cross +! section need to be computed here. !=============================================================================== subroutine score_collision_derivative(p) @@ -3780,8 +3822,8 @@ contains case (DIFF_DENSITY) associate (mat => materials(p % material)) if (mat % id == deriv % diff_material) then - ! phi = Sigma_MT - ! (1 / phi) * (d_phi / d_rho) = (d_Sigma_MT / d_rho) / Sigma_MT + ! phi is proportional to Sigma_s + ! (1 / phi) * (d_phi / d_rho) = (d_Sigma_s / d_rho) / Sigma_s ! (1 / phi) * (d_phi / d_rho) = 1 / rho deriv % flux_deriv = deriv % flux_deriv & + ONE / mat % density_gpcc @@ -3800,9 +3842,9 @@ contains if (mat % nuclide(j) /= deriv % diff_nuclide) then call fatal_error("Couldn't find the right nuclide.") end if - ! phi = Sigma_MT - ! (1 / phi) * (d_phi / d_N) = (d_Sigma_MT / d_N) / Sigma_MT - ! (1 / phi) * (d_phi / d_N) = sigma_MT / Sigma_MT + ! phi is proportional to Sigma_s + ! (1 / phi) * (d_phi / d_N) = (d_Sigma_s / d_N) / Sigma_s + ! (1 / phi) * (d_phi / d_N) = sigma_s / Sigma_s ! (1 / phi) * (d_phi / d_N) = 1 / N deriv % flux_deriv = deriv % flux_deriv & + ONE / mat % atom_density(j) @@ -3818,20 +3860,21 @@ contains nuc % mp_present .and. & p % last_E >= nuc % multipole % start_E .and. & p % last_E <= nuc % multipole % end_E) then - ! phi = Sigma_MT - ! (1 / phi) * (d_phi / d_T) = (d_Sigma_MT / d_T) / Sigma_MT - ! (1 / phi) * (d_phi / d_T) = (d_sigma_MT / d_T) / sigma_MT + ! phi is proportional to Sigma_s + ! (1 / phi) * (d_phi / d_T) = (d_Sigma_s / d_T) / Sigma_s + ! (1 / phi) * (d_phi / d_T) = (d_sigma_s / d_T) / sigma_s call multipole_deriv_eval(nuc % multipole, p % last_E, & p % sqrtkT, dsigT, dsigA, dsigF) - select case(p % event) - case (EVENT_SCATTER) - deriv % flux_deriv = deriv % flux_deriv + (dsigT - dsigA)& - / (micro_xs(mat % nuclide(l)) % total & - - micro_xs(mat % nuclide(l)) % absorption) - case (EVENT_ABSORB) - deriv % flux_deriv = deriv % flux_deriv & - + dsigA / micro_xs(mat % nuclide(l)) % absorption - end select + deriv % flux_deriv = deriv % flux_deriv + (dsigT - dsigA)& + / (micro_xs(mat % nuclide(l)) % total & + - micro_xs(mat % nuclide(l)) % absorption) + ! Note that this is an approximation! The real scattering + ! cross section is Sigma_s(E'->E, uvw'->uvw) = + ! Sigma_s(E') * P(E'->E, uvw'->uvw). We are assuming that + ! d_P(E'->E, uvw'->uvw) / d_T = 0 and only computing + ! d_S(E') / d_T. Using this approximation in the vicinity + ! of low-energy resonances causes errors (~2-5% for PWR + ! pincell eigenvalue derivatives). end if end associate end do diff --git a/src/tally_header.F90 b/src/tally_header.F90 index f30a40debe..e292aba60b 100644 --- a/src/tally_header.F90 +++ b/src/tally_header.F90 @@ -25,10 +25,10 @@ module tally_header type TallyDerivative integer :: id - real(8) :: flux_deriv integer :: variable integer :: diff_material integer :: diff_nuclide + real(8) :: flux_deriv end type TallyDerivative !=============================================================================== diff --git a/tests/test_diff_tally/inputs_true.dat b/tests/test_diff_tally/inputs_true.dat index f82b5d8f07..9a67475791 100644 --- a/tests/test_diff_tally/inputs_true.dat +++ b/tests/test_diff_tally/inputs_true.dat @@ -1 +1 @@ -be155010540ca076356596aef8511edd58c91772a5e956e5af77437a39ce3d238b91b57df30c2d599fc6e01c887bf73897ee8ed91425c2d475d97202689c2b88 \ No newline at end of file +df5a0ee7d353fe25344496058cea42e3244a7ab32c13c34c03b4b2f6adf88579f08a71ec0d22d8d264e50e3663717068ff54308e2d16aed8e085c222a8c2fdbd \ No newline at end of file diff --git a/tests/test_diff_tally/results_true.dat b/tests/test_diff_tally/results_true.dat index f40c39973f..7c4f7f7764 100644 --- a/tests/test_diff_tally/results_true.dat +++ b/tests/test_diff_tally/results_true.dat @@ -1,129 +1,177 @@ d_material,d_nuclide,d_variable,score,mean,std. dev. -1,,density,nu-fission,1.11e-02,3.51e-03 -1,,density,nu-fission,9.19e-03,3.48e-03 -1,,density,nu-fission,9.18e-03,5.56e-04 -1,,density,nu-fission,4.82e-03,1.21e-03 -1,,density,nu-fission,0.00e+00,0.00e+00 -1,,density,nu-fission,0.00e+00,0.00e+00 -1,,density,nu-fission,0.00e+00,0.00e+00 -1,,density,nu-fission,0.00e+00,0.00e+00 -1,O16,nuclide_density,nu-fission,6.11e-01,4.97e-01 -1,O16,nuclide_density,nu-fission,2.93e-01,6.38e-01 -1,O16,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,O16,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,U235,nuclide_density,nu-fission,2.36e+02,1.40e+01 -1,U235,nuclide_density,nu-fission,4.76e+02,2.90e+01 -1,U235,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,U235,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,,temperature,nu-fission,-2.34e-07,5.70e-06 -1,,temperature,nu-fission,3.95e-06,3.03e-05 -1,,temperature,nu-fission,0.00e+00,0.00e+00 -1,,temperature,nu-fission,0.00e+00,0.00e+00 -3,,density,flux,-4.61e+00,5.24e-01 -3,,density,flux,-1.03e+01,1.44e+00 -1,,density,flux,-3.13e-01,2.59e-02 -1,,density,flux,-2.20e-01,6.88e-02 -1,O16,nuclide_density,flux,-7.42e+00,2.58e+00 -1,O16,nuclide_density,flux,9.12e-02,1.37e+01 -1,U235,nuclide_density,flux,-2.19e+03,1.01e+02 -1,U235,nuclide_density,flux,-1.73e+03,1.03e+02 -1,,temperature,flux,-4.53e-05,1.53e-04 -1,,temperature,flux,9.07e-05,9.43e-05 -3,,density,total,-1.83e+00,1.70e-01 -3,,density,absorption,5.05e-02,1.70e-02 -3,,density,fission,1.02e-01,1.75e-02 -3,,density,nu-fission,2.45e-01,4.27e-02 -3,,density,total,1.09e-01,1.84e-02 -3,,density,absorption,1.28e-01,1.94e-02 -3,,density,fission,1.11e-01,1.73e-02 -3,,density,nu-fission,2.71e-01,4.22e-02 -3,,density,total,7.64e+00,2.06e+00 -3,,density,absorption,1.24e-01,4.94e-02 -3,,density,fission,0.00e+00,0.00e+00 -3,,density,nu-fission,0.00e+00,0.00e+00 -3,,density,total,0.00e+00,0.00e+00 -3,,density,absorption,0.00e+00,0.00e+00 -3,,density,fission,0.00e+00,0.00e+00 -3,,density,nu-fission,0.00e+00,0.00e+00 -1,,density,total,4.23e-01,1.82e-02 -1,,density,absorption,2.15e-02,5.84e-03 -1,,density,fission,7.86e-03,3.45e-03 -1,,density,nu-fission,2.00e-02,8.35e-03 -1,,density,total,1.30e-02,4.22e-03 -1,,density,absorption,8.14e-03,4.13e-03 -1,,density,fission,5.86e-03,3.50e-03 -1,,density,nu-fission,1.43e-02,8.53e-03 -1,,density,total,-2.89e-01,9.44e-02 -1,,density,absorption,-6.94e-03,2.01e-03 -1,,density,fission,0.00e+00,0.00e+00 -1,,density,nu-fission,0.00e+00,0.00e+00 -1,,density,total,0.00e+00,0.00e+00 -1,,density,absorption,0.00e+00,0.00e+00 -1,,density,fission,0.00e+00,0.00e+00 -1,,density,nu-fission,0.00e+00,0.00e+00 -1,O16,nuclide_density,total,4.54e+01,1.65e+00 -1,O16,nuclide_density,absorption,1.98e-01,4.51e-01 -1,O16,nuclide_density,fission,-3.48e-02,3.76e-01 -1,O16,nuclide_density,nu-fission,-9.43e-02,9.15e-01 -1,O16,nuclide_density,total,-6.13e-02,4.65e-01 -1,O16,nuclide_density,absorption,-3.28e-02,4.51e-01 -1,O16,nuclide_density,fission,-1.46e-02,3.78e-01 -1,O16,nuclide_density,nu-fission,-3.62e-02,9.21e-01 -1,O16,nuclide_density,total,1.04e+00,1.65e+01 -1,O16,nuclide_density,absorption,-3.14e-02,2.69e-01 -1,O16,nuclide_density,fission,0.00e+00,0.00e+00 -1,O16,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,O16,nuclide_density,total,0.00e+00,0.00e+00 -1,O16,nuclide_density,absorption,0.00e+00,0.00e+00 -1,O16,nuclide_density,fission,0.00e+00,0.00e+00 -1,O16,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,U235,nuclide_density,total,-5.09e+02,3.43e+01 -1,U235,nuclide_density,absorption,2.35e+02,1.23e+01 -1,U235,nuclide_density,fission,2.96e+02,1.01e+01 -1,U235,nuclide_density,nu-fission,7.21e+02,2.45e+01 -1,U235,nuclide_density,total,4.95e+02,1.13e+01 -1,U235,nuclide_density,absorption,3.78e+02,1.11e+01 -1,U235,nuclide_density,fission,2.96e+02,1.02e+01 -1,U235,nuclide_density,nu-fission,7.22e+02,2.49e+01 -1,U235,nuclide_density,total,-3.58e+03,2.51e+02 -1,U235,nuclide_density,absorption,-8.88e+01,8.05e+00 -1,U235,nuclide_density,fission,0.00e+00,0.00e+00 -1,U235,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,U235,nuclide_density,total,0.00e+00,0.00e+00 -1,U235,nuclide_density,absorption,0.00e+00,0.00e+00 -1,U235,nuclide_density,fission,0.00e+00,0.00e+00 -1,U235,nuclide_density,nu-fission,0.00e+00,0.00e+00 -1,,temperature,total,9.57e-05,8.25e-05 -1,,temperature,absorption,1.75e-05,2.01e-05 -1,,temperature,fission,-5.34e-06,5.90e-06 -1,,temperature,nu-fission,-1.30e-05,1.44e-05 -1,,temperature,total,-8.49e-06,7.80e-06 -1,,temperature,absorption,-8.20e-06,7.11e-06 -1,,temperature,fission,-5.31e-06,5.87e-06 -1,,temperature,nu-fission,-1.29e-05,1.43e-05 -1,,temperature,total,1.34e-04,1.35e-04 -1,,temperature,absorption,1.75e-06,2.38e-06 -1,,temperature,fission,0.00e+00,0.00e+00 -1,,temperature,nu-fission,0.00e+00,0.00e+00 -1,,temperature,total,0.00e+00,0.00e+00 -1,,temperature,absorption,0.00e+00,0.00e+00 -1,,temperature,fission,0.00e+00,0.00e+00 -1,,temperature,nu-fission,0.00e+00,0.00e+00 -3,,density,absorption,4.95e-02,4.11e-02 -3,,density,absorption,9.83e-02,3.77e-02 -1,,density,absorption,1.60e-02,5.04e-03 -1,,density,absorption,-7.46e-03,2.08e-03 -1,O16,nuclide_density,absorption,3.63e-01,5.10e-01 -1,O16,nuclide_density,absorption,1.02e-01,1.58e-01 -1,U235,nuclide_density,absorption,2.21e+02,2.59e+01 -1,U235,nuclide_density,absorption,-1.08e+02,8.87e+00 -1,,temperature,absorption,-5.32e-06,2.49e-05 -1,,temperature,absorption,9.82e-06,9.34e-06 -3,,density,nu-fission,-2.30e-02,8.64e-02 -3,,density,nu-fission,-1.58e-02,8.56e-02 -3,,density,nu-fission,1.01e-01,8.75e-02 -3,,density,nu-fission,1.19e-01,8.71e-02 -3,,density,nu-fission,0.00e+00,0.00e+00 -3,,density,nu-fission,0.00e+00,0.00e+00 -3,,density,nu-fission,0.00e+00,0.00e+00 -3,,density,nu-fission,0.00e+00,0.00e+00 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,scatter,3.9902949e-02,9.1258428e-03 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,scatter,9.8213745e-04,9.8213745e-04 +1,,density,nu-fission,2.7945389e-02,2.0999368e-02 +1,,density,scatter,4.0626155e-01,1.7017674e-02 +1,,density,nu-fission,2.4595279e-02,2.1224443e-02 +1,,density,scatter,2.6505962e-03,2.3698970e-03 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,scatter,-1.2721728e-01,1.8810986e-01 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,scatter,0.0000000e+00,0.0000000e+00 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,scatter,4.1950592e-02,7.3680059e-02 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,scatter,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,scatter,-1.9798576e-02,1.9798576e-02 +1,O16,nuclide_density,nu-fission,9.3632921e-01,2.0322286e+00 +1,O16,nuclide_density,scatter,-2.2042881e-01,1.6781767e-01 +1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,scatter,2.3761276e+00,2.3761276e+00 +1,U235,nuclide_density,nu-fission,7.7441690e+02,8.6460933e+01 +1,U235,nuclide_density,scatter,9.6917103e+01,1.0750582e+01 +1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 +1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 +1,,temperature,scatter,-2.0607998e-06,2.0607998e-06 +1,,temperature,nu-fission,3.8845881e-06,3.5405083e-05 +1,,temperature,scatter,-6.6772431e-07,2.0750826e-07 +1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 +1,,temperature,scatter,0.0000000e+00,0.0000000e+00 +1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 +1,,temperature,scatter,0.0000000e+00,0.0000000e+00 +3,,density,flux,-7.6179774e+00,5.0326447e+00 +3,,density,flux,-1.6242019e+01,6.6231774e+00 +1,,density,flux,-2.2394746e-01,5.4534297e-02 +1,,density,flux,-5.7132854e-02,1.6898134e-01 +1,O16,nuclide_density,flux,-1.3403658e+01,1.3017127e+01 +1,O16,nuclide_density,flux,-1.0499715e+01,2.1684953e+01 +1,U235,nuclide_density,flux,-2.4741168e+03,5.7986812e+01 +1,U235,nuclide_density,flux,-1.9955533e+03,4.3254820e+02 +1,,temperature,flux,1.0601815e-04,3.3076550e-04 +1,,temperature,flux,1.6664450e-04,2.8761112e-04 +3,,density,total,-3.3161585e+00,2.5615932e+00 +3,,density,absorption,-4.3491248e-01,5.1559021e-01 +3,,density,scatter,-2.8812460e+00,2.0540305e+00 +3,,density,fission,-2.3060366e-01,3.1191109e-01 +3,,density,nu-fission,-5.6817321e-01,7.6143389e-01 +3,,density,total,-2.8908007e-01,3.9383184e-01 +3,,density,absorption,-2.5237485e-01,3.6565053e-01 +3,,density,scatter,-3.6705221e-02,2.9275371e-02 +3,,density,fission,-2.1271120e-01,3.0873698e-01 +3,,density,nu-fission,-5.1866339e-01,7.5235533e-01 +3,,density,total,2.7320569e+00,8.7709465e+00 +3,,density,absorption,8.4322466e-02,1.2807898e-01 +3,,density,scatter,2.6477344e+00,8.6432567e+00 +3,,density,fission,0.0000000e+00,0.0000000e+00 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,total,0.0000000e+00,0.0000000e+00 +3,,density,absorption,0.0000000e+00,0.0000000e+00 +3,,density,scatter,0.0000000e+00,0.0000000e+00 +3,,density,fission,0.0000000e+00,0.0000000e+00 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,total,4.7523439e-01,2.5652004e-02 +1,,density,absorption,3.1301234e-02,7.6793142e-03 +1,,density,scatter,4.4393315e-01,1.8023252e-02 +1,,density,fission,1.5559355e-02,3.2310294e-03 +1,,density,nu-fission,3.8658109e-02,7.8012233e-03 +1,,density,total,2.2062939e-02,4.3689061e-03 +1,,density,absorption,1.6845626e-02,4.0750601e-03 +1,,density,scatter,5.2173132e-03,2.9663452e-04 +1,,density,fission,1.3503649e-02,3.2642875e-03 +1,,density,nu-fission,3.2945474e-02,7.9507685e-03 +1,,density,total,-9.4735691e-02,2.5584665e-01 +1,,density,absorption,-4.0246397e-03,5.2111770e-03 +1,,density,scatter,-9.0711052e-02,2.5073762e-01 +1,,density,fission,0.0000000e+00,0.0000000e+00 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,density,total,0.0000000e+00,0.0000000e+00 +1,,density,absorption,0.0000000e+00,0.0000000e+00 +1,,density,scatter,0.0000000e+00,0.0000000e+00 +1,,density,fission,0.0000000e+00,0.0000000e+00 +1,,density,nu-fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,total,4.4488215e+01,5.3981603e+00 +1,O16,nuclide_density,absorption,-2.9372611e-01,9.3282813e-01 +1,O16,nuclide_density,scatter,4.4781941e+01,4.5257555e+00 +1,O16,nuclide_density,fission,9.9827872e-02,4.0698927e-01 +1,O16,nuclide_density,nu-fission,2.3342880e-01,9.8749212e-01 +1,O16,nuclide_density,total,4.0914051e-02,6.2301812e-01 +1,O16,nuclide_density,absorption,8.8289354e-02,5.5570922e-01 +1,O16,nuclide_density,scatter,-4.7375303e-02,6.7714071e-02 +1,O16,nuclide_density,fission,1.3678733e-01,4.4006413e-01 +1,O16,nuclide_density,nu-fission,3.3257520e-01,1.0719313e+00 +1,O16,nuclide_density,total,-1.6055918e+01,2.3439335e+01 +1,O16,nuclide_density,absorption,-3.9601231e-01,3.0131622e-01 +1,O16,nuclide_density,scatter,-1.5659906e+01,2.3140407e+01 +1,O16,nuclide_density,fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,total,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,absorption,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,fission,0.0000000e+00,0.0000000e+00 +1,O16,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,total,-6.1444902e+02,6.0111692e+01 +1,U235,nuclide_density,absorption,2.3977134e+02,4.5868405e+01 +1,U235,nuclide_density,scatter,-8.5422036e+02,2.4877920e+01 +1,U235,nuclide_density,fission,3.1319132e+02,3.1465126e+01 +1,U235,nuclide_density,nu-fission,7.6415465e+02,7.6501604e+01 +1,U235,nuclide_density,total,5.0916179e+02,3.5499319e+01 +1,U235,nuclide_density,absorption,3.9477360e+02,3.4326165e+01 +1,U235,nuclide_density,scatter,1.1438818e+02,2.7378217e+00 +1,U235,nuclide_density,fission,3.1360739e+02,3.2243605e+01 +1,U235,nuclide_density,nu-fission,7.6527228e+02,7.8683697e+01 +1,U235,nuclide_density,total,-4.1815711e+03,8.7796611e+02 +1,U235,nuclide_density,absorption,-1.0563226e+02,2.5308627e+01 +1,U235,nuclide_density,scatter,-4.0759388e+03,8.5332185e+02 +1,U235,nuclide_density,fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,total,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,absorption,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,scatter,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,fission,0.0000000e+00,0.0000000e+00 +1,U235,nuclide_density,nu-fission,0.0000000e+00,0.0000000e+00 +1,,temperature,total,2.1367130e-04,1.8632816e-04 +1,,temperature,absorption,6.9456249e-05,3.2199390e-05 +1,,temperature,scatter,1.4421505e-04,1.5754180e-04 +1,,temperature,fission,3.0674981e-06,1.8048377e-05 +1,,temperature,nu-fission,7.4768877e-06,4.3976766e-05 +1,,temperature,total,5.8223116e-06,2.3786474e-05 +1,,temperature,absorption,5.2142698e-06,2.1901911e-05 +1,,temperature,scatter,6.0804185e-07,1.9834890e-06 +1,,temperature,fission,3.0674200e-06,1.8048542e-05 +1,,temperature,nu-fission,7.4767028e-06,4.3977153e-05 +1,,temperature,total,2.1510156e-04,4.6388707e-04 +1,,temperature,absorption,2.2409527e-06,8.2901060e-06 +1,,temperature,scatter,2.1286061e-04,4.5560034e-04 +1,,temperature,fission,0.0000000e+00,0.0000000e+00 +1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 +1,,temperature,total,0.0000000e+00,0.0000000e+00 +1,,temperature,absorption,0.0000000e+00,0.0000000e+00 +1,,temperature,scatter,0.0000000e+00,0.0000000e+00 +1,,temperature,fission,0.0000000e+00,0.0000000e+00 +1,,temperature,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,absorption,-1.6517201e-01,3.0984738e-01 +3,,density,absorption,8.0402344e-03,1.4689335e-01 +1,,density,absorption,2.9069882e-02,2.2139609e-03 +1,,density,absorption,-9.4690065e-03,8.6605392e-03 +1,O16,nuclide_density,absorption,7.6911962e-01,4.1945687e-01 +1,O16,nuclide_density,absorption,-6.3724795e-01,6.6341488e-01 +1,U235,nuclide_density,absorption,1.4109543e+02,1.8518890e+01 +1,U235,nuclide_density,absorption,-1.2052822e+02,3.2084002e+01 +1,,temperature,absorption,3.9995404e-05,2.1703384e-05 +1,,temperature,absorption,2.7274361e-06,8.9339257e-06 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,scatter,-8.7934551e-01,1.0210652e+00 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,scatter,-3.5236516e-03,3.5236516e-03 +3,,density,nu-fission,7.2953012e-02,2.9725863e-01 +3,,density,scatter,-2.2716410e+00,1.2546347e+00 +3,,density,nu-fission,8.9171481e-02,3.0634856e-01 +3,,density,scatter,-1.0151747e-03,9.6296775e-03 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,scatter,2.3163923e+00,4.8766690e+00 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,scatter,0.0000000e+00,0.0000000e+00 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,scatter,4.0762434e-01,3.8504141e+00 +3,,density,nu-fission,0.0000000e+00,0.0000000e+00 +3,,density,scatter,0.0000000e+00,0.0000000e+00 diff --git a/tests/test_diff_tally/test_diff_tally.py b/tests/test_diff_tally/test_diff_tally.py index 5e34fd8861..ecf281034d 100644 --- a/tests/test_diff_tally/test_diff_tally.py +++ b/tests/test_diff_tally/test_diff_tally.py @@ -2,10 +2,7 @@ import glob import os -try: - from StringIO import StringIO -except: - from io import StringIO +from io import StringIO import sys import pandas as pd @@ -20,9 +17,9 @@ class DiffTallyTestHarness(PyAPITestHarness): self._input_set.build_default_materials_and_geometry() # Set settings explicitly - self._input_set.settings.batches = 5 + self._input_set.settings.batches = 3 self._input_set.settings.inactive = 0 - self._input_set.settings.particles = 400 + self._input_set.settings.particles = 100 self._input_set.settings.source = openmc.Source(space=openmc.stats.Box( [-160, -160, -183], [160, 160, 183])) self._input_set.settings.temperature['multipole'] = True @@ -30,7 +27,7 @@ class DiffTallyTestHarness(PyAPITestHarness): self._input_set.tallies = openmc.Tallies() filt_mats = openmc.MaterialFilter((1, 3)) - filt_eout = openmc.EnergyoutFilter((0.0, 1.0e6, 20.0e6)) + filt_eout = openmc.EnergyoutFilter((0.0, 0.625, 20.0e6)) # We want density derivatives for both water and fuel to get coverage # for both fissile and non-fissile materials. @@ -75,6 +72,7 @@ class DiffTallyTestHarness(PyAPITestHarness): t = openmc.Tally() t.add_score('total') t.add_score('absorption') + t.add_score('scatter') t.add_score('fission') t.add_score('nu-fission') t.add_filter(filt_mats) @@ -96,6 +94,7 @@ class DiffTallyTestHarness(PyAPITestHarness): for i in range(2): t = openmc.Tally() t.add_score('nu-fission') + t.add_score('scatter') t.add_filter(filt_mats) t.add_filter(filt_eout) t.add_nuclide('total') @@ -107,6 +106,7 @@ class DiffTallyTestHarness(PyAPITestHarness): for i in range(2, 5): t = openmc.Tally() t.add_score('nu-fission') + t.add_score('scatter') t.add_filter(filt_mats) t.add_filter(filt_eout) t.add_nuclide('U235') @@ -129,7 +129,7 @@ class DiffTallyTestHarness(PyAPITestHarness): out = StringIO() cols = ('d_material', 'd_nuclide', 'd_variable', 'score', 'mean', 'std. dev.') - df.to_csv(out, columns=cols, index=False, float_format='%.2e') + df.to_csv(out, columns=cols, index=False, float_format='%.7e') return out.getvalue() @@ -140,5 +140,5 @@ class DiffTallyTestHarness(PyAPITestHarness): if __name__ == '__main__': - harness = DiffTallyTestHarness('statepoint.5.*', True) + harness = DiffTallyTestHarness('statepoint.3.h5', True) harness.main()