Merge pull request #1209 from liangjg/photon-analog

Fix photon tally issues when using analog/collision estimators
This commit is contained in:
Paul Romano 2019-04-01 09:27:28 -05:00 committed by GitHub
commit 13a9c316b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 14 deletions

View file

@ -56,7 +56,6 @@ void collision(Particle* p)
if (p->E_ < settings::energy_cutoff[type]) {
p->alive_ = false;
p->wgt_ = 0.0;
p->wgt_last_ = 0.0;
}
// Display information about collision

View file

@ -717,7 +717,7 @@ void read_tallies_xml()
const auto& f = model::tally_filters[i_filter].get();
auto pf = dynamic_cast<ParticleFilter*>(f);
if (pf) particle_filter_index = j;
if (pf) particle_filter_index = i_filter;
// Change the tally estimator if a filter demands it
std::string filt_type = f->type();

View file

@ -3,7 +3,7 @@
<cell id="13" material="void" region="-9 10 -11" universe="9" />
<cell id="14" material="13" region="-9 11 -12" universe="9" />
<cell id="15" material="void" region="~(-9 10 -12)" universe="9" />
<surface boundary="vacuum" coeffs="0.0 0.0 1e-06" id="9" type="x-cylinder" />
<surface boundary="vacuum" coeffs="0.0 0.0 1.0" id="9" type="x-cylinder" />
<surface boundary="vacuum" coeffs="-1.0" id="10" type="x-plane" />
<surface coeffs="1.0" id="11" type="x-plane" />
<surface boundary="vacuum" coeffs="1000000000.0" id="12" type="x-plane" />
@ -47,4 +47,19 @@
<filters>1 2</filters>
<scores>current</scores>
</tally>
<tally id="2">
<filters>2</filters>
<scores>total</scores>
<estimator>tracklength</estimator>
</tally>
<tally id="3">
<filters>2</filters>
<scores>total</scores>
<estimator>collision</estimator>
</tally>
<tally id="4">
<filters>2</filters>
<scores>total</scores>
<estimator>analog</estimator>
</tally>
</tallies>

View file

@ -1,3 +1,12 @@
tally 1:
sum = 7.938000E-01
sum_sq = 6.301184E-01
9.403000E-01
8.841641E-01
tally 2:
8.281718E-01
6.858685E-01
tally 3:
8.242000E-01
6.793056E-01
tally 4:
8.242000E-01
6.793056E-01

View file

@ -14,7 +14,7 @@ class SourceTestHarness(PyAPITestHarness):
materials = openmc.Materials([mat])
materials.export_to_xml()
cyl = openmc.XCylinder(boundary_type='vacuum', r=1.0e-6)
cyl = openmc.XCylinder(boundary_type='vacuum', r=1.0)
x_plane_left = openmc.XPlane(boundary_type='vacuum', x0=-1.0)
x_plane_center = openmc.XPlane(boundary_type='transmission', x0=1.0)
x_plane_right = openmc.XPlane(boundary_type='vacuum', x0=1.0e9)
@ -48,20 +48,37 @@ class SourceTestHarness(PyAPITestHarness):
surface_filter = openmc.SurfaceFilter(cyl)
particle_filter = openmc.ParticleFilter('photon')
tally = openmc.Tally()
tally.filters = [surface_filter, particle_filter]
tally.scores = ['current']
tallies = openmc.Tallies([tally])
current_tally = openmc.Tally()
current_tally.filters = [surface_filter, particle_filter]
current_tally.scores = ['current']
total_tally_tracklength = openmc.Tally()
total_tally_tracklength.filters = [particle_filter]
total_tally_tracklength.scores = ['total']
total_tally_tracklength.estimator = 'tracklength'
total_tally_collision = openmc.Tally()
total_tally_collision.filters = [particle_filter]
total_tally_collision.scores = ['total']
total_tally_collision.estimator = 'collision'
total_tally_analog = openmc.Tally()
total_tally_analog.filters = [particle_filter]
total_tally_analog.scores = ['total']
total_tally_analog.estimator = 'analog'
tallies = openmc.Tallies([current_tally, total_tally_tracklength,
total_tally_collision, total_tally_analog])
tallies.export_to_xml()
def _get_results(self):
with openmc.StatePoint(self._sp_name) as sp:
outstr = ''
t = sp.get_tally()
outstr += 'tally {}:\n'.format(t.id)
outstr += 'sum = {:12.6E}\n'.format(t.sum[0, 0, 0])
outstr += 'sum_sq = {:12.6E}\n'.format(t.sum_sq[0, 0, 0])
for i, tally_ind in enumerate(sp.tallies):
tally = sp.tallies[tally_ind]
results = np.zeros((tally.sum.size * 2, ))
results[0::2] = tally.sum.ravel()
results[1::2] = tally.sum_sq.ravel()
results = ['{0:12.6E}'.format(x) for x in results]
outstr += 'tally {}:\n'.format(i + 1)
outstr += '\n'.join(results) + '\n'
return outstr