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

openmc-dev / openmc / 21489819490

29 Jan 2026 06:21PM UTC coverage: 80.077% (-1.9%) from 81.953%
21489819490

Pull #3757

github

web-flow
Merge d08626053 into f7a734189
Pull Request #3757: Testing point detectors

16004 of 22621 branches covered (70.75%)

Branch coverage included in aggregate %.

94 of 518 new or added lines in 26 files covered. (18.15%)

1021 existing lines in 52 files now uncovered.

53779 of 64524 relevant lines covered (83.35%)

8016833.26 hits per line

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

78.82
/src/secondary_uncorrelated.cpp
1
#include "openmc/secondary_uncorrelated.h"
2

3
#include <string> // for string
4

5
#include <fmt/core.h>
6

7
#include "openmc/error.h"
8
#include "openmc/hdf5_interface.h"
9
#include "openmc/random_dist.h"
10

11
namespace openmc {
12

13
//==============================================================================
14
// UncorrelatedAngleEnergy implementation
15
//==============================================================================
16

17
UncorrelatedAngleEnergy::UncorrelatedAngleEnergy(hid_t group)
252,441✔
18
{
19
  // Check if angle group is present & read
20
  if (object_exists(group, "angle")) {
252,441✔
21
    hid_t angle_group = open_group(group, "angle");
239,163✔
22
    angle_ = AngleDistribution {angle_group};
239,163✔
23
    close_group(angle_group);
239,163✔
24
  }
25

26
  // Check if energy group is present & read
27
  if (object_exists(group, "energy")) {
252,441✔
28
    hid_t energy_group = open_group(group, "energy");
250,219✔
29

30
    std::string type;
250,219✔
31
    read_attribute(energy_group, "type", type);
250,219✔
32
    using UPtrEDist = unique_ptr<EnergyDistribution>;
33
    if (type == "discrete_photon") {
250,219✔
34
      energy_ = UPtrEDist {new DiscretePhoton {energy_group}};
184,142✔
35
    } else if (type == "level") {
66,077✔
36
      energy_ = UPtrEDist {new LevelInelastic {energy_group}};
41,436✔
37
    } else if (type == "continuous") {
24,641✔
38
      energy_ = UPtrEDist {new ContinuousTabular {energy_group}};
24,003✔
39
    } else if (type == "maxwell") {
638✔
40
      energy_ = UPtrEDist {new MaxwellEnergy {energy_group}};
227✔
41
    } else if (type == "evaporation") {
411✔
42
      energy_ = UPtrEDist {new Evaporation {energy_group}};
394✔
43
    } else if (type == "watt") {
17!
44
      energy_ = UPtrEDist {new WattEnergy {energy_group}};
17✔
45
    } else {
46
      warning(
×
47
        fmt::format("Energy distribution type '{}' not implemented.", type));
×
48
    }
49
    close_group(energy_group);
250,219✔
50
  }
250,219✔
51
}
252,441✔
52

53
void UncorrelatedAngleEnergy::sample(
3,959,682✔
54
  double E_in, double& E_out, double& mu, uint64_t* seed) const
55
{
56
  // Sample cosine of scattering angle
57
  if (!angle_.empty()) {
3,959,682✔
58
    mu = angle_.sample(E_in, seed);
1,427,188✔
59
  } else {
60
    // no angle distribution given => assume isotropic for all energies
61
    mu = uniform_distribution(-1., 1., seed);
2,532,494✔
62
  }
63

64
  // Sample outgoing energy
65
  E_out = energy_->sample(E_in, seed);
3,959,682✔
66
}
3,959,682✔
67

NEW
68
double UncorrelatedAngleEnergy::sample_energy_and_pdf(
×
69
  double E_in, double mu, double& E_out, uint64_t* seed) const
70
{
71
  // Sample outgoing energy
NEW
72
  if (energy_ != nullptr) {
×
NEW
73
    E_out = energy_->sample(E_in, seed);
×
74
  } else {
NEW
75
    E_out = E_in;
×
76
  }
77

NEW
78
  if (!angle_.empty()) {
×
NEW
79
    return angle_.evaluate(E_in, mu);
×
80
  } else {
81
    // no angle distribution given => assume isotropic for all energies
NEW
82
    return 0.5;
×
83
  }
84
}
85

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

© 2026 Coveralls, Inc