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

openmc-dev / openmc / 14386648657

10 Apr 2025 05:30PM UTC coverage: 85.118% (+0.07%) from 85.044%
14386648657

Pull #3370

github

web-flow
Merge 993e23d39 into 07f533461
Pull Request #3370: Fix negative distances from bins_crossed for CylindricalMesh

6 of 6 new or added lines in 1 file covered. (100.0%)

199 existing lines in 18 files now uncovered.

51665 of 60698 relevant lines covered (85.12%)

37166875.55 hits per line

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

25.0
/include/openmc/endf.h
1
//! \file endf.h
2
//! Classes and functions related to the ENDF-6 format
3

4
#ifndef OPENMC_ENDF_H
5
#define OPENMC_ENDF_H
6

7
#include "hdf5.h"
8

9
#include "openmc/constants.h"
10
#include "openmc/memory.h"
11
#include "openmc/vector.h"
12

13
namespace openmc {
14

15
//! Convert integer representing interpolation law to enum
16
//! \param[in] i Intereger (e.g. 1=histogram, 2=lin-lin)
17
//! \return Corresponding enum value
18
Interpolation int2interp(int i);
19

20
//! Determine whether MT number corresponds to a fission reaction
21
//! \param[in] MT ENDF MT value
22
//! \return Whether corresponding reaction is a fission reaction
23
bool is_fission(int MT);
24

25
//! Determine if a given MT number is that of a disappearance reaction, i.e., a
26
//! reaction with no neutron in the exit channel
27
//! \param[in] MT ENDF MT value
28
//! \return Whether corresponding reaction is a disappearance reaction
29
bool is_disappearance(int MT);
30

31
//! Determine if a given MT number is that of an inelastic scattering reaction
32
//! \param[in] MT ENDF MT value
33
//! \return Whether corresponding reaction is an inelastic scattering reaction
34
bool is_inelastic_scatter(int MT);
35

36
//==============================================================================
37
//! Abstract one-dimensional function
38
//==============================================================================
39

40
class Function1D {
41
public:
42
  virtual double operator()(double x) const = 0;
UNCOV
43
  virtual ~Function1D() = default;
×
44
};
×
UNCOV
45

×
46
//==============================================================================
47
//! One-dimensional function expressed as a polynomial
48
//==============================================================================
49

50
class Polynomial : public Function1D {
51
public:
52
  //! Construct polynomial from HDF5 data
53
  //! \param[in] dset Dataset containing coefficients
54
  explicit Polynomial(hid_t dset);
55

56
  //! Construct polynomial from coefficients
57
  //! \param[in] coef Polynomial coefficients
58
  explicit Polynomial(vector<double> coef) : coef_(coef) {}
59

60
  //! Evaluate the polynomials
132✔
61
  //! \param[in] x independent variable
62
  //! \return Polynomial evaluated at x
63
  double operator()(double x) const override;
64

65
private:
66
  vector<double> coef_; //!< Polynomial coefficients
67
};
68

69
//==============================================================================
70
//! One-dimensional interpolable function
71
//==============================================================================
72

73
class Tabulated1D : public Function1D {
74
public:
75
  Tabulated1D() = default;
76

77
  //! Construct function from HDF5 data
78
  //! \param[in] dset Dataset containing tabulated data
79
  explicit Tabulated1D(hid_t dset);
80

81
  //! Evaluate the tabulated function
82
  //! \param[in] x independent variable
83
  //! \return Function evaluated at x
84
  double operator()(double x) const override;
85

86
  // Accessors
87
  const vector<double>& x() const { return x_; }
88
  const vector<double>& y() const { return y_; }
89

90
private:
91
  std::size_t n_regions_ {0}; //!< number of interpolation regions
92
  vector<int> nbt_;           //!< values separating interpolation regions
93
  vector<Interpolation> int_; //!< interpolation schemes
94
  std::size_t n_pairs_;       //!< number of (x,y) pairs
95
  vector<double> x_;          //!< values of abscissa
96
  vector<double> y_;          //!< values of ordinate
97
};
98

99
//==============================================================================
100
//! Coherent elastic scattering data from a crystalline material
101
//==============================================================================
102

103
class CoherentElasticXS : public Function1D {
104
public:
105
  explicit CoherentElasticXS(hid_t dset);
106

107
  double operator()(double E) const override;
108

109
  const vector<double>& bragg_edges() const { return bragg_edges_; }
110
  const vector<double>& factors() const { return factors_; }
111

112
private:
113
  vector<double> bragg_edges_; //!< Bragg edges in [eV]
114
  vector<double> factors_;     //!< Partial sums of structure factors [eV-b]
115
};
116

117
//==============================================================================
118
//! Incoherent elastic scattering cross section
119
//==============================================================================
120

121
class IncoherentElasticXS : public Function1D {
122
public:
123
  explicit IncoherentElasticXS(hid_t dset);
124

125
  double operator()(double E) const override;
126

127
private:
128
  double bound_xs_; //!< Characteristic bound xs in [b]
129
  double
130
    debye_waller_; //!< Debye-Waller integral divided by atomic mass in [eV^-1]
131
};
132

133
//==============================================================================
134
//! Sum of multiple 1D functions
135
//==============================================================================
136

137
class Sum1D : public Function1D {
138
public:
139
  // Constructors
140
  explicit Sum1D(hid_t group);
141

142
  //! Evaluate each function and sum results
143
  //! \param[in] x independent variable
144
  //! \return Function evaluated at x
145
  double operator()(double E) const override;
146

147
  const unique_ptr<Function1D>& functions(int i) const { return functions_[i]; }
148

149
private:
150
  vector<unique_ptr<Function1D>> functions_; //!< individual functions
151
};
152

153
//! Read 1D function from HDF5 dataset
154
//! \param[in] group HDF5 group containing dataset
155
//! \param[in] name Name of dataset
156
//! \return Unique pointer to 1D function
157
unique_ptr<Function1D> read_function(hid_t group, const char* name);
158

159
} // namespace openmc
160

161
#endif // OPENMC_ENDF_H
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