|
| 1 | +#ifndef OPENMC_NCRYSTAL_INTERFACE_H |
| 2 | +#define OPENMC_NCRYSTAL_INTERFACE_H |
| 3 | + |
| 4 | +#ifdef NCRYSTAL |
| 5 | +#include "NCrystal/NCRNG.hh" |
| 6 | +#include "NCrystal/NCrystal.hh" |
| 7 | +#endif |
| 8 | + |
| 9 | +#include "openmc/particle.h" |
| 10 | + |
| 11 | +#include <cstdint> // for uint64_t |
| 12 | +#include <limits> // for numeric_limits |
| 13 | +#include <string> |
| 14 | + |
| 15 | +namespace openmc { |
| 16 | + |
| 17 | +//============================================================================== |
| 18 | +// Constants |
| 19 | +//============================================================================== |
| 20 | + |
| 21 | +extern "C" const bool NCRYSTAL_ENABLED; |
| 22 | + |
| 23 | +//! Energy in [eV] to switch between NCrystal and ENDF |
| 24 | +constexpr double NCRYSTAL_MAX_ENERGY {5.0}; |
| 25 | + |
| 26 | +//============================================================================== |
| 27 | +// Wrapper class an NCrystal material |
| 28 | +//============================================================================== |
| 29 | + |
| 30 | +class NCrystalMat { |
| 31 | +public: |
| 32 | + //---------------------------------------------------------------------------- |
| 33 | + // Constructors |
| 34 | + NCrystalMat() = default; |
| 35 | + explicit NCrystalMat(const std::string& cfg); |
| 36 | + |
| 37 | + //---------------------------------------------------------------------------- |
| 38 | + // Methods |
| 39 | + |
| 40 | +#ifdef NCRYSTAL |
| 41 | + //! Return configuration string |
| 42 | + std::string cfg() const; |
| 43 | + |
| 44 | + //! Get cross section from NCrystal material |
| 45 | + // |
| 46 | + //! \param[in] p Particle object |
| 47 | + //! \return Cross section in [b] |
| 48 | + double xs(const Particle& p) const; |
| 49 | + |
| 50 | + // Process scattering event |
| 51 | + // |
| 52 | + //! \param[in] p Particle object |
| 53 | + void scatter(Particle& p) const; |
| 54 | + |
| 55 | + //! Whether the object holds a valid NCrystal material |
| 56 | + operator bool() const; |
| 57 | +#else |
| 58 | + |
| 59 | + //---------------------------------------------------------------------------- |
| 60 | + // Trivial methods when compiling without NCRYSTAL |
| 61 | + std::string cfg() const |
| 62 | + { |
| 63 | + return ""; |
| 64 | + } |
| 65 | + double xs(const Particle& p) const |
| 66 | + { |
| 67 | + return -1.0; |
| 68 | + } |
| 69 | + void scatter(Particle& p) const {} |
| 70 | + operator bool() const |
| 71 | + { |
| 72 | + return false; |
| 73 | + } |
| 74 | +#endif |
| 75 | + |
| 76 | +private: |
| 77 | + //---------------------------------------------------------------------------- |
| 78 | + // Data members (only present when compiling with NCrystal support) |
| 79 | +#ifdef NCRYSTAL |
| 80 | + std::string cfg_; //!< NCrystal configuration string |
| 81 | + std::shared_ptr<const NCrystal::ProcImpl::Process> |
| 82 | + ptr_; //!< Pointer to NCrystal material object |
| 83 | +#endif |
| 84 | +}; |
| 85 | + |
| 86 | +//============================================================================== |
| 87 | +// Functions |
| 88 | +//============================================================================== |
| 89 | + |
| 90 | +void ncrystal_update_micro(double xs, NuclideMicroXS& micro); |
| 91 | + |
| 92 | +} // namespace openmc |
| 93 | + |
| 94 | +#endif // OPENMC_NCRYSTAL_INTERFACE_H |
0 commit comments