forked from openmc-dev/openmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwmp.h
121 lines (98 loc) · 4.15 KB
/
wmp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef OPENMC_WMP_H
#define OPENMC_WMP_H
#include "hdf5.h"
#include "xtensor/xtensor.hpp"
#include <complex>
#include <string>
#include <tuple>
#include "openmc/array.h"
#include "openmc/vector.h"
namespace openmc {
//========================================================================
// Constants
//========================================================================
// Constants that determine which value to access
constexpr int MP_EA {0}; // Pole
constexpr int MP_RS {1}; // Residue scattering
constexpr int MP_RA {2}; // Residue absorption
constexpr int MP_RF {3}; // Residue fission
// Polynomial fit indices
constexpr int FIT_S {0}; // Scattering
constexpr int FIT_A {1}; // Absorption
constexpr int FIT_F {2}; // Fission
// Multipole HDF5 file version
constexpr array<int, 2> WMP_VERSION {1, 1};
//========================================================================
// Windowed multipole data
//========================================================================
class WindowedMultipole {
public:
// Types
struct WindowInfo {
int index_start; // Index of starting pole
int index_end; // Index of ending pole
bool broaden_poly; // Whether to broaden polynomial curvefit
};
// Constructors, destructors
WindowedMultipole(hid_t group);
// Methods
//! \brief Evaluate the windowed multipole equations for cross sections in the
//! resolved resonance regions
//!
//! \param E Incident neutron energy in [eV]
//! \param sqrtkT Square root of temperature times Boltzmann constant
//! \return Tuple of elastic scattering, absorption, and fission cross
//! sections in [b]
std::tuple<double, double, double> evaluate(double E, double sqrtkT) const;
//! \brief Evaluates the windowed multipole equations for the derivative of
//! cross sections in the resolved resonance regions with respect to
//! temperature.
//!
//! \param E Incident neutron energy in [eV]
//! \param sqrtkT Square root of temperature times Boltzmann constant
//! \return Tuple of derivatives of elastic scattering, absorption, and
//! fission cross sections in [b/K]
std::tuple<double, double, double> evaluate_deriv(
double E, double sqrtkT) const;
// Data members
std::string name_; //!< Name of nuclide
double E_min_; //!< Minimum energy in [eV]
double E_max_; //!< Maximum energy in [eV]
double sqrt_awr_; //!< Square root of atomic weight ratio
double inv_spacing_; //!< 1 / spacing in sqrt(E) space
int fit_order_; //!< Order of the fit
bool fissionable_; //!< Is the nuclide fissionable?
vector<WindowInfo> window_info_; // Information about a window
xt::xtensor<double, 3>
curvefit_; // Curve fit coefficients (window, poly order, reaction)
xt::xtensor<std::complex<double>, 2> data_; //!< Poles and residues
// Constant data
static constexpr int MAX_POLY_COEFFICIENTS =
11; //!< Max order of polynomial fit plus one
};
//========================================================================
// Non-member functions
//========================================================================
//! Check to make sure WMP library data version matches
//!
//! \param[in] file HDF5 file object
void check_wmp_version(hid_t file);
//! \brief Checks for the existence of a multipole library in the directory and
//! loads it
//!
//! \param[in] i_nuclide Index in global nuclides array
void read_multipole_data(int i_nuclide);
//==============================================================================
//! Doppler broadens the windowed multipole curvefit.
//!
//! The curvefit is a polynomial of the form a/E + b/sqrt(E) + c + d sqrt(E)...
//!
//! \param E The energy to evaluate the broadening at
//! \param dopp sqrt(atomic weight ratio / kT) with kT given in eV
//! \param n The number of components to the polynomial
//! \param factors The output leading coefficient
//==============================================================================
extern "C" void broaden_wmp_polynomials(
double E, double dopp, int n, double factors[]);
} // namespace openmc
#endif // OPENMC_WMP_H