mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Updating tests to include checks for quadratic/cubic interpolation
This commit is contained in:
parent
3b00ed3864
commit
b68e6e96e6
3 changed files with 57 additions and 4 deletions
|
|
@ -39,6 +39,21 @@
|
|||
<y>0.1 0.1 0.1333 0.158 0.18467 0.25618 0.4297 0.48 0.48</y>
|
||||
<interpolation>log-linear</interpolation>
|
||||
</filter>
|
||||
<filter id="6" type="energyfunction">
|
||||
<energy>0.0 5000000.0 10000000.0 15000000.0</energy>
|
||||
<y>0.2 0.7 0.7 0.2</y>
|
||||
<interpolation>linear-linear</interpolation>
|
||||
</filter>
|
||||
<filter id="7" type="energyfunction">
|
||||
<energy>0.0 5000000.0 10000000.0 15000000.0</energy>
|
||||
<y>0.2 0.7 0.7 0.2</y>
|
||||
<interpolation>quadratic</interpolation>
|
||||
</filter>
|
||||
<filter id="8" type="energyfunction">
|
||||
<energy>0.0 5000000.0 10000000.0 15000000.0</energy>
|
||||
<y>0.2 0.7 0.7 0.2</y>
|
||||
<interpolation>cubic</interpolation>
|
||||
</filter>
|
||||
<tally id="1">
|
||||
<nuclides>Am241</nuclides>
|
||||
<scores>(n,gamma)</scores>
|
||||
|
|
@ -63,4 +78,19 @@
|
|||
<nuclides>Am241</nuclides>
|
||||
<scores>(n,gamma)</scores>
|
||||
</tally>
|
||||
<tally id="6">
|
||||
<filters>6</filters>
|
||||
<nuclides>Am241</nuclides>
|
||||
<scores>(n,gamma)</scores>
|
||||
</tally>
|
||||
<tally id="7">
|
||||
<filters>7</filters>
|
||||
<nuclides>Am241</nuclides>
|
||||
<scores>(n,gamma)</scores>
|
||||
</tally>
|
||||
<tally id="8">
|
||||
<filters>8</filters>
|
||||
<nuclides>Am241</nuclides>
|
||||
<scores>(n,gamma)</scores>
|
||||
</tally>
|
||||
</tallies>
|
||||
|
|
|
|||
|
|
@ -6,3 +6,5 @@
|
|||
0 b4e2ac84068d2d Am241 (n,gamma) 8.19e-02 2.25e-03
|
||||
energyfunction nuclide score mean std. dev.
|
||||
0 dacf88242512ea Am241 (n,gamma) 7.95e-02 2.19e-03
|
||||
energyfunction nuclide score mean std. dev.
|
||||
0 fe168c70d9e078 Am241 (n,gamma) 1.06e-01 2.96e-03
|
||||
|
|
|
|||
|
|
@ -48,9 +48,21 @@ def model():
|
|||
filt5 = openmc.EnergyFunctionFilter(x, y)
|
||||
filt5.interpolation = 'log-linear'
|
||||
|
||||
filters = [filt1, filt3, filt4, filt5]
|
||||
# define a trapezoidal function for comparison
|
||||
x = [0.0, 5e6, 1e7, 1.5e7]
|
||||
y = [0.2, 0.7, 0.7, 0.2]
|
||||
|
||||
filt6 = openmc.EnergyFunctionFilter(x, y)
|
||||
|
||||
filt7 = openmc.EnergyFunctionFilter(x, y)
|
||||
filt7.interpolation = 'quadratic'
|
||||
|
||||
filt8 = openmc.EnergyFunctionFilter(x, y)
|
||||
filt8.interpolation = 'cubic'
|
||||
|
||||
filters = [filt1, filt3, filt4, filt5, filt6, filt7, filt8]
|
||||
# Make tallies
|
||||
tallies = [openmc.Tally() for i in range(5)]
|
||||
tallies = [openmc.Tally() for _ in range(len(filters) + 1)]
|
||||
for t in tallies:
|
||||
t.scores = ['(n,gamma)']
|
||||
t.nuclides = ['Am241']
|
||||
|
|
@ -73,7 +85,7 @@ class FilterEnergyFunHarness(PyAPITestHarness):
|
|||
br_tally = sp.tallies[2] / sp.tallies[1]
|
||||
dataframes_string += br_tally.get_pandas_dataframe().to_string() + '\n'
|
||||
|
||||
for t_id in (3, 4, 5):
|
||||
for t_id in (3, 4, 5, 6):
|
||||
ef_tally = sp.tallies[t_id]
|
||||
dataframes_string += ef_tally.get_pandas_dataframe().to_string() + '\n'
|
||||
|
||||
|
|
@ -122,7 +134,16 @@ class FilterEnergyFunHarness(PyAPITestHarness):
|
|||
sp_log_lin_filt = sp_log_lin_tally.find_filter(openmc.EnergyFunctionFilter)
|
||||
assert sp_log_lin_filt.interpolation == 'log-linear'
|
||||
|
||||
# check that the cubic interpolation provides a higher value
|
||||
# than linear-linear
|
||||
contrived_lin_lin_tally = sp.get_tally(id=6)
|
||||
contrived_quadratic_tally = sp.get_tally(id=7)
|
||||
contrived_cubic_tally = sp.get_tally(id=8)
|
||||
|
||||
assert all(contrived_lin_lin_tally.mean < contrived_quadratic_tally.mean)
|
||||
assert all(contrived_lin_lin_tally.mean < contrived_cubic_tally.mean)
|
||||
|
||||
|
||||
def test_filter_energyfun(model):
|
||||
harness = FilterEnergyFunHarness('statepoint.5.h5', model)
|
||||
harness.main()
|
||||
harness.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue