Skip to content

Commit 2dd5322

Browse files
Fix undefined variable in openmc.mgxs.library (scatt_mgxs) (#3943)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
1 parent 46d8896 commit 2dd5322

4 files changed

Lines changed: 244 additions & 5 deletions

File tree

openmc/mgxs/library.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,6 +1290,14 @@ def get_xsdata(self, domain, xsdata_name, nuclide='total', xs_type='macro',
12901290
'are ignored since multiplicity or nu-scatter matrices '\
12911291
'were not tallied for ' + xsdata_name
12921292
warn(msg, RuntimeWarning)
1293+
1294+
if 'scatter matrix' in self.mgxs_types:
1295+
scatt_mgxs = self.get_mgxs(domain, 'scatter matrix')
1296+
elif 'consistent scatter matrix' in self.mgxs_types:
1297+
scatt_mgxs = self.get_mgxs(domain, 'consistent scatter matrix')
1298+
else:
1299+
raise ValueError(f'No scatter matrix found for {xsdata_name}.')
1300+
12931301
xsdata.set_scatter_matrix_mgxs(scatt_mgxs, temperature=temperature,
12941302
xs_type=xs_type,
12951303
nuclide=[nuclide],

tests/regression_tests/mgxs_library_ce_to_mg/inputs_true.dat renamed to tests/regression_tests/mgxs_library_ce_to_mg/inputs_true_multiplicity_matrix.dat

File renamed without changes.
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<model>
3+
<materials>
4+
<material id="7" name="UO2 (2.4%)" depletable="true">
5+
<density value="10.29769" units="g/cm3"/>
6+
<nuclide name="U234" ao="4.4843e-06"/>
7+
<nuclide name="U235" ao="0.00055815"/>
8+
<nuclide name="U238" ao="0.022408"/>
9+
<nuclide name="O16" ao="0.045829"/>
10+
</material>
11+
<material id="8" name="Zircaloy">
12+
<density value="6.55" units="g/cm3"/>
13+
<nuclide name="Zr90" ao="0.021827"/>
14+
<nuclide name="Zr91" ao="0.00476"/>
15+
<nuclide name="Zr92" ao="0.0072758"/>
16+
<nuclide name="Zr94" ao="0.0073734"/>
17+
<nuclide name="Zr96" ao="0.0011879"/>
18+
</material>
19+
<material id="9" name="Hot borated water">
20+
<density value="0.740582" units="g/cm3"/>
21+
<nuclide name="H1" ao="0.049457"/>
22+
<nuclide name="O16" ao="0.024672"/>
23+
<nuclide name="B10" ao="8.0042e-06"/>
24+
<nuclide name="B11" ao="3.2218e-05"/>
25+
<sab name="c_H_in_H2O"/>
26+
</material>
27+
</materials>
28+
<geometry>
29+
<cell id="4" name="Fuel" material="7" region="-7" universe="0"/>
30+
<cell id="5" name="Cladding" material="8" region="7 -8" universe="0"/>
31+
<cell id="6" name="Water" material="9" region="8 9 -10 11 -12" universe="0"/>
32+
<surface id="7" name="Fuel OR" type="z-cylinder" coeffs="0 0 0.39218"/>
33+
<surface id="8" name="Clad OR" type="z-cylinder" coeffs="0 0 0.4572"/>
34+
<surface id="9" name="left" type="x-plane" boundary="reflective" coeffs="-0.63"/>
35+
<surface id="10" name="right" type="x-plane" boundary="reflective" coeffs="0.63"/>
36+
<surface id="11" name="bottom" type="y-plane" boundary="reflective" coeffs="-0.63"/>
37+
<surface id="12" name="top" type="y-plane" boundary="reflective" coeffs="0.63"/>
38+
</geometry>
39+
<settings>
40+
<run_mode>eigenvalue</run_mode>
41+
<particles>100</particles>
42+
<batches>10</batches>
43+
<inactive>5</inactive>
44+
<source type="independent" strength="1.0" particle="neutron">
45+
<space type="box">
46+
<parameters>-0.63 -0.63 -1 0.63 0.63 1</parameters>
47+
</space>
48+
<constraints>
49+
<fissionable>true</fissionable>
50+
</constraints>
51+
</source>
52+
</settings>
53+
<tallies>
54+
<filter id="43" type="material">
55+
<bins>7</bins>
56+
</filter>
57+
<filter id="44" type="energy">
58+
<bins>0.0 0.625 20000000.0</bins>
59+
</filter>
60+
<filter id="49" type="energyout">
61+
<bins>0.0 0.625 20000000.0</bins>
62+
</filter>
63+
<filter id="53" type="legendre">
64+
<order>3</order>
65+
</filter>
66+
<filter id="54" type="material">
67+
<bins>8</bins>
68+
</filter>
69+
<filter id="65" type="material">
70+
<bins>9</bins>
71+
</filter>
72+
<tally id="76">
73+
<filters>43 44</filters>
74+
<nuclides>total</nuclides>
75+
<scores>flux</scores>
76+
<estimator>tracklength</estimator>
77+
</tally>
78+
<tally id="77">
79+
<filters>43 44</filters>
80+
<nuclides>total</nuclides>
81+
<scores>total</scores>
82+
<estimator>tracklength</estimator>
83+
</tally>
84+
<tally id="78">
85+
<filters>43 44</filters>
86+
<nuclides>total</nuclides>
87+
<scores>flux</scores>
88+
<estimator>tracklength</estimator>
89+
</tally>
90+
<tally id="79">
91+
<filters>43 44</filters>
92+
<nuclides>total</nuclides>
93+
<scores>absorption</scores>
94+
<estimator>tracklength</estimator>
95+
</tally>
96+
<tally id="80">
97+
<filters>43 44</filters>
98+
<nuclides>total</nuclides>
99+
<scores>flux</scores>
100+
<estimator>analog</estimator>
101+
</tally>
102+
<tally id="81">
103+
<filters>43 44 49</filters>
104+
<nuclides>total</nuclides>
105+
<scores>nu-fission</scores>
106+
<estimator>analog</estimator>
107+
</tally>
108+
<tally id="82">
109+
<filters>43 44</filters>
110+
<nuclides>total</nuclides>
111+
<scores>flux</scores>
112+
<estimator>analog</estimator>
113+
</tally>
114+
<tally id="83">
115+
<filters>43 44 49 53</filters>
116+
<nuclides>total</nuclides>
117+
<scores>scatter</scores>
118+
<estimator>analog</estimator>
119+
</tally>
120+
<tally id="84">
121+
<filters>54 44</filters>
122+
<nuclides>total</nuclides>
123+
<scores>flux</scores>
124+
<estimator>tracklength</estimator>
125+
</tally>
126+
<tally id="85">
127+
<filters>54 44</filters>
128+
<nuclides>total</nuclides>
129+
<scores>total</scores>
130+
<estimator>tracklength</estimator>
131+
</tally>
132+
<tally id="86">
133+
<filters>54 44</filters>
134+
<nuclides>total</nuclides>
135+
<scores>flux</scores>
136+
<estimator>tracklength</estimator>
137+
</tally>
138+
<tally id="87">
139+
<filters>54 44</filters>
140+
<nuclides>total</nuclides>
141+
<scores>absorption</scores>
142+
<estimator>tracklength</estimator>
143+
</tally>
144+
<tally id="88">
145+
<filters>54 44</filters>
146+
<nuclides>total</nuclides>
147+
<scores>flux</scores>
148+
<estimator>analog</estimator>
149+
</tally>
150+
<tally id="89">
151+
<filters>54 44 49</filters>
152+
<nuclides>total</nuclides>
153+
<scores>nu-fission</scores>
154+
<estimator>analog</estimator>
155+
</tally>
156+
<tally id="90">
157+
<filters>54 44</filters>
158+
<nuclides>total</nuclides>
159+
<scores>flux</scores>
160+
<estimator>analog</estimator>
161+
</tally>
162+
<tally id="91">
163+
<filters>54 44 49 53</filters>
164+
<nuclides>total</nuclides>
165+
<scores>scatter</scores>
166+
<estimator>analog</estimator>
167+
</tally>
168+
<tally id="92">
169+
<filters>65 44</filters>
170+
<nuclides>total</nuclides>
171+
<scores>flux</scores>
172+
<estimator>tracklength</estimator>
173+
</tally>
174+
<tally id="93">
175+
<filters>65 44</filters>
176+
<nuclides>total</nuclides>
177+
<scores>total</scores>
178+
<estimator>tracklength</estimator>
179+
</tally>
180+
<tally id="94">
181+
<filters>65 44</filters>
182+
<nuclides>total</nuclides>
183+
<scores>flux</scores>
184+
<estimator>tracklength</estimator>
185+
</tally>
186+
<tally id="95">
187+
<filters>65 44</filters>
188+
<nuclides>total</nuclides>
189+
<scores>absorption</scores>
190+
<estimator>tracklength</estimator>
191+
</tally>
192+
<tally id="96">
193+
<filters>65 44</filters>
194+
<nuclides>total</nuclides>
195+
<scores>flux</scores>
196+
<estimator>analog</estimator>
197+
</tally>
198+
<tally id="97">
199+
<filters>65 44 49</filters>
200+
<nuclides>total</nuclides>
201+
<scores>nu-fission</scores>
202+
<estimator>analog</estimator>
203+
</tally>
204+
<tally id="98">
205+
<filters>65 44</filters>
206+
<nuclides>total</nuclides>
207+
<scores>flux</scores>
208+
<estimator>analog</estimator>
209+
</tally>
210+
<tally id="99">
211+
<filters>65 44 49 53</filters>
212+
<nuclides>total</nuclides>
213+
<scores>scatter</scores>
214+
<estimator>analog</estimator>
215+
</tally>
216+
</tallies>
217+
</model>

tests/regression_tests/mgxs_library_ce_to_mg/test.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class MGXSTestHarness(PyAPITestHarness):
12-
def __init__(self, *args, **kwargs):
12+
def __init__(self, *args, scatter_mgxs_type=None, **kwargs):
1313
# Generate inputs using parent class routine
1414
super().__init__(*args, **kwargs)
1515

@@ -19,8 +19,8 @@ def __init__(self, *args, **kwargs):
1919
# Initialize MGXS Library for a few cross section types
2020
self.mgxs_lib = openmc.mgxs.Library(self._model.geometry)
2121
self.mgxs_lib.by_nuclide = False
22-
self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix',
23-
'nu-scatter matrix', 'multiplicity matrix']
22+
self.mgxs_lib.mgxs_types = ['total', 'absorption', 'nu-fission matrix']
23+
self.mgxs_lib.mgxs_types += scatter_mgxs_type
2424
self.mgxs_lib.energy_groups = energy_groups
2525
self.mgxs_lib.correction = None
2626
self.mgxs_lib.legendre_order = 3
@@ -69,9 +69,23 @@ def _cleanup(self):
6969
os.remove(f)
7070

7171

72-
def test_mgxs_library_ce_to_mg():
72+
def test_mgxs_library_ce_to_mg_multiplicity_matrix():
7373
# Set the input set to use the pincell model
7474
model = pwr_pin_cell()
7575

76-
harness = MGXSTestHarness('statepoint.10.h5', model)
76+
harness = MGXSTestHarness(
77+
'statepoint.10.h5', model,
78+
inputs_true='inputs_true_multiplicity_matrix.dat',
79+
scatter_mgxs_type=['nu-scatter matrix', 'multiplicity matrix']
80+
)
81+
harness.main()
82+
83+
84+
def test_mgxs_library_ce_to_mg_scatter_matrix():
85+
# Set the input set to use the pincell model
86+
model = pwr_pin_cell()
87+
88+
harness = MGXSTestHarness('statepoint.10.h5', model,
89+
inputs_true='inputs_true_scatter_matrix.dat',
90+
scatter_mgxs_type=['scatter matrix'])
7791
harness.main()

0 commit comments

Comments
 (0)