2018-06-04 19:00:07 -04:00
|
|
|
//! \file mgxs.h
|
|
|
|
|
//! A collection of classes for Multi-Group Cross Section data
|
|
|
|
|
|
2018-08-20 14:40:32 -05:00
|
|
|
#ifndef OPENMC_MGXS_H
|
|
|
|
|
#define OPENMC_MGXS_H
|
2018-06-04 19:00:07 -04:00
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2026-02-17 09:50:38 -06:00
|
|
|
#include "openmc/tensor.h"
|
2018-08-31 18:18:01 -04:00
|
|
|
|
2018-08-20 14:40:32 -05:00
|
|
|
#include "openmc/constants.h"
|
|
|
|
|
#include "openmc/hdf5_interface.h"
|
2019-11-12 05:07:43 -06:00
|
|
|
#include "openmc/particle.h"
|
2021-04-22 16:46:23 -04:00
|
|
|
#include "openmc/vector.h"
|
2018-08-20 14:40:32 -05:00
|
|
|
#include "openmc/xsdata.h"
|
2018-06-04 19:00:07 -04:00
|
|
|
|
|
|
|
|
namespace openmc {
|
|
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
|
// MGXS contains the mgxs data for a nuclide/material
|
|
|
|
|
//==============================================================================
|
|
|
|
|
|
|
|
|
|
class Mgxs {
|
|
|
|
|
private:
|
2026-02-17 09:50:38 -06:00
|
|
|
tensor::Tensor<double> kTs; // temperature in eV (k * T)
|
2020-01-16 15:41:45 -05:00
|
|
|
AngleDistributionType
|
|
|
|
|
scatter_format; // flag for if this is legendre, histogram, or tabular
|
2018-06-04 19:00:07 -04:00
|
|
|
int num_groups; // number of energy groups
|
2020-02-26 16:23:53 -06:00
|
|
|
int num_delayed_groups; // number of delayed neutron groups
|
2021-04-22 16:46:23 -04:00
|
|
|
vector<XsData> xs; // Cross section data
|
2018-06-16 13:37:50 -04:00
|
|
|
// MGXS Incoming Flux Angular grid information
|
2018-06-04 19:00:07 -04:00
|
|
|
int n_pol;
|
|
|
|
|
int n_azi;
|
2021-04-22 16:46:23 -04:00
|
|
|
vector<double> polar;
|
|
|
|
|
vector<double> azimuthal;
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Initializes the Mgxs object metadata
|
|
|
|
|
//!
|
|
|
|
|
//! @param in_name Name of the object.
|
|
|
|
|
//! @param in_awr atomic-weight ratio.
|
|
|
|
|
//! @param in_kTs temperatures (in units of eV) that data is available.
|
|
|
|
|
//! @param in_fissionable Is this item fissionable or not.
|
|
|
|
|
//! @param in_scatter_format Denotes whether Legendre, Tabular, or
|
|
|
|
|
//! Histogram scattering is used.
|
|
|
|
|
//! @param in_is_isotropic Is this an isotropic or angular with respect to
|
|
|
|
|
//! the incoming particle.
|
|
|
|
|
//! @param in_polar Polar angle grid.
|
|
|
|
|
//! @param in_azimuthal Azimuthal angle grid.
|
2021-04-22 16:46:23 -04:00
|
|
|
void init(const std::string& in_name, double in_awr,
|
|
|
|
|
const vector<double>& in_kTs, bool in_fissionable,
|
|
|
|
|
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
2021-04-29 16:23:54 -04:00
|
|
|
const vector<double>& in_polar, const vector<double>& in_azimuthal);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-21 20:45:10 -04:00
|
|
|
//! \brief Initializes the Mgxs object metadata from the HDF5 file
|
|
|
|
|
//!
|
|
|
|
|
//! @param xs_id HDF5 group id for the cross section data.
|
|
|
|
|
//! @param temperature Temperatures to read.
|
|
|
|
|
//! @param temps_to_read Resultant list of temperatures in the library
|
|
|
|
|
//! to read which correspond to the requested temperatures.
|
|
|
|
|
//! @param order_dim Resultant dimensionality of the scattering order.
|
2021-04-22 16:46:23 -04:00
|
|
|
void metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
|
|
|
|
|
vector<int>& temps_to_read, int& order_dim);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Performs the actual act of combining the microscopic data for a
|
|
|
|
|
//! single temperature.
|
|
|
|
|
//!
|
|
|
|
|
//! @param micros Microscopic objects to combine.
|
|
|
|
|
//! @param scalars Scalars to multiply the microscopic data by.
|
|
|
|
|
//! @param micro_ts The temperature index of the microscopic objects that
|
|
|
|
|
//! corresponds to the temperature of interest.
|
|
|
|
|
//! @param this_t The temperature index of the macroscopic object.
|
2021-04-29 16:23:54 -04:00
|
|
|
void combine(const vector<Mgxs*>& micros, const vector<double>& scalars,
|
|
|
|
|
const vector<int>& micro_ts, int this_t);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Checks to see if this and that are able to be combined
|
|
|
|
|
//!
|
|
|
|
|
//! This comparison is used when building macroscopic cross sections
|
|
|
|
|
//! from microscopic cross sections.
|
|
|
|
|
//! @param that The other Mgxs to compare to this one.
|
|
|
|
|
//! @return True if they can be combined, False otherwise.
|
2018-06-13 20:22:51 -04:00
|
|
|
bool equiv(const Mgxs& that);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-04 19:00:07 -04:00
|
|
|
public:
|
2023-07-21 02:53:32 -05:00
|
|
|
std::string name; // name of dataset, e.g., UO2
|
|
|
|
|
double awr; // atomic weight ratio
|
|
|
|
|
bool fissionable; // Is this fissionable
|
2024-04-18 17:10:16 -05:00
|
|
|
bool is_isotropic {
|
|
|
|
|
true}; // used to skip search for angle indices if isotropic
|
2024-11-20 14:15:41 -06:00
|
|
|
bool exists_in_model {true}; // Is this present in model
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-21 20:45:10 -04:00
|
|
|
Mgxs() = default;
|
2024-11-20 14:15:41 -06:00
|
|
|
Mgxs(bool exists) : exists_in_model(exists) {}
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-21 20:45:10 -04:00
|
|
|
//! \brief Constructor that loads the Mgxs object from the HDF5 file
|
2018-06-17 10:10:53 -04:00
|
|
|
//!
|
|
|
|
|
//! @param xs_id HDF5 group id for the cross section data.
|
|
|
|
|
//! @param temperature Temperatures to read.
|
2019-11-02 22:08:06 -04:00
|
|
|
//! @param num_group number of energy groups
|
|
|
|
|
//! @param num_delay number of delayed groups
|
2021-04-22 16:46:23 -04:00
|
|
|
Mgxs(hid_t xs_id, const vector<double>& temperature, int num_group,
|
|
|
|
|
int num_delay);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-21 20:45:10 -04:00
|
|
|
//! \brief Constructor that initializes and populates all data to build a
|
2020-10-15 13:46:05 -05:00
|
|
|
//! macroscopic cross section from microscopic cross sections.
|
2018-06-21 20:45:10 -04:00
|
|
|
//!
|
|
|
|
|
//! @param in_name Name of the object.
|
|
|
|
|
//! @param mat_kTs temperatures (in units of eV) that data is needed.
|
|
|
|
|
//! @param micros Microscopic objects to combine.
|
|
|
|
|
//! @param atom_densities Atom densities of those microscopic quantities.
|
2019-11-02 22:08:06 -04:00
|
|
|
//! @param num_group number of energy groups
|
|
|
|
|
//! @param num_delay number of delayed groups
|
2021-04-22 16:46:23 -04:00
|
|
|
Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
2021-04-29 16:23:54 -04:00
|
|
|
const vector<Mgxs*>& micros, const vector<double>& atom_densities,
|
2021-04-22 16:46:23 -04:00
|
|
|
int num_group, int num_delay);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2026-02-09 16:54:59 -06:00
|
|
|
//! \brief Get the number of temperature data points.
|
|
|
|
|
//!
|
|
|
|
|
//! @return The number of temperature data points for this MGXS
|
|
|
|
|
inline int n_temperature_points() { return kTs.size(); }
|
|
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Provides a cross section value given certain parameters
|
|
|
|
|
//!
|
|
|
|
|
//! @param xstype Type of cross section requested, according to the
|
|
|
|
|
//! enumerated constants.
|
|
|
|
|
//! @param gin Incoming energy group.
|
|
|
|
|
//! @param gout Outgoing energy group; use nullptr if irrelevant, or if a
|
|
|
|
|
//! sum is requested.
|
|
|
|
|
//! @param mu Cosine of the change-in-angle, for scattering quantities;
|
|
|
|
|
//! use nullptr if irrelevant.
|
|
|
|
|
//! @param dg delayed group index; use nullptr if irrelevant.
|
2023-07-21 02:53:32 -05:00
|
|
|
//! @param t Temperature index.
|
|
|
|
|
//! @param a Angle index.
|
2018-06-17 10:10:53 -04:00
|
|
|
//! @return Requested cross section value.
|
2023-07-21 02:53:32 -05:00
|
|
|
double get_xs(MgxsType xstype, int gin, const int* gout, const double* mu,
|
|
|
|
|
const int* dg, int t, int a);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2023-07-21 02:53:32 -05:00
|
|
|
inline double get_xs(MgxsType xstype, int gin, int t, int a)
|
2019-11-09 09:24:30 -06:00
|
|
|
{
|
2023-07-21 02:53:32 -05:00
|
|
|
return get_xs(xstype, gin, nullptr, nullptr, nullptr, t, a);
|
2019-11-09 09:24:30 -06:00
|
|
|
}
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Samples the fission neutron energy and if prompt or delayed.
|
|
|
|
|
//!
|
|
|
|
|
//! @param gin Incoming energy group.
|
|
|
|
|
//! @param dg Sampled delayed group index.
|
|
|
|
|
//! @param gout Sampled outgoing energy group.
|
2019-12-05 19:50:31 +00:00
|
|
|
//! @param seed Pseudorandom seed pointer
|
2023-07-21 02:53:32 -05:00
|
|
|
//! @param t Temperature index.
|
|
|
|
|
//! @param a Angle index.
|
|
|
|
|
void sample_fission_energy(
|
|
|
|
|
int gin, int& dg, int& gout, uint64_t* seed, int t, int a);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Samples the outgoing energy and angle from a scatter event.
|
|
|
|
|
//!
|
|
|
|
|
//! @param gin Incoming energy group.
|
|
|
|
|
//! @param gout Sampled outgoing energy group.
|
|
|
|
|
//! @param mu Sampled cosine of the change-in-angle.
|
|
|
|
|
//! @param wgt Weight of the particle to be adjusted.
|
2019-12-05 19:50:31 +00:00
|
|
|
//! @param seed Pseudorandom seed pointer.
|
2023-07-21 02:53:32 -05:00
|
|
|
//! @param t Temperature index.
|
|
|
|
|
//! @param a Angle index.
|
2019-12-05 19:50:31 +00:00
|
|
|
void sample_scatter(
|
2023-07-21 02:53:32 -05:00
|
|
|
int gin, int& gout, double& mu, double& wgt, uint64_t* seed, int t, int a);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2018-06-17 10:10:53 -04:00
|
|
|
//! \brief Calculates cross section quantities needed for tracking.
|
|
|
|
|
//!
|
2019-11-12 05:07:43 -06:00
|
|
|
//! @param p The particle whose attributes set which MGXS to get.
|
|
|
|
|
void calculate_xs(Particle& p);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2023-07-21 02:53:32 -05:00
|
|
|
//! \brief Sets the temperature index in the particle's cache.
|
|
|
|
|
//!
|
|
|
|
|
//! @param p Particle.
|
|
|
|
|
void set_temperature_index(Particle& p);
|
|
|
|
|
|
|
|
|
|
//! \brief Gets the temperature index given a temperature.
|
2018-06-17 10:10:53 -04:00
|
|
|
//!
|
|
|
|
|
//! @param sqrtkT Temperature of the material.
|
2023-07-21 02:53:32 -05:00
|
|
|
//! @return The temperature index corresponding to sqrtkT.
|
|
|
|
|
int get_temperature_index(double sqrtkT) const;
|
|
|
|
|
|
|
|
|
|
//! \brief Sets the angle index in the particle's cache.
|
|
|
|
|
//!
|
|
|
|
|
//! @param p Particle.
|
|
|
|
|
void set_angle_index(Particle& p);
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2023-07-21 02:53:32 -05:00
|
|
|
//! \brief Gets the angle index given a direction.
|
2018-06-17 10:10:53 -04:00
|
|
|
//!
|
2019-03-01 14:46:21 -06:00
|
|
|
//! @param u Incoming particle direction.
|
2023-07-21 02:53:32 -05:00
|
|
|
//! @return The angle index corresponding to u.
|
|
|
|
|
int get_angle_index(const Direction& u) const;
|
2021-08-11 11:41:49 -05:00
|
|
|
|
2020-03-03 09:36:42 -05:00
|
|
|
//! \brief Provide const access to list of XsData held by this
|
2021-04-22 16:46:23 -04:00
|
|
|
const vector<XsData>& get_xsdata() const { return xs; }
|
2018-06-04 19:00:07 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace openmc
|
2018-08-20 14:40:32 -05:00
|
|
|
#endif // OPENMC_MGXS_H
|