import openmc.examples
model = openmc.examples.pwr_pin_cell()
# Use a library that has heating-local data
model.materials.cross_sections = '/opt/data/hdf5/endfb71_hdf5/cross_sections.xml'
model.settings.particles = 10000
model.settings.inactive = 10
model.settings.batches = 50
model.settings.photon_transport = True
particle_filter = openmc.ParticleFilter(['neutron', 'photon'])
mat_filter = openmc.MaterialFilter(model.materials)
t1 = openmc.Tally()
t1.filters = [mat_filter, particle_filter]
t1.scores = ['fission', 'heating', 'heating-local']
model.tallies.append(t1)
model.export_to_xml()
openmc.run(output=False)
with openmc.StatePoint(f'statepoint.{model.settings.batches}.h5') as sp:
df = sp.tallies[1].get_pandas_dataframe()
df
material | particle | nuclide | score | mean | std. dev. | |
---|---|---|---|---|---|---|
0 | 1 | neutron | total | fission | 4.712912e-01 | 0.000560 |
1 | 1 | neutron | total | heating | 8.296674e+07 | 98225.558086 |
2 | 1 | neutron | total | heating-local | 9.132275e+07 | 106503.058968 |
3 | 1 | photon | total | fission | 0.000000e+00 | 0.000000 |
4 | 1 | photon | total | heating | 9.707006e+06 | 10281.962817 |
5 | 1 | photon | total | heating-local | 0.000000e+00 | 0.000000 |
6 | 2 | neutron | total | fission | 0.000000e+00 | 0.000000 |
7 | 2 | neutron | total | heating | 8.598917e+03 | 14.340791 |
8 | 2 | neutron | total | heating-local | 1.876138e+05 | 486.838500 |
9 | 2 | photon | total | fission | 0.000000e+00 | 0.000000 |
10 | 2 | photon | total | heating | 1.253789e+06 | 1403.575649 |
11 | 2 | photon | total | heating-local | 0.000000e+00 | 0.000000 |
12 | 3 | neutron | total | fission | 0.000000e+00 | 0.000000 |
13 | 3 | neutron | total | heating | 1.593696e+06 | 2263.684248 |
14 | 3 | neutron | total | heating-local | 1.756963e+06 | 2320.578770 |
15 | 3 | photon | total | fission | 0.000000e+00 | 0.000000 |
16 | 3 | photon | total | heating | 7.558494e+05 | 943.374655 |
17 | 3 | photon | total | heating-local | 0.000000e+00 | 0.000000 |
totals = df.groupby('score').sum()
totals
material | mean | std. dev. | |
---|---|---|---|
score | |||
fission | 12 | 4.712912e-01 | 0.000560 |
heating | 12 | 9.628568e+07 | 113132.496247 |
heating-local | 12 | 9.326733e+07 | 109310.476239 |
totals.loc['heating', 'mean'] / totals.loc['fission', 'mean'] / 1e6
204.30190326787005
totals.loc['heating-local', 'mean'] / totals.loc['fission', 'mean'] / 1e6
197.89746402501413
model.settings.electron_treatment = 'led'
model.export_to_xml()
openmc.run(output=False)
with openmc.StatePoint(f'statepoint.{model.settings.batches}.h5') as sp:
df_led = sp.tallies[1].get_pandas_dataframe()
df_led
material | particle | nuclide | score | mean | std. dev. | |
---|---|---|---|---|---|---|
0 | 1 | neutron | total | fission | 4.712912e-01 | 0.000560 |
1 | 1 | neutron | total | heating | 8.296674e+07 | 98225.558086 |
2 | 1 | neutron | total | heating-local | 9.132275e+07 | 106503.058970 |
3 | 1 | photon | total | fission | 0.000000e+00 | 0.000000 |
4 | 1 | photon | total | heating | 9.139772e+06 | 11099.191538 |
5 | 1 | photon | total | heating-local | 0.000000e+00 | 0.000000 |
6 | 2 | neutron | total | fission | 0.000000e+00 | 0.000000 |
7 | 2 | neutron | total | heating | 8.598917e+03 | 14.340791 |
8 | 2 | neutron | total | heating-local | 1.876138e+05 | 486.838500 |
9 | 2 | photon | total | fission | 0.000000e+00 | 0.000000 |
10 | 2 | photon | total | heating | 1.206271e+06 | 1590.402336 |
11 | 2 | photon | total | heating-local | 0.000000e+00 | 0.000000 |
12 | 3 | neutron | total | fission | 0.000000e+00 | 0.000000 |
13 | 3 | neutron | total | heating | 1.593696e+06 | 2263.684248 |
14 | 3 | neutron | total | heating-local | 1.756963e+06 | 2320.578770 |
15 | 3 | photon | total | fission | 0.000000e+00 | 0.000000 |
16 | 3 | photon | total | heating | 7.416471e+05 | 984.143188 |
17 | 3 | photon | total | heating-local | 0.000000e+00 | 0.000000 |
totals2 = df_led.groupby('score').sum()
totals2
material | mean | std. dev. | |
---|---|---|---|
score | |||
fission | 12 | 4.712912e-01 | 0.000560 |
heating | 12 | 9.565673e+07 | 114177.320188 |
heating-local | 12 | 9.326733e+07 | 109310.476240 |
totals2.loc['heating', 'mean'] / totals2.loc['fission', 'mean'] / 1e6
202.96736866489894