Merge pull request #1442 from paulromano/fixed-source-wgt-norm

Use number of particles for tally normalization
This commit is contained in:
Patrick Shriwise 2020-01-09 21:39:46 -06:00 committed by GitHub
commit f4e46fd620
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 102 additions and 69 deletions

View file

@ -831,11 +831,13 @@ void Tally::accumulate()
total_source = 1.0;
}
// Account for number of source particles in normalization
double norm = total_source / (settings::n_particles * settings::gen_per_batch);
// Accumulate each result
for (int i = 0; i < results_.shape()[0]; ++i) {
for (int j = 0; j < results_.shape()[1]; ++j) {
double val = results_(i, j, RESULT_VALUE) /
simulation::total_weight * total_source;
double val = results_(i, j, RESULT_VALUE) * norm;
results_(i, j, RESULT_VALUE) = 0.0;
results_(i, j, RESULT_SUM) += val;
results_(i, j, RESULT_SUM_SQ) += val*val;

View file

@ -16,7 +16,7 @@ tally 1:
3.347757E+01
1.124264E+02
2.931336E+01
8.607239E+01
8.607238E+01
2.182947E+01
4.789565E+01
1.147668E+01
@ -468,10 +468,10 @@ cmfd openmc source comparison
4.515310E-03
2.439840E-03
2.114032E-03
2.673132E-03
2.673131E-03
2.431749E-03
4.330928E-03
3.404647E-03
3.404646E-03
3.680298E-03
3.309620E-03
3.705541E-03

View file

@ -212,7 +212,7 @@ tally 4:
0.000000E+00
0.000000E+00
0.000000E+00
9.042233E+00
9.042232E+00
4.097018E+00
3.711597E+01
6.891834E+01
@ -256,7 +256,7 @@ tally 4:
4.161211E+00
3.715168E+01
6.904544E+01
9.042233E+00
9.042232E+00
4.097018E+00
3.711597E+01
6.891834E+01
@ -314,7 +314,7 @@ tally 5:
1.007512E+02
5.078162E+02
1.403236E+01
9.884347E+00
9.884346E+00
4.598486E+01
1.058070E+02
6.194677E+01

View file

@ -51,7 +51,7 @@ tally 2:
2.497751E+00
6.238760E+00
2.974675E+00
8.848690E+00
8.848691E+00
2.121163E+00
4.499332E+00
2.329248E+00
@ -76,7 +76,7 @@ tally 3:
1.521351E-01
2.314509E-02
2.610287E+00
6.813596E+00
6.813597E+00
1.718778E-01
2.954199E-02
2.911379E+00
@ -158,8 +158,8 @@ tally 4:
6.909608E-02
3.851599E-01
1.483482E-01
4.595809E-01
2.112146E-01
4.595810E-01
2.112147E-01
0.000000E+00
0.000000E+00
0.000000E+00
@ -176,8 +176,8 @@ tally 4:
0.000000E+00
0.000000E+00
0.000000E+00
4.595809E-01
2.112146E-01
4.595810E-01
2.112147E-01
3.851599E-01
1.483482E-01
4.679967E-01
@ -229,7 +229,7 @@ tally 4:
4.909661E-01
2.410477E-01
5.152690E-01
2.655021E-01
2.655022E-01
4.788649E-01
2.293116E-01
0.000000E+00
@ -251,7 +251,7 @@ tally 4:
4.788649E-01
2.293116E-01
5.152690E-01
2.655021E-01
2.655022E-01
4.266876E-01
1.820623E-01
3.401342E-01
@ -277,7 +277,7 @@ tally 4:
4.266876E-01
1.820623E-01
3.724186E-01
1.386956E-01
1.386957E-01
2.560013E-01
6.553669E-02
0.000000E+00
@ -299,7 +299,7 @@ tally 4:
2.560013E-01
6.553669E-02
3.724186E-01
1.386956E-01
1.386957E-01
2.892134E-01
8.364439E-02
1.556176E-01
@ -356,7 +356,7 @@ tally 5:
2.047332E+00
4.191570E+00
2.627497E-01
6.903740E-02
6.903741E-02
2.609217E+00
6.808012E+00
3.360314E-01

View file

@ -222,7 +222,7 @@ tally 4:
2.662637E-01
2.719284E+01
4.625227E+01
7.106615E+00
7.106614E+00
3.182962E+00
2.092906E+00
2.757959E-01
@ -276,7 +276,7 @@ tally 4:
0.000000E+00
0.000000E+00
0.000000E+00
7.106615E+00
7.106614E+00
3.182962E+00
2.092906E+00
2.757959E-01

View file

@ -1,7 +1,7 @@
k-combined:
1.165408E+00 1.127320E-02
tally 1:
1.141009E+01
1.141008E+01
1.305436E+01
2.074878E+01
4.311543E+01
@ -63,7 +63,7 @@ tally 2:
8.282626E-01
6.860190E-01
tally 3:
7.459525E-01
7.459524E-01
5.564451E-01
4.877161E-02
2.378670E-03
@ -230,7 +230,7 @@ tally 4:
2.410423E-01
5.152620E-01
2.654949E-01
4.788580E-01
4.788579E-01
2.293049E-01
0.000000E+00
0.000000E+00
@ -248,7 +248,7 @@ tally 4:
0.000000E+00
0.000000E+00
0.000000E+00
4.788580E-01
4.788579E-01
2.293049E-01
5.152620E-01
2.654949E-01
@ -345,10 +345,10 @@ tally 4:
0.000000E+00
0.000000E+00
tally 5:
7.459525E-01
7.459524E-01
5.564451E-01
1.149859E-01
1.322177E-02
1.322176E-02
1.356729E+00
1.840713E+00
1.801152E-01
@ -362,7 +362,7 @@ tally 5:
3.360312E-01
1.129170E-01
2.909427E+00
8.464765E+00
8.464764E+00
4.095398E-01
1.677229E-01
2.805095E+00

View file

@ -7,7 +7,7 @@ tally 1:
4.162146E+01
2.839961E+01
8.098764E+01
3.405187E+01
3.405186E+01
1.164951E+02
3.712390E+01
1.380899E+02

View file

@ -16,7 +16,7 @@ tally 1:
3.347757E+01
1.124264E+02
2.931336E+01
8.607239E+01
8.607238E+01
2.182947E+01
4.789565E+01
1.147668E+01
@ -468,10 +468,10 @@ cmfd openmc source comparison
4.515310E-03
2.439840E-03
2.114032E-03
2.673132E-03
2.673131E-03
2.431749E-03
4.330928E-03
3.404647E-03
3.404646E-03
3.680298E-03
3.309620E-03
3.705541E-03

View file

@ -1,8 +0,0 @@
<?xml version="1.0"?>
<geometry>
<!-- Sphere with radius 10 -->
<surface id="1" type="sphere" coeffs="0 0 0 10" boundary="vacuum"/>
<cell id="1" material="1" region="-1" />
</geometry>

View file

@ -0,0 +1,31 @@
<?xml version='1.0' encoding='utf-8'?>
<geometry>
<cell id="1" material="1" region="-1" universe="1" />
<surface boundary="vacuum" coeffs="0.0 0.0 0.0 10.0" id="1" type="sphere" />
</geometry>
<?xml version='1.0' encoding='utf-8'?>
<materials>
<material depletable="true" id="1">
<density units="g/cm3" value="4.5" />
<nuclide ao="1.0" name="U235" />
</material>
</materials>
<?xml version='1.0' encoding='utf-8'?>
<settings>
<run_mode>eigenvalue</run_mode>
<particles>1000</particles>
<batches>7</batches>
<inactive>3</inactive>
<generations_per_batch>3</generations_per_batch>
<source strength="1.0">
<space type="box">
<parameters>-4.0 -4.0 -4.0 4.0 4.0 4.0</parameters>
</space>
</source>
</settings>
<?xml version='1.0' encoding='utf-8'?>
<tallies>
<tally id="1">
<scores>flux</scores>
</tally>
</tallies>

View file

@ -1,9 +0,0 @@
<?xml version="1.0"?>
<materials>
<material id="1">
<density value="4.5" units="g/cc" />
<nuclide name="U235" ao="1.0" />
</material>
</materials>

View file

@ -1,2 +1,5 @@
k-combined:
3.001411E-01 2.669758E-03
tally 1:
3.219698E+01
2.591699E+02

View file

@ -1,16 +0,0 @@
<?xml version="1.0"?>
<settings>
<run_mode>eigenvalue</run_mode>
<batches>7</batches>
<inactive>3</inactive>
<particles>1000</particles>
<generations_per_batch>3</generations_per_batch>
<source>
<space type="box">
<parameters>-4 -4 -4 4 4 4</parameters>
</space>
</source>
</settings>

View file

@ -1,6 +1,36 @@
from tests.testing_harness import TestHarness
import openmc
import pytest
from tests.testing_harness import PyAPITestHarness
def test_eigenvalue_genperbatch():
harness = TestHarness('statepoint.7.h5')
@pytest.fixture
def model():
model = openmc.model.Model()
m = openmc.Material()
m.set_density('g/cm3', 4.5)
m.add_nuclide('U235', 1.0)
model.materials.append(m)
sph = openmc.Sphere(r=10.0, boundary_type='vacuum')
c = openmc.Cell(fill=m, region=-sph)
model.geometry = openmc.Geometry([c])
model.settings.particles = 1000
model.settings.inactive = 3
model.settings.batches = 7
model.settings.generations_per_batch = 3
space = openmc.stats.Box((-4.0, -4.0, -4.0), (4.0, 4.0, 4.))
model.settings.source = openmc.Source(space=space)
t = openmc.Tally()
t.scores = ['flux']
model.tallies.append(t)
return model
def test_eigenvalue_genperbatch(model):
harness = PyAPITestHarness('statepoint.7.h5', model)
harness.main()

View file

@ -1 +1 @@
c37e0468f1684f7810429332721762884f3cdf0429d38caa99500bbde04ad84cf1e1639adc46b6db44b28b6f31028ed029f85920c8164d77463b6d89336043a8
67a1b19f5ee0260a5efd99e0712c5dc8c770b04bcb70aad5c47cdc67e8ea2f9148a9d122598d0f0d2bc2f2ae0222e1a78c8fed10dfb49866123a137b6c1c1264