Skip to content

Commit

Permalink
Do not divide particle energy weight by frequency.
Browse files Browse the repository at this point in the history
+ Remove division by frequency in source particle creation.
+ Update singularity-opac commit to correct mean opacity accesses.
+ Have regressions fail if mean errors are NaN.
  • Loading branch information
RyanWollaeger committed Jan 29, 2025
1 parent 33d68b9 commit 5bffda0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/jaybenne/sourcing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ TaskStatus SourcePhotons(T *md, const Real t_start, const Real dt) {
ppack_i(b, ph::ijk(1), n) = j;
ppack_i(b, ph::ijk(2), n) = k;

// Set energy weight
ppack_r(b, ph::weight(), n) = vmesh(b, fj::source_ew_per_cell(), k, j, i);

// Sample position uniformly in space over cell
// TODO(BRR) only valid for Cartesian
ppack_r(b, swarm_position::x(), n) = xi + dx_i * (rng_gen.drand() - 0.5);
Expand Down Expand Up @@ -257,8 +260,6 @@ TaskStatus SourcePhotons(T *md, const Real t_start, const Real dt) {
const Real nu = numind * std::exp((n + 0.5) * dlnu);
ppack_r(b, ph::energy(), n) = hd * nu;
}
ppack_r(b, ph::weight(), n) =
vmesh(b, fj::source_ew_per_cell(), k, j, i) / ppack_r(b, ph::energy(), n);

if constexpr (ST == SourceType::emission) {
dejbn -= ppack_r(b, ph::weight(), n);
Expand Down
4 changes: 2 additions & 2 deletions tst/regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,10 @@ def analytic_comparison(
print(f"Max fractional error: {max_frac_error:.2e}")

if args.comparison == "mean":
if mean_frac_error > tolerance:
if mean_frac_error > tolerance or np.isnan(mean_frac_error):
success = False
elif args.comparison == "weighted_mean":
if mean_frac_error_weighted > tolerance:
if mean_frac_error_weighted > tolerance or np.isnan(mean_frac_error):
success = False

if args.visualize:
Expand Down

0 comments on commit 5bffda0

Please sign in to comment.