From 017a8735c3bd33e236d2685e1b6048d92476aad9 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Mon, 1 Feb 2016 12:46:21 -0500 Subject: [PATCH] Update diff tally docs --- docs/source/usersguide/input.rst | 50 ++++++---- docs/source/usersguide/output/statepoint.rst | 16 ++++ openmc/statepoint.py | 2 +- src/constants.F90 | 2 +- src/input_xml.F90 | 2 +- src/relaxng/tallies.rnc | 22 +++-- src/relaxng/tallies.rng | 98 +++++++++++++------- src/state_point.F90 | 6 +- 8 files changed, 134 insertions(+), 64 deletions(-) diff --git a/docs/source/usersguide/input.rst b/docs/source/usersguide/input.rst index f6ac534822..d1dac8caff 100644 --- a/docs/source/usersguide/input.rst +++ b/docs/source/usersguide/input.rst @@ -1708,25 +1708,11 @@ The ```` element accepts the following sub-elements: *Default*: "all" :derivative: - Tally the first-order derivative of the quantity of interest with respect to - some material perturbation. Differential tallies are currently only - implemented for collision and analog estimators. + The id of a ``derivative`` element. This derivative will be applied to all + scores in the tally. Differential tallies are currently only implemented + for collision and analog estimators. - The ``derivative`` element has the following attributes/sub-elements: - - :variable: - The independent variable of the derivative. Accepted options are - "density" and "nuclide_density". A "density" derivative will give the - derivative with respect to the density of the material in [g / cm^3]. A - "nuclide_density" derivative will give the derivative with respect to - the density of a particular nuclide in units of [atom / b / cm]. - - :material: - The perturbed material. (Necessary for both "density" and - "nuclide_density") - - :nuclide: - The perturbed nuclide. (Necessary only for "nuclide_density") + *Default*: None ```` Element ------------------ @@ -1756,6 +1742,34 @@ attributes/sub-elements: One of ```` or ```` must be specified, but not both (even if they are consistent with one another). +```` Element +------------------------ + +OpenMC can take the first-order derivative of many tallies with respect to +material perturbations. It works by propagating a derivative through the +transport equation. Essentially, OpenMC keeps track of how each particle's +weight would change as materials are perturbed, and then accounts for that +weight change in the tallies. Note that this assumes material perturbations are +small enough not to change the distribution of fission sites. This element has +the following attributes/sub-elements: + + :id: + A unique integer that can be used to identify the derivative. + + :variable: + The independent variable of the derivative. Accepted options are + "density" and "nuclide_density". A "density" derivative will give the + derivative with respect to the density of the material in [g / cm^3]. A + "nuclide_density" derivative will give the derivative with respect to + the density of a particular nuclide in units of [atom / b / cm]. + + :material: + The perturbed material. (Necessary for both "density" and + "nuclide_density") + + :nuclide: + The perturbed nuclide. (Necessary only for "nuclide_density") + ```` Element ----------------------------- diff --git a/docs/source/usersguide/output/statepoint.rst b/docs/source/usersguide/output/statepoint.rst index 15bc79f739..786b7e8fbb 100644 --- a/docs/source/usersguide/output/statepoint.rst +++ b/docs/source/usersguide/output/statepoint.rst @@ -156,6 +156,18 @@ if run_mode == 'k-eigenvalue': Width of each mesh cell in each dimension. +**/tallies/derivatives/derivative /independent variable** (*char[]*) + + Independent variable of tally derivative + +**/tallies/derivatives/derivative /material** (*int*) + + ID of the perturbed material + +**/tallies/derivatives/derivative /nuclide** (*char[]*) + + Alias of the perturbed nuclide + **/tallies/n_tallies** (*int*) Number of user-defined tallies. @@ -198,6 +210,10 @@ if run_mode == 'k-eigenvalue': Array of nuclides to tally. Note that if no nuclide is specified in the user input, a single 'total' nuclide appears here. +**/tallies/tally /derivative** (*int*) + + ID of the derivative applied to the tally. + **/tallies/tally /n_score_bins** (*int*) Number of scoring bins for a single nuclide. In general, this can be greater diff --git a/openmc/statepoint.py b/openmc/statepoint.py index ae86c26032..8cd11d7359 100644 --- a/openmc/statepoint.py +++ b/openmc/statepoint.py @@ -468,7 +468,7 @@ class StatePoint(object): base = 'tallies/derivatives/derivative {:d}'.format(d_id) deriv = openmc.TallyDerivative(derivative_id=d_id) deriv.variable = \ - self._f[base + '/dependent variable'].value.decode() + self._f[base + '/independent variable'].value.decode() if deriv.variable == 'density': deriv.material = self._f[base + '/material'].value elif deriv.variable == 'nuclide_density': diff --git a/src/constants.F90 b/src/constants.F90 index 5d8ded5af6..72df3c216d 100644 --- a/src/constants.F90 +++ b/src/constants.F90 @@ -352,7 +352,7 @@ module constants K_TRACKLENGTH = 3, & LEAKAGE = 4 - ! Differential tally dependent variables + ! Differential tally independent variables integer, parameter :: & DIFF_DENSITY = 1, & DIFF_NUCLIDE_DENSITY = 2 diff --git a/src/input_xml.F90 b/src/input_xml.F90 index be6610224d..f29661352b 100644 --- a/src/input_xml.F90 +++ b/src/input_xml.F90 @@ -2570,7 +2570,7 @@ contains // trim(to_str(deriv % id))) end do - ! Read the dependent variable name. + ! Read the independent variable name. temp_str = "" call get_node_value(node_deriv, "variable", temp_str) temp_str = to_lower(temp_str) diff --git a/src/relaxng/tallies.rnc b/src/relaxng/tallies.rnc index c6f470175e..4522adff55 100644 --- a/src/relaxng/tallies.rnc +++ b/src/relaxng/tallies.rnc @@ -15,6 +15,21 @@ element tallies { ) }* & + element derivative { + (element id { xsd:int } | attribute id { xsd:int }) & + (element material { xsd:int } | attribute material { xsd:int }) & + ( (element variable { ( "density") } + | attribute variable { ( "density" ) } ) | + ( + (element variable { ( "nuclide_density" ) } + | attribute variable { ( "nuclide_density" ) } ) + & + (element nuclide { xsd:string { maxLength = "12" } } + | attribute nuclide { xsd:string { maxLength = "12" } } ) + ) + ) + }* & + element tally { (element id { xsd:int } | attribute id { xsd:int }) & (element name { xsd:string { maxLength="52" } } | @@ -42,12 +57,7 @@ element tallies { (element threshold { xsd:double} | attribute threshold { xsd:double }) & (element scores { list { xsd:string { maxLength = "20" }+ } } | attribute scores { list { xsd:string { maxLength = "20"}+ } } )? }* & - element derivative { - (element variable { ( "density" | "nuclide_density") } | - attribute variable { ( "density" | "nuclide_density") } ) & - (element material { xsd:int } | attribute material { xsd:int }) & - (element nuclide { xsd:string } | attribute nuclide { xsd:string })? - }? + (element derivative { xsd:int } | attribute derivative { xsd:int } )? }* & element assume_separate { xsd:boolean }? diff --git a/src/relaxng/tallies.rng b/src/relaxng/tallies.rng index 47fcb70f33..3f88b07608 100644 --- a/src/relaxng/tallies.rng +++ b/src/relaxng/tallies.rng @@ -89,6 +89,60 @@ + + + + + + + + + + + + + + + + + + + + + + + density + + + density + + + + + + nuclide_density + + + nuclide_density + + + + + + 12 + + + + + 12 + + + + + + + + @@ -254,6 +308,16 @@ + + + + + + + + + + @@ -262,39 +326,5 @@ - - - - - - density - nuclide_density - - - - - density - nuclide_density - - - - - - - - - - - - - - - - - - - - - diff --git a/src/state_point.F90 b/src/state_point.F90 index 7991719c84..b7a913dd01 100644 --- a/src/state_point.F90 +++ b/src/state_point.F90 @@ -203,17 +203,17 @@ contains // trim(to_str(deriv % id))) select case (deriv % variable) case (DIFF_DENSITY) - call write_dataset(deriv_group, "dependent variable", "density") + call write_dataset(deriv_group, "independent variable", "density") call write_dataset(deriv_group, "material", deriv % diff_material) case (DIFF_NUCLIDE_DENSITY) - call write_dataset(deriv_group, "dependent variable", & + call write_dataset(deriv_group, "independent variable", & "nuclide_density") call write_dataset(deriv_group, "material", deriv % diff_material) i_list = nuclides(deriv % diff_nuclide) % listing call write_dataset(deriv_group, "nuclide", & xs_listings(i_list) % alias) case default - call fatal_error("Dependent variable for derivative " & + call fatal_error("Independent variable for derivative " & // trim(to_str(deriv % id)) // " not defined in & &state_point.F90.") end select