Skip to content

Commit cf77e9b

Browse files
authored
Merge pull request #470 from steps-re/fix/neutron-physics-sampling
fix: correct several neutron sampling / tally bugs
2 parents 859bcfc + 86eec71 commit cf77e9b

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

mcdc/object_/tally.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def __init__(
198198
self.filter_direction = True
199199
if polar_reference is not None:
200200
polar_reference = np.array(polar_reference)
201-
self.polar_reference /= polar_reference / np.linalg.norm(polar_reference)
201+
self.polar_reference = polar_reference / np.linalg.norm(polar_reference)
202202
if energy is not None:
203203
if type(energy) == str and energy == "all_groups":
204204
G = simulation.materials[0].G

mcdc/transport/distribution.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ def sample_direction(polar_cosine, azimuthal, polar_coordinate, rng_state):
154154
wy = polar_coordinate[1]
155155
wz = polar_coordinate[2]
156156
if abs(wz) >= 0.999:
157+
# Axis nearly parallel to z: use a fixed transverse basis
158+
ux, uy, uz = 1.0, 0.0, 0.0
159+
vx, vy, vz = 0.0, 1.0, 0.0
160+
else:
157161
inv = 1.0 / math.sqrt(wx * wx + wy * wy)
158162

159163
ux = -wy * inv
@@ -163,10 +167,6 @@ def sample_direction(polar_cosine, azimuthal, polar_coordinate, rng_state):
163167
vx = -wz * wx * inv
164168
vy = -wz * wy * inv
165169
vz = math.sqrt(wx * wx + wy * wy)
166-
else:
167-
# Axis nearly parallel to z
168-
ux, uy, uz = 1.0, 0.0, 0.0
169-
vx, vy, vz = 0.0, 1.0, 0.0
170170

171171
# Rotate into lab frame
172172
s = math.sqrt(max(0.0, 1.0 - mu * mu))
@@ -271,7 +271,7 @@ def sample_white_direction(nx, ny, nz, rng_state):
271271
sin_azi = math.sin(azi)
272272
Ac = (1.0 - mu**2) ** 0.5
273273

274-
if nz != 1.0:
274+
if abs(nz) != 1.0:
275275
B = (1.0 - nz**2) ** 0.5
276276
C = Ac / B
277277

mcdc/transport/physics/neutron/native.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def fission(
828828
prompt = True
829829
delayed_group = -1
830830
xi = rng.lcg(particle_container_new)
831-
total = nu_p
831+
total = nu_p / nu
832832
if xi > total:
833833
prompt = False
834834
# Determine delayed group
@@ -912,7 +912,7 @@ def fission(
912912
ux_new, uy_new, uz_new = sample_isotropic_direction(particle_container_new)
913913

914914
# Sample emission time
915-
decay_rate = mcdc_get.nuclide.neutron_fission_delayed_fractions(
915+
decay_rate = mcdc_get.nuclide.neutron_fission_delayed_decay_rates(
916916
delayed_group, nuclide, data
917917
)
918918
if not prompt:
0 Bytes
Binary file not shown.
2.21 KB
Binary file not shown.

0 commit comments

Comments
 (0)