• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmc-dev / openmc / 38739185556

15 Oct 2026 01:01PM UTC coverage: 81.476%. First build
38739185556

Pull #3757

github

web-flow
Merge cb45408c9 into 46c4c6075
Pull Request #3757: Implementation of point detectors

20422 of 29653 branches covered (68.87%)

Branch coverage included in aggregate %.

465 of 556 new or added lines in 24 files covered. (83.63%)

63115 of 72876 relevant lines covered (86.61%)

42599939.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.62
/src/angle_energy.cpp
1
#include "openmc/angle_energy.h"
2

3
#include <algorithm> // for clamp
4
#include <cmath>     // for sqrt
5

6
#include "openmc/constants.h"
7
#include "openmc/random_lcg.h"
8

9
namespace openmc {
10

11
double get_jac_and_transform(
13,032 ✔
12
  double E_in, double& mu, double& E_out, uint64_t* seed, double awr)
13
{
14
  // eq 56 in LA-UR-23-30378 rev 1 (valid for stationary target)
15
  double E_com = E_in / ((awr + 1.0) * (awr + 1.0));
13,032 ✔
16
  return get_jac_and_transform_impl(E_com, mu, E_out, seed, awr);
13,032 ✔
17
}
18

19
double get_jac_and_transform_impl(
4,956,072 ✔
20
  double E_com, double& mu, double& E_out, uint64_t* seed, double awr)
21
{
22
  // This function is using target-in-motion kinematics
23
  double E_cm = E_out;
4,956,072 ✔
24
  double mu_lab = mu;
4,956,072 ✔
25
  // eq 22 in LA-UR-23-30378 rev 1
26
  double D = mu_lab * mu_lab - 1.0 + E_cm / E_com;
4,956,072 ✔
27
  if (D <= 0.0)
4,956,072 ✔
28
    return 0.0;
29
  D = std::sqrt(D);
4,675,912 ✔
30

31
  if ((mu_lab <= 0.0) && (E_cm <= E_com))
4,675,912 ✔
32
    return 0.0;
33
  // eq 23 in LA-UR-23-30378 rev 1
34
  double E_out1 = E_com * (mu_lab + D) * (mu_lab + D);
2,634,232 ✔
35
  double mult;
2,634,232 ✔
36
  if (E_cm > E_com) {
2,634,232 ✔
37
    mult = 1.0;
1,871,400 ✔
38
    E_out = E_out1;
1,871,400 ✔
39
  } else {
40
    mult = 2.0;
762,832 ✔
41
    if (prn(seed) < 0.5) {
762,832 ✔
42
      E_out = E_out1;
381,440 ✔
43
    } else {
44
      E_out = E_com * (mu_lab - D) * (mu_lab - D);
381,392 ✔
45
    }
46
  }
47
  // eq 12 in LA-UR-23-30378 rev 1
48
  mu = mu_lab * std::sqrt(E_out / E_cm) - std::sqrt(E_com / E_cm);
2,634,232 ✔
49

50
  if ((std::abs(mu) > 1.0) && (std::abs(mu) < 1.0 + FP_PRECISION))
2,634,232 !
NEW
51
    mu = std::clamp(mu, -1.0, 1.0);
×
52
  // eq 55 in LA-UR-23-30378 rev 1
53
  return mult * E_out / (D * std::sqrt(E_cm * E_com));
2,634,232 ✔
54
}
55

56
} // namespace openmc
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc