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

openmc-dev / openmc / 23084721708

14 Mar 2026 08:56AM UTC coverage: 81.599% (-0.5%) from 82.058%
23084721708

Pull #2693

github

web-flow
Merge 0ed23ee59 into bc9c31e0f
Pull Request #2693: Add reactivity control to coupled transport-depletion analyses

17575 of 25275 branches covered (69.54%)

Branch coverage included in aggregate %.

74 of 85 new or added lines in 4 files covered. (87.06%)

3755 existing lines in 99 files now uncovered.

58074 of 67433 relevant lines covered (86.12%)

47252067.37 hits per line

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

95.77
/src/distribution_angle.cpp
1
#include "openmc/distribution_angle.h"
2

3
#include <cmath> // for abs, copysign
4

5
#include "openmc/tensor.h"
6

7
#include "openmc/endf.h"
8
#include "openmc/hdf5_interface.h"
9
#include "openmc/math_functions.h"
10
#include "openmc/random_lcg.h"
11
#include "openmc/search.h"
12
#include "openmc/vector.h" // for vector
13

14
namespace openmc {
15

16
//==============================================================================
17
// AngleDistribution implementation
18
//==============================================================================
19

20
AngleDistribution::AngleDistribution(hid_t group)
3,168,940✔
21
{
22
  // Get incoming energies
23
  read_dataset(group, "energy", energy_);
3,168,940✔
24
  int n_energy = energy_.size();
3,168,940✔
25

26
  // Get outgoing energy distribution data
27
  vector<int> offsets;
3,168,940✔
28
  vector<int> interp;
3,168,940✔
29
  hid_t dset = open_dataset(group, "mu");
3,168,940✔
30
  read_attribute(dset, "offsets", offsets);
3,168,940✔
31
  read_attribute(dset, "interpolation", interp);
3,168,940✔
32
  tensor::Tensor<double> temp;
3,168,940✔
33
  read_dataset(dset, temp);
3,168,940✔
34
  close_dataset(dset);
3,168,940✔
35

36
  for (int i = 0; i < n_energy; ++i) {
30,487,671✔
37
    // Determine number of outgoing energies
38
    int j = offsets[i];
27,318,731✔
39
    int n;
27,318,731✔
40
    if (i < n_energy - 1) {
27,318,731✔
41
      n = offsets[i + 1] - j;
24,149,791✔
42
    } else {
43
      n = temp.shape(1) - j;
6,337,880!
44
    }
45

46
    // Create and initialize tabular distribution
47
    tensor::View<double> xs = temp.slice(0, tensor::range(j, j + n));
27,318,731✔
48
    tensor::View<double> ps = temp.slice(1, tensor::range(j, j + n));
27,318,731✔
49
    tensor::View<double> cs = temp.slice(2, tensor::range(j, j + n));
27,318,731✔
50
    vector<double> x {xs.begin(), xs.end()};
27,318,731✔
51
    vector<double> p {ps.begin(), ps.end()};
27,318,731✔
52
    vector<double> c {cs.begin(), cs.end()};
27,318,731✔
53

54
    // To get answers that match ACE data, for now we still use the tabulated
55
    // CDF values that were passed through to the HDF5 library. At a later
56
    // time, we can remove the CDF values from the HDF5 library and
57
    // reconstruct them using the PDF
58
    Tabular* mudist =
27,318,731✔
59
      new Tabular {x.data(), p.data(), n, int2interp(interp[i]), c.data()};
27,318,731✔
60

61
    distribution_.emplace_back(mudist);
27,318,731✔
62
  }
109,274,924✔
63
}
3,168,940✔
64

65
double AngleDistribution::sample(double E, uint64_t* seed) const
1,034,080,658✔
66
{
67
  // Find energy bin and calculate interpolation factor
68
  int i;
1,034,080,658✔
69
  double r;
1,034,080,658✔
70
  get_energy_index(energy_, E, i, r);
1,034,080,658✔
71

72
  // Sample between the ith and (i+1)th bin
73
  if (r > prn(seed))
1,034,080,658✔
74
    ++i;
427,522,442✔
75

76
  // Sample i-th distribution
77
  double mu = distribution_[i]->sample(seed).first;
1,034,080,658✔
78

79
  // Make sure mu is in range [-1,1] and return
80
  if (std::abs(mu) > 1.0)
1,034,080,658!
UNCOV
81
    mu = std::copysign(1.0, mu);
×
82
  return mu;
1,034,080,658✔
83
}
84

85
} // 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