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

openmc-dev / openmc / 15371300071

01 Jun 2025 05:04AM UTC coverage: 85.143% (+0.3%) from 84.827%
15371300071

Pull #3176

github

web-flow
Merge 4f739184a into cb95c784b
Pull Request #3176: MeshFilter rotation - solution to issue #3166

86 of 99 new or added lines in 4 files covered. (86.87%)

3707 existing lines in 117 files now uncovered.

52212 of 61323 relevant lines covered (85.14%)

42831974.38 hits per line

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

95.45
/src/ncrystal_interface.cpp
1
#include "openmc/ncrystal_interface.h"
2

3
#include "openmc/error.h"
4
#include "openmc/material.h"
5
#include "openmc/random_lcg.h"
6

7
namespace openmc {
8

9
//==============================================================================
10
// NCrystalMat implementation
11
//==============================================================================
12

13
NCrystalMat::NCrystalMat(const std::string& cfg) : cfg_(cfg), proc_(cfg.c_str())
22✔
14
{}
22✔
15

16
double NCrystalMat::xs(const Particle& p) const
15,216,585✔
17
{
18
  // Calculate scattering XS per atom with NCrystal, only once per material
19
  double neutron_state[4] = {p.E(), p.u().x, p.u().y, p.u().z};
15,216,585✔
20
  return proc_.cross_section(neutron_state);
30,433,170✔
21
}
22

23
void NCrystalMat::scatter(Particle& p) const
216,585✔
24
{
25
  // Scatter with NCrystal, using the OpenMC RNG stream:
26
  uint64_t* seed = p.current_seed();
216,585✔
27
  std::function<double()> rng = [&seed]() { return prn(seed); };
1,232,520✔
28
  double neutron_state[4] = {p.E(), p.u().x, p.u().y, p.u().z};
216,585✔
29
  proc_.scatter(rng, neutron_state);
216,585✔
30
  // Modify attributes of particle
31
  p.E() = neutron_state[0];
216,585✔
32
  Direction u_old {p.u()};
216,585✔
33
  p.u() = Direction(neutron_state[1], neutron_state[2], neutron_state[3]);
216,585✔
34
  p.mu() = u_old.dot(p.u());
216,585✔
35
  p.event_mt() = ELASTIC;
216,585✔
36
}
216,585✔
37

38
//==============================================================================
39
// Functions
40
//==============================================================================
41

42
void ncrystal_update_micro(double xs, NuclideMicroXS& micro)
15,025,845✔
43
{
44
  if (micro.thermal > 0 || micro.thermal_elastic > 0) {
15,025,845✔
UNCOV
45
    fatal_error("S(a,b) treatment and NCrystal are not compatible.");
×
46
  }
47
  // remove free atom cross section
48
  // and replace it by scattering cross section per atom from NCrystal
49
  micro.total = micro.total - micro.elastic + xs;
15,025,845✔
50
  micro.elastic = xs;
15,025,845✔
51
}
15,025,845✔
52

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