From bdd9468540360e3ca24f1a9e68032517669d61b6 Mon Sep 17 00:00:00 2001 From: yardasol Date: Tue, 9 Aug 2022 17:19:49 -0500 Subject: [PATCH 01/13] Fix reaction rate normalization in IndependentOperator The _IndependentNormalizationHelper was unneeded. Additionally, need to have a dilute_inital parameter to get good first-step results. --- openmc/deplete/independent_operator.py | 55 ++++++-------------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/openmc/deplete/independent_operator.py b/openmc/deplete/independent_operator.py index b7956205a4..422965fb80 100644 --- a/openmc/deplete/independent_operator.py +++ b/openmc/deplete/independent_operator.py @@ -55,6 +55,10 @@ class IndependentOperator(OpenMCOperator): Dictionary of nuclides and their fission Q values [eV]. If not given, values will be pulled from the ``chain_file``. Only applicable if ``"normalization_mode" == "fission-q"``. + dilute_initial : float, optional + Initial atom density [atoms/cm^3] to add for nuclides that are zero + in initial condition to ensure they exist in the decay chain. + Only done for nuclides with reaction rates. reduce_chain : bool, optional If True, use :meth:`openmc.deplete.Chain.reduce` to reduce the depletion chain up to ``reduce_chain_level``. @@ -110,6 +114,7 @@ class IndependentOperator(OpenMCOperator): keff=None, normalization_mode='source-rate', fission_q=None, + dilute_initial=1.0e3, prev_results=None, reduce_chain=False, reduce_chain_level=None, @@ -135,6 +140,7 @@ class IndependentOperator(OpenMCOperator): chain_file, prev_results, fission_q=fission_q, + dilute_initial=dilute_initial, helper_kwargs=helper_kwargs, reduce_chain=reduce_chain, reduce_chain_level=reduce_chain_level) @@ -147,6 +153,7 @@ class IndependentOperator(OpenMCOperator): keff=None, normalization_mode='source-rate', fission_q=None, + dilute_initial=1.0e3, prev_results=None, reduce_chain=False, reduce_chain_level=None, @@ -178,6 +185,10 @@ class IndependentOperator(OpenMCOperator): Dictionary of nuclides and their fission Q values [eV]. If not given, values will be pulled from the ``chain_file``. Only applicable if ``"normalization_mode" == "fission-q"``. + dilute_initial : float + Initial atom density [atoms/cm^3] to add for nuclides that + are zero in initial condition to ensure they exist in the decay + chain. Only done for nuclides with reaction rates. prev_results : Results, optional Results from a previous depletion calculation. reduce_chain : bool, optional @@ -202,6 +213,7 @@ class IndependentOperator(OpenMCOperator): keff=keff, normalization_mode=normalization_mode, fission_q=fission_q, + dilute_initial=dilute_initial, prev_results=prev_results, reduce_chain=reduce_chain, reduce_chain_level=reduce_chain_level, @@ -253,47 +265,6 @@ class IndependentOperator(OpenMCOperator): """Finds nuclides with cross section data""" return set(cross_sections.index) - class _IndependentNormalizationHelper(ChainFissionHelper): - """Class for calculating one-group flux based on a power. - - flux = Power / X, where X = volume * sum_i(Q_i * fission_micro_xs_i * density_i) - - Parameters - ---------- - op : openmc.deplete.IndependentOperator - Reference to the object encapsulating _IndependentNormalizationHelper. - We pass this so we don't have to duplicate :attr:`IndependentOperator.number`. - - """ - - def __init__(self, op): - rates = op.reaction_rates - self.nuc_ind_map = {ind: nuc for nuc, ind in rates.index_nuc.items()} - self._op = op - super().__init__() - - def update(self, fission_rates, mat_index=None): - """Update 'energy' produced with fission rates in a material. What - this actually calculates is the quantity X. - - Parameters - ---------- - fission_rates : numpy.ndarray - fission reaction rate for each isotope in the specified - material. Should be ordered corresponding to initial - ``rate_index`` used in :meth:`prepare` - mat_index : int - Material index - - """ - volume = self._op.number.get_mat_volume(mat_index) - densities = np.empty_like(fission_rates) - for i_nuc, nuc in self.nuc_ind_map.items(): - densities[i_nuc] = self._op.number.get_atom_density(mat_index, nuc) - fission_rates *= volume * densities - - super().update(fission_rates) - class _IndependentRateHelper(ReactionRateHelper): """Class for generating one-group reaction rates with flux and one-group cross sections. @@ -370,7 +341,7 @@ class IndependentOperator(OpenMCOperator): self._rate_helper = self._IndependentRateHelper(self) if normalization_mode == "fission-q": - self._normalization_helper = self._IndependentNormalizationHelper(self) + self._normalization_helper = ChainFissionHelper() else: self._normalization_helper = SourceRateHelper() From b5b0ca5ce01bc3139b1481c48874f898655201f0 Mon Sep 17 00:00:00 2001 From: yardasol Date: Tue, 9 Aug 2022 19:54:40 -0500 Subject: [PATCH 02/13] make fission-q default normalization mode --- openmc/deplete/independent_operator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openmc/deplete/independent_operator.py b/openmc/deplete/independent_operator.py index 422965fb80..d84dcb16f8 100644 --- a/openmc/deplete/independent_operator.py +++ b/openmc/deplete/independent_operator.py @@ -112,7 +112,7 @@ class IndependentOperator(OpenMCOperator): micro_xs, chain_file, keff=None, - normalization_mode='source-rate', + normalization_mode='fission-q', fission_q=None, dilute_initial=1.0e3, prev_results=None, @@ -151,7 +151,7 @@ class IndependentOperator(OpenMCOperator): chain_file, nuc_units='atom/b-cm', keff=None, - normalization_mode='source-rate', + normalization_mode='fission-q', fission_q=None, dilute_initial=1.0e3, prev_results=None, From 6048593ad31e7890eb3882e018a25538483a4db9 Mon Sep 17 00:00:00 2001 From: yardasol Date: Tue, 9 Aug 2022 21:51:33 -0500 Subject: [PATCH 03/13] update and expand deplete_no_transport test --- tests/micro_xs_simple.csv | 20 +-- .../deplete_no_transport/test.py | 155 +++++++++++++++--- .../test_reference_coupled_days.h5 | Bin 0 -> 36312 bytes .../test_reference_coupled_hours.h5 | Bin 0 -> 36312 bytes .../test_reference_coupled_minutes.h5 | Bin 0 -> 36312 bytes .../test_reference_coupled_months.h5 | Bin 0 -> 36312 bytes .../test_reference_fission_q.h5 | Bin 36312 -> 36312 bytes .../test_reference_source_rate.h5 | Bin 36312 -> 36312 bytes 8 files changed, 144 insertions(+), 31 deletions(-) create mode 100644 tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 create mode 100644 tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 create mode 100644 tests/regression_tests/deplete_no_transport/test_reference_coupled_minutes.h5 create mode 100644 tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 diff --git a/tests/micro_xs_simple.csv b/tests/micro_xs_simple.csv index 787ce74c39..71981c718c 100644 --- a/tests/micro_xs_simple.csv +++ b/tests/micro_xs_simple.csv @@ -1,13 +1,13 @@ nuclide,"(n,gamma)",fission -U234,22.231989822002465,0.49620744663749855 -U235,10.479008971197121,48.41787337164604 -U238,0.8673334105437324,0.10467880588762352 -U236,8.65171044607122,0.31948392400019293 -O16,7.497851000107524e-05,0.0 -O17,0.0004079227797153371,0.0 -I135,6.842395323713927,0.0 -Xe135,227463.86426990604,0.0 -Xe136,0.02317896034753588,0.0 +U234,22.231989822002454,0.4962074466374984 +U235,10.479008971197121,48.41787337164606 +U238,0.8673334105437321,0.1046788058876236 +U236,8.651710446071224,0.31948392400019293 +O16,7.497851000107522e-05,0.0 +O17,0.0004079227797153372,0.0 +I135,6.842395323713929,0.0 +Xe135,227463.8642699061,0.0 +Xe136,0.023178960347535887,0.0 Cs135,2.1721665580713623,0.0 -Gd157,12786.09939237018,0.0 +Gd157,12786.099392370175,0.0 Gd156,3.4006085445846983,0.0 diff --git a/tests/regression_tests/deplete_no_transport/test.py b/tests/regression_tests/deplete_no_transport/test.py index 95b842537c..bf4a4b132b 100644 --- a/tests/regression_tests/deplete_no_transport/test.py +++ b/tests/regression_tests/deplete_no_transport/test.py @@ -20,6 +20,17 @@ def fuel(): return fuel +@pytest.fixture(scope="module") +def micro_xs(): + micro_xs_file = Path(__file__).parents[2] / 'micro_xs_simple.csv' + micro_xs = MicroXS.from_csv(micro_xs_file) + + return micro_xs + +@pytest.fixture(scope="module") +def chain_file(): + return Path(__file__).parents[2] / 'chain_simple.xml' + @pytest.mark.parametrize("multiproc, from_nuclides, normalization_mode, power, flux", [ (True, True,'source-rate', None, 1164719970082145.0), (False, True, 'source-rate', None, 1164719970082145.0), @@ -29,7 +40,15 @@ def fuel(): (False, False, 'source-rate', None, 1164719970082145.0), (True, False, 'fission-q', 174, None), (False, False, 'fission-q', 174, None)]) -def test_no_transport_from_nuclides(run_in_tmpdir, fuel, multiproc, from_nuclides, normalization_mode, power, flux): +def test_against_self(run_in_tmpdir, + fuel, + micro_xs, + chain_file, + multiproc, + from_nuclides, + normalization_mode, + power, + flux): """Transport free system test suite. Runs an OpenMC transport-free depletion calculation and verifies @@ -37,28 +56,22 @@ def test_no_transport_from_nuclides(run_in_tmpdir, fuel, multiproc, from_nuclide """ # Create operator - micro_xs_file = Path(__file__).parents[2] / 'micro_xs_simple.csv' - micro_xs = MicroXS.from_csv(micro_xs_file) - chain_file = Path(__file__).parents[2] / 'chain_simple.xml' - - if from_nuclides: - nuclides = {} - for nuc, dens in fuel.get_nuclide_atom_densities().items(): - nuclides[nuc] = dens - - op = IndependentOperator.from_nuclides( - fuel.volume, nuclides, micro_xs, chain_file, normalization_mode=normalization_mode) - - else: - op = IndependentOperator(openmc.Materials([fuel]), micro_xs, chain_file, normalization_mode=normalization_mode) + op = _create_operator(from_nuclides, + fuel, + micro_xs, + chain_file, + normalization_mode) # Power and timesteps - dt = [30] # single step + dt = [360] # single step # Perform simulation using the predictor algorithm openmc.deplete.pool.USE_MULTIPROCESSING = multiproc - openmc.deplete.PredictorIntegrator( - op, dt, power=power, source_rates=flux, timestep_units='d').integrate() + openmc.deplete.PredictorIntegrator(op, + dt, + power=power, + source_rates=flux, + timestep_units='s').integrate() # Get path to test and reference results path_test = op.output_dir / 'depletion_results.h5' @@ -73,9 +86,86 @@ def test_no_transport_from_nuclides(run_in_tmpdir, fuel, multiproc, from_nuclide res_ref = openmc.deplete.Results(path_reference) # Assert same mats + _assert_same_mats(res_test, res_ref) + + tol = 1.0e-14 + _assert_atoms_equal(res_test, res_ref, tol) + _assert_reaction_rates_equal(res_test, res_ref, tol) + +@pytest.mark.parametrize("multiproc, dt, time_units, time_type, atom_tol, rx_tol ", [ + (True, 360, 's', 'minutes', 2.0e-3, 3.0e-2), + (False, 360, 's', 'minutes', 2.0e-3, 3.0e-2), + (True, 4, 'h', 'hours', 2.0e-3, 6.0e-2), + (False,4, 'h', 'hours', 2.0e-3, 6.0e-2), + (True, 5, 'd', 'days', 2.0e-3, 5.0e-2), + (False,5, 'd', 'days', 2.0e-3, 5.0e-2), + (True, 100, 'd', 'months', 4.0e-3, 9.0e-2), + (False, 100, 'd', 'months', 4.0e-3, 9.0e-2)]) +def test_against_coupled(run_in_tmpdir, + fuel, + micro_xs, + chain_file, + multiproc, + dt, + time_units, + time_type, + atom_tol, + rx_tol): + # Create operator + op = _create_operator(False, fuel, micro_xs, chain_file, 'fission-q') + + # Power and timesteps + dt = [dt] # single step + + # Perform simulation using the predictor algorithm + openmc.deplete.pool.USE_MULTIPROCESSING = multiproc + openmc.deplete.PredictorIntegrator( + op, dt, power=174, timestep_units=time_units).integrate() + + # Get path to test and reference results + path_test = op.output_dir / 'depletion_results.h5' + + ref_path = f'test_reference_coupled_{time_type}.h5' + path_reference = Path(__file__).with_name(ref_path) + + # Load the reference/test results + res_test = openmc.deplete.Results(path_test) + res_ref = openmc.deplete.Results(path_reference) + + # Assert same mats + _assert_same_mats(res_test, res_ref) + + _assert_atoms_equal(res_test, res_ref, atom_tol) + _assert_reaction_rates_equal(res_test, res_ref, rx_tol) + +def _create_operator(from_nuclides, + fuel, + micro_xs, + chain_file, + normalization_mode): + if from_nuclides: + nuclides = {} + for nuc, dens in fuel.get_nuclide_atom_densities().items(): + nuclides[nuc] = dens + + op = IndependentOperator.from_nuclides(fuel.volume, + nuclides, + micro_xs, + chain_file, + normalization_mode=normalization_mode) + + else: + op = IndependentOperator(openmc.Materials([fuel]), + micro_xs, + chain_file, + normalization_mode=normalization_mode) + + return op + +def _assert_same_mats(res_ref, res_test): for mat in res_ref[0].mat_to_ind: - assert mat in res_test[0].mat_to_ind, \ - "Material {} not in new results.".format(mat) + assert mat in res_test[0].mat_to_ind, \ + "Material {} not in new results.".format(mat) for nuc in res_ref[0].nuc_to_ind: assert nuc in res_test[0].nuc_to_ind, \ "Nuclide {} not in new results.".format(nuc) @@ -87,7 +177,7 @@ def test_no_transport_from_nuclides(run_in_tmpdir, fuel, multiproc, from_nuclide assert nuc in res_ref[0].nuc_to_ind, \ "Nuclide {} not in old results.".format(nuc) - tol = 1.0e-6 +def _assert_atoms_equal(res_ref, res_test, tol): for mat in res_test[0].mat_to_ind: for nuc in res_test[0].nuc_to_ind: _, y_test = res_test.get_atoms(mat, nuc) @@ -104,3 +194,26 @@ def test_no_transport_from_nuclides(run_in_tmpdir, fuel, multiproc, from_nuclide assert correct, "Discrepancy in mat {} and nuc {}\n{}\n{}".format( mat, nuc, y_old, y_test) + +def _assert_reaction_rates_equal(res_ref, res_test, tol): + for reactions in res_test[0].rates: + for mat in reactions.index_mat: + for nuc in reactions.index_nuc: + for rx in reactions.index_rx: + y_test = res_test.get_reaction_rate(mat, nuc, rx)[1] / \ + res_test.get_atoms(mat, nuc)[1] + y_old = res_ref.get_reaction_rate(mat, nuc, rx)[1] / \ + res_ref.get_atoms(mat, nuc)[1] + + # Test each point + correct = True + for i, ref in enumerate(y_old): + if ref != y_test[i]: + if ref != 0.0: + correct = np.abs(y_test[i] - ref) / ref <= tol + else: + if y_test[i] != 0.0: + correct = False + + assert correct, "Discrepancy in mat {}, nuc {}, and rx {}\n{}\n{}".format( + mat, nuc, rx, y_old, y_test) diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_days.h5 new file mode 100644 index 0000000000000000000000000000000000000000..d97acffec6923460cacfe609b1122c57e5181ce9 GIT binary patch literal 36312 zcmeHPZ)_aJ6`#BFpCg#&V$xzl8!izg7Xih=A#p)>zQh+|S3sSFKW;_abDRx!QYjxIVFaa-f@G6c)S(|@6^TZmluJ?7P)accnp6~G^-BX^@P{_;%+CAW z-c7Q1=e5t69!cH(pQa?5p32MNlLT0 zyb);Gw4qJ)aE!W%c~%!IZ@-t&d_{ej*EOO=az)6w9TYWkcJH>*1Ks_7A{3M~vYQmQ z&pw}K2GK#zaD9L;kToJs_O6oUgJNfQk2SbAWs$nLRw^!$3Fz;zQc^+I7*1OQLp_57 zP&D|9Y@aNt%7TaJS4ee29`(d8%|o9n5685ppg!ude7f?FWRbA6Q`B;^xdV0;V4TkJ>3dpgG_P_=tS3Qu_fFb@g$+ zT1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66^orO(&5eKj?Da(KiHDCzPmP?5K7XHY-AxV0 zqknGw=(h3x&zp_~{xJM*Z7SOiyL~@gw!xMsthkb+)=1Mw|9SJdM;>ZuerfqH*KdAu zW%K>#MlvV*hnl~4=-&-vA8c)I|NW9j9(eb?jlWtQdgm{#Qyb4rR_^3<04h|ctAKG|f#f2;mZ=e0-v$u~r zI2>qr_B)RcRAq7KdillL+dpoI9qIaTYoP7@=+5ZAEvo`6V@F>2_Px*jJrO(i*VbLn pJbfr!@}fKV%LL{|8&T`&R$} literal 0 HcmV?d00001 diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_hours.h5 new file mode 100644 index 0000000000000000000000000000000000000000..6d9bcc91ff7eff734feb83cf96e56f2b2d3e8819 GIT binary patch literal 36312 zcmeHPe{3AZ6`s4Z<4bVJ#kj-?DqJEWOo7%R0W8p+kNDg=1&RrE>o%%-j&l&F{&Ae` z$Pu6>B}j?r4@<46snif8M4UoM09A2Q6{SIeOInbls;X&KIS8d(|3HdRCEPYN%)p-KFE3oMY=KaR-!IBUz`DfgJRRdd(m6=u zevB?WBzKV<@#+hYC>QEp4dn;Oe$b~gQk4Jo^-WDecm?c3(rqy^PhZtjhQCo?#3;?; z(ng@U>FyTQ!$Z_f%(I$sY5TpH<}2#Mysi|@k}E>aZNI3LvwLei+1J_IBLaR&BdbXf z>+JDpW)L0Z4A%$v0$C{{WN*GK?-vhscE$U*CE}zmu9Aw2Wdiz};t8oBYYZmieFI(n zeNZ&`i)@c9smg+f=vP2>LLPO*FU>=bBM%R0PeFauW%+#hAOIe=QI`=dT4??NiB)ug z`Pz&dF6Dz?yFaR8$sm=VygR=k%UMX3R002>xhh1O;t|?w@&ddWsnqpCZ;aAsuhjYV z)U3(7=wglur+7Shg>ESPtM&uJ(GSeAZgF#F83EG|fJbc`{5SEc6m_%?nJ3pZe$m;pDXx6(1?w6Em`YJkXRPyYe|$7hqr8Mhk$10i#p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0`k|hlJMXe_7`(Rc zi>uyQlEdNf@$VeJ_rj*=1)Z1wqoMcx$Wu#?uTOu~5dFi|n>TEIDIOhq_HXHM=CjD? jGougg8axzv_2CDmK2Lnv()*L`8|oe*9MFHrJRJT9)R*{% literal 0 HcmV?d00001 diff --git a/tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 b/tests/regression_tests/deplete_no_transport/test_reference_coupled_months.h5 new file mode 100644 index 0000000000000000000000000000000000000000..43b45cb370c43d2d05000e6cb2dfa1b764d0d5b7 GIT binary patch literal 36312 zcmeHP4{TdU89&=eQ zMxecIV?y=t2z3+ltRYg_elMr_iuy3GYel={ijZ^LFKXrN-kHh{rU&{(z%OZJH7RPH zJs!;rqJx~_`T$=bYekgoT_?-?#Utt7)X?rsiqyr8QgOLVK))xIkqWZLU^X>4+&eS~ zMT5V{_Q;Z|EO>~11ym>G(M0^xJoGs7@QC&l)JI*G&({tD;9)0q8POs^^9M+*r3=j0 zcHD3&ANbUkxQZpasQlE%nGIRaLaO9S_y^5ZAtosvp}i(Az?;!pT`%;;DShF6I=_XQ zHFXbNEHdE~kEfRDhQhyUKOh|az#{7wH)nwnF#P~{)JgFH%>hrqN94Pe+7GCxtB(sc zTB4o?y3t~^!)<+6YdOS!6R%p)MC*_xa$VyW>HeOS^0}9-YYbp&MGKXy5i4Z5oddnY zeRB1(JlINO6&352iFMP4pY48pTgT~F|JrJ=Obo-6bXvcd{bP5#kGtD%&}LB20ZJdCb_A%F(28Qc1f?_Y z*ZJVjq55LI9Hl2$>inPVU6<8`|2Tw5or<4Dhq;X{b1*BNcgn*O(IzaOX zW#L!m%YT7)rvI_|;*NLK)L`3=JKn)gxx7o>tSe^TVaBkW2>~bG`Dq@ZY^8W-#&er5 z?s!L!t>+x?V5eN(P0%`nd50OpawY_vc(=z`uU3k8=K6T9yhC4YJMQ8g?3By9M58Xj zyt9$xD`y0pcsCU+E>kJqjoqT_nV|Y?zPO8b_<7B?@&r2E0V!;E1$69P`Wn_OL7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=kxh~|LgI;xAp9r z&ZiG|eAV~Z$v5)l&o9evYQD+F;gv(r)qnS7bENe@ThARl|5o_j^p{@jOWYQ@wCwnX x@%{Hk>JmNm=^spn(+@R<1HV2RKK#PL&mBDV@7B!bpFh0+K8*wV4=D<8_#el*|FQr8 literal 0 HcmV?d00001 diff --git a/tests/regression_tests/deplete_no_transport/test_reference_fission_q.h5 b/tests/regression_tests/deplete_no_transport/test_reference_fission_q.h5 index 82bf11567363a56b84f87a204df7ea79d6f7e124..826c5f3b012fb4b1fb26be4193ac451bd232e2a1 100644 GIT binary patch delta 499 zcmcaHo9V`ErVS^$>nn9vC1wRSIuJ|W%t~IlPW__u_QUpe=6`Kn)&vI}U2wIi( z>oaS_?HHio#j&PC7cR5g!}yCFtEQR6O|gaXH?i6U{J8Wt0xl3>en?d`?0(3ES5+<&P*^p`|r|UxQ81i*q)a}^6=4er7ihL9<~$Kv;PhB@Zu*w@>_u( s{`<>dl?>3sd^gWHc>p~exwPTDIncxIcc$7g{s(zjOd9527>(p_038;reE=)Ab`?xM&C z8qSOt)V(FQn>#aAeT-cTbW_-dH%EQv+PYj%{r^4vQj3e6i_XteMLR7)=7K<##nCNZ z7gt(Acnl2l&;83O+a_oRSMZ^xFE>U@U!VIc;%#r4Z3tLebJ%iA#UuAeKo76$Sv0HUT&LwCzQBD=W*`rX%D_Afqmexh E0GDu#TmS$7 diff --git a/tests/regression_tests/deplete_no_transport/test_reference_source_rate.h5 b/tests/regression_tests/deplete_no_transport/test_reference_source_rate.h5 index 88ed73b1766fb795aee19a1417a151a451c6243e..f5161d37067f6b7ffe333e41270959a75f7ebfda 100644 GIT binary patch delta 439 zcmcaHo9V`ErVS^$>nn9vC1wRSIuJ|W%t~IlPW__u_QUpe=6`Kn)&vI}U2wIf`iXPC8n9r>*gQ;}o;v zI;TpYvs1Ot$(JH6Sx#D$1U!zI*E!wmZ_EYxcER)y;ru|~rtbT(6`OB85x!*u+rMP8 jWv@Krw8@dZ@|rN`M?#(d9EbDogPbn|ayHlqEY1f24GN@? delta 305 zcmcaHo9V`ErVS^$Ctfg+xS5r_a-I4`=beY`?acq$x~vZlIJ)3!i_64=37VT%{C3!U zHrg&CxI19+ZDzaYF>$M}n0nd0soXSmpJe|#6zS}LWc+uJR(kEwwmzFN)7Sx1)yxiilM!@xwv#g^X)G7w|nrxm$)z{}zkurDZ_Q2AP1(`2bQpfkOZQ From 672293a310425f975665ba95b6757b3d32a9fd68 Mon Sep 17 00:00:00 2001 From: yardasol Date: Tue, 9 Aug 2022 23:04:53 -0500 Subject: [PATCH 04/13] doc fixes --- docs/source/pythonapi/deplete.rst | 4 ++-- docs/source/usersguide/depletion.rst | 3 ++- openmc/deplete/microxs.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/source/pythonapi/deplete.rst b/docs/source/pythonapi/deplete.rst index 0b7faceb71..4154e35df1 100644 --- a/docs/source/pythonapi/deplete.rst +++ b/docs/source/pythonapi/deplete.rst @@ -43,7 +43,7 @@ algorithms `_. SILEQIIntegrator Each of these classes expects a "transport operator" to be passed. OpenMC -provides The following classes implementing transpor operators: +provides The following classes implement transport operators: .. autosummary:: :toctree: generated @@ -55,7 +55,7 @@ provides The following classes implementing transpor operators: The :class:`CoupledOperator` and :class:`IndependentOperator` classes must also have some knowledge of how nuclides transmute and decay. This is handled by the -:class:`Chain`. +:class:`Chain` class. Minimal Example --------------- diff --git a/docs/source/usersguide/depletion.rst b/docs/source/usersguide/depletion.rst index 29c8114d93..6c31170951 100644 --- a/docs/source/usersguide/depletion.rst +++ b/docs/source/usersguide/depletion.rst @@ -21,7 +21,8 @@ material compositions over time. Each method appears as a different class. For example, :class:`openmc.deplete.CECMIntegrator` runs a depletion calculation using the CE/CM algorithm (deplete over a timestep using the middle-of-step reaction rates). An instance of :class:`~openmc.deplete.abc.TransportOperator` -is passed to one of these functions along with the timesteps and power level:: +is passed to one of these Integrator classes along with the timesteps and power +level:: power = 1200.0e6 # watts timesteps = [10.0, 10.0, 10.0] # days diff --git a/openmc/deplete/microxs.py b/openmc/deplete/microxs.py index 982d0a55f8..71e476c2c3 100644 --- a/openmc/deplete/microxs.py +++ b/openmc/deplete/microxs.py @@ -1,7 +1,7 @@ """MicroXS module A pandas.DataFrame storing microscopic cross section data with -nuclides names as row indices and reaction names as column indices. +nuclide names as row indices and reaction names as column indices. """ import tempfile @@ -26,7 +26,7 @@ _valid_rxns.append('fission') class MicroXS(DataFrame): """Stores microscopic cross section data for use in - independent depletion. + transport-independent depletion. """ @classmethod From 6bd4a7134134abd1bbf1078d48147dca29d67694 Mon Sep 17 00:00:00 2001 From: yardasol Date: Wed, 10 Aug 2022 10:56:22 -0500 Subject: [PATCH 05/13] add clarifying comment to _IndependentRateHelper --- openmc/deplete/independent_operator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openmc/deplete/independent_operator.py b/openmc/deplete/independent_operator.py index d84dcb16f8..a2d89e441e 100644 --- a/openmc/deplete/independent_operator.py +++ b/openmc/deplete/independent_operator.py @@ -321,8 +321,10 @@ class IndependentOperator(OpenMCOperator): nuc = self.nuc_ind_map[i_nuc] rxn = self.rxn_ind_map[i_react] density = self._op.number.get_atom_density(mat_id, nuc) - self._results_cache[i_nuc, - i_react] = self._op.cross_sections[rxn][nuc] * density * volume + + # Sigma^j_i * V = sigma^j_i * rho * V + self._results_cache[i_nuc,i_react] = \ + self._op.cross_sections[rxn][nuc] * density * volume return self._results_cache From 2144ec271fa3625c74c90881d9c5e5589fe77db6 Mon Sep 17 00:00:00 2001 From: yardasol Date: Wed, 10 Aug 2022 10:57:23 -0500 Subject: [PATCH 06/13] fix flux equation in depletion userguide --- docs/source/usersguide/depletion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/usersguide/depletion.rst b/docs/source/usersguide/depletion.rst index 6c31170951..ee0d09b8d1 100644 --- a/docs/source/usersguide/depletion.rst +++ b/docs/source/usersguide/depletion.rst @@ -319,7 +319,7 @@ normalizing reaction rates: .. math:: - \phi = \frac{P}{V \cdot \sum_i (Q_i \cdot \Sigma^f_i \cdot \rho_i)} + \phi = \frac{P}{V \cdot \sum_i (Q_i \cdot \sigma^f_i \cdot \rho_i)} where :math:`\sum_i` is the sum over all nuclides :math:`i`. This equation makes the same assumptions and issues as discussed in From b93642ff74253033cc16693f6a1c61537b207b7b Mon Sep 17 00:00:00 2001 From: Olek <45364492+yardasol@users.noreply.github.com> Date: Wed, 10 Aug 2022 14:32:42 -0500 Subject: [PATCH 07/13] fix density variable --- docs/source/usersguide/depletion.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/usersguide/depletion.rst b/docs/source/usersguide/depletion.rst index ee0d09b8d1..229e90a4cf 100644 --- a/docs/source/usersguide/depletion.rst +++ b/docs/source/usersguide/depletion.rst @@ -319,7 +319,7 @@ normalizing reaction rates: .. math:: - \phi = \frac{P}{V \cdot \sum_i (Q_i \cdot \sigma^f_i \cdot \rho_i)} + \phi = \frac{P}{V \cdot \sum_i (Q_i \cdot \sigma^f_i \cdot \n_i)} where :math:`\sum_i` is the sum over all nuclides :math:`i`. This equation makes the same assumptions and issues as discussed in From 8969b9b4e9fe99ac0926e2e67586b0573f2519c4 Mon Sep 17 00:00:00 2001 From: yardasol Date: Wed, 10 Aug 2022 15:53:40 -0500 Subject: [PATCH 08/13] remove unneeded parameter from update --- openmc/deplete/abc.py | 4 +--- openmc/deplete/helpers.py | 4 +--- openmc/deplete/openmc_operator.py | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/openmc/deplete/abc.py b/openmc/deplete/abc.py index e3587f0527..3e2c37ece7 100644 --- a/openmc/deplete/abc.py +++ b/openmc/deplete/abc.py @@ -331,7 +331,7 @@ class NormalizationHelper(ABC): `fission_rates` for :meth:`update`. """ - def update(self, fission_rates, mat_index=None): + def update(self, fission_rates): """Update the normalization based on fission rates (only used for energy-based normalization) @@ -341,8 +341,6 @@ class NormalizationHelper(ABC): fission reaction rate for each isotope in the specified material. Should be ordered corresponding to initial ``rate_index`` used in :meth:`prepare` - mat_index : int - Material index """ @property diff --git a/openmc/deplete/helpers.py b/openmc/deplete/helpers.py index 1e382576ee..3a7928a52d 100644 --- a/openmc/deplete/helpers.py +++ b/openmc/deplete/helpers.py @@ -426,7 +426,7 @@ class ChainFissionHelper(EnergyNormalizationHelper): self._fission_q_vector = fission_qs - def update(self, fission_rates, mat_index=None): + def update(self, fission_rates): """Update energy produced with fission rates in a material Parameters @@ -435,8 +435,6 @@ class ChainFissionHelper(EnergyNormalizationHelper): fission reaction rate for each isotope in the specified material. Should be ordered corresponding to initial ``rate_index`` used in :meth:`prepare` - mat_index : int - Unused """ self._energy += dot(fission_rates, self._fission_q_vector) diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index 6e6f8dd8d4..c340650782 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -528,13 +528,13 @@ class OpenMCOperator(TransportOperator): # Accumulate energy from fission if fission_ind is not None: self._normalization_helper.update( - tally_rates[:, fission_ind], - mat_index=mat_index) + tally_rates[:, fission_ind]) # Divide by total number and store rates[i] = self._rate_helper.divide_by_adens(number) # Scale reaction rates to obtain units of reactions/sec + print(f"flux, power, or source rate: {self._normalization_helper.factor(source_rate)}") rates *= self._normalization_helper.factor(source_rate) # Store new fission yields on the chain From f9b2c21d59241990ca28fcb604b9ef7ca2c97f7c Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 10 Aug 2022 23:12:01 -0500 Subject: [PATCH 09/13] Fix potential bug with nuclide densities in Results.export_to_materials --- openmc/deplete/results.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openmc/deplete/results.py b/openmc/deplete/results.py index b89bae088b..c2138b55c6 100644 --- a/openmc/deplete/results.py +++ b/openmc/deplete/results.py @@ -417,7 +417,16 @@ class Results(list): mat_id = str(mat.id) if mat_id in result.mat_to_ind: mat.volume = result.volume[mat_id] + + # Change density of all nuclides in material to atom/b-cm + atoms_per_barn_cm = mat.get_nuclide_atom_densities() + for nuc, value in atoms_per_barn_cm.items(): + mat.remove_nuclide(nuc) + mat.add_nuclide(nuc, value) mat.set_density('sum') + + # For nuclides in chain that have cross sections, replace + # density in original material with new density from results for nuc in result.nuc_to_ind: if nuc not in available_cross_sections: continue From 22e23374dd2433903168dc5c09c9fc603c293527 Mon Sep 17 00:00:00 2001 From: Olek <45364492+yardasol@users.noreply.github.com> Date: Thu, 11 Aug 2022 13:38:45 -0500 Subject: [PATCH 10/13] Apply suggestions from code review Co-authored-by: Paul Romano --- docs/source/pythonapi/deplete.rst | 2 +- openmc/deplete/openmc_operator.py | 1 - tests/regression_tests/deplete_no_transport/test.py | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/source/pythonapi/deplete.rst b/docs/source/pythonapi/deplete.rst index 4154e35df1..dd679a40a0 100644 --- a/docs/source/pythonapi/deplete.rst +++ b/docs/source/pythonapi/deplete.rst @@ -43,7 +43,7 @@ algorithms `_. SILEQIIntegrator Each of these classes expects a "transport operator" to be passed. OpenMC -provides The following classes implement transport operators: +provides the following transport operator classes: .. autosummary:: :toctree: generated diff --git a/openmc/deplete/openmc_operator.py b/openmc/deplete/openmc_operator.py index c340650782..ee569bf712 100644 --- a/openmc/deplete/openmc_operator.py +++ b/openmc/deplete/openmc_operator.py @@ -534,7 +534,6 @@ class OpenMCOperator(TransportOperator): rates[i] = self._rate_helper.divide_by_adens(number) # Scale reaction rates to obtain units of reactions/sec - print(f"flux, power, or source rate: {self._normalization_helper.factor(source_rate)}") rates *= self._normalization_helper.factor(source_rate) # Store new fission yields on the chain diff --git a/tests/regression_tests/deplete_no_transport/test.py b/tests/regression_tests/deplete_no_transport/test.py index bf4a4b132b..f5ee4bf1db 100644 --- a/tests/regression_tests/deplete_no_transport/test.py +++ b/tests/regression_tests/deplete_no_transport/test.py @@ -23,9 +23,7 @@ def fuel(): @pytest.fixture(scope="module") def micro_xs(): micro_xs_file = Path(__file__).parents[2] / 'micro_xs_simple.csv' - micro_xs = MicroXS.from_csv(micro_xs_file) - - return micro_xs + return MicroXS.from_csv(micro_xs_file) @pytest.fixture(scope="module") def chain_file(): From 5af0d291a1fc423d8c0a6aef9762fc344640aa3a Mon Sep 17 00:00:00 2001 From: yardasol Date: Thu, 11 Aug 2022 15:14:07 -0500 Subject: [PATCH 11/13] style fix on constant --- openmc/deplete/microxs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openmc/deplete/microxs.py b/openmc/deplete/microxs.py index 71e476c2c3..96a5e9dbd6 100644 --- a/openmc/deplete/microxs.py +++ b/openmc/deplete/microxs.py @@ -146,7 +146,7 @@ class MicroXS(DataFrame): for material in model.materials: if material.depletable: nuc_densities = material.get_nuclide_atom_densities() - dilute_density = 1.e-24 * dilute_initial + dilute_density = 1.0e-24 * dilute_initial material.set_density('sum') for nuc, density in nuc_densities.items(): material.remove_nuclide(nuc) From 3c483a7d7df53703381d1bb3ca3b30fc9e5c939c Mon Sep 17 00:00:00 2001 From: yardasol Date: Thu, 11 Aug 2022 17:25:28 -0500 Subject: [PATCH 12/13] add run_kwargs parameter to MicroXS.from_model() --- openmc/deplete/microxs.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/openmc/deplete/microxs.py b/openmc/deplete/microxs.py index 96a5e9dbd6..05831fb1a3 100644 --- a/openmc/deplete/microxs.py +++ b/openmc/deplete/microxs.py @@ -35,7 +35,8 @@ class MicroXS(DataFrame): reaction_domain, chain_file, dilute_initial=1.0e3, - energy_bounds=(0, 20e6)): + energy_bounds=(0, 20e6), + run_kwargs=None): """Generate a one-group cross-section dataframe using OpenMC. Note that the ``openmc`` executable must be compiled. @@ -57,6 +58,8 @@ class MicroXS(DataFrame): Reaction names to tally energy_bound : 2-tuple of float, optional Bounds for the energy group. + run_kwargs : dict, optional + Keyword arguments for :meth:`openmc.model.Model.run()` Returns ------- @@ -89,7 +92,12 @@ class MicroXS(DataFrame): # create temporary run with tempfile.TemporaryDirectory() as temp_dir: - statepoint_path = model.run(cwd=temp_dir) + if run_kwargs is None: + run_kwargs = {} + model.init_lib() + elif 'cwd' in run_kwargs: + run_kwargs.pop('cwd') + statepoint_path = model.run(cwd=temp_dir, **run_kwargs) with StatePoint(statepoint_path) as sp: for rx in xs: From f8101006d821abc109df45092088d5d8ce9794e2 Mon Sep 17 00:00:00 2001 From: Olek <45364492+yardasol@users.noreply.github.com> Date: Sat, 13 Aug 2022 10:20:19 -0500 Subject: [PATCH 13/13] remove `init_lib()` call in `MicroXS.from_model()`; use `setdefault` to ensure correct directory is used Co-authored-by: Paul Romano --- openmc/deplete/microxs.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/openmc/deplete/microxs.py b/openmc/deplete/microxs.py index 05831fb1a3..ccbfab5389 100644 --- a/openmc/deplete/microxs.py +++ b/openmc/deplete/microxs.py @@ -94,10 +94,8 @@ class MicroXS(DataFrame): with tempfile.TemporaryDirectory() as temp_dir: if run_kwargs is None: run_kwargs = {} - model.init_lib() - elif 'cwd' in run_kwargs: - run_kwargs.pop('cwd') - statepoint_path = model.run(cwd=temp_dir, **run_kwargs) + run_kwargs.setdefault('cwd', temp_dir) + statepoint_path = model.run(**run_kwargs) with StatePoint(statepoint_path) as sp: for rx in xs: