Cardinal
|
#include <OpenMCProblemBase.h>
Public Types | |
typedef std::pair< int32_t, int32_t > | cellInfo |
Public Member Functions | |
OpenMCProblemBase (const InputParameters ¶ms) | |
virtual | ~OpenMCProblemBase () override |
std::string | subdomainName (const SubdomainID &id) const |
void | catchOpenMCError (const int &err, const std::string descriptor) const |
bool | isReactionRateScore (const std::string &score) const |
bool | isHeatingScore (const std::string &score) const |
unsigned int | addExternalVariable (const std::string &name, const std::vector< SubdomainName > *block=nullptr) |
const Real & | scaling () const |
bool | hasScaling () const |
std::string | enumToTallyScore (const std::string &score) const |
std::string | tallyScoreToEnum (const std::string &score) const |
virtual void | geometryType (bool &has_csg_universe, bool &has_dag_universe) const |
bool | firstSolve () const |
Whether this is the first time OpenMC is running. More... | |
openmc::TriggerMetric | triggerMetric (trigger::TallyTriggerTypeEnum trigger) const |
openmc::TriggerMetric | triggerMetric (std::string trigger) const |
openmc::TallyEstimator | tallyEstimator (tally::TallyEstimatorEnum estimator) const |
std::string | estimatorToString (openmc::TallyEstimator estimator) const |
void | externalSolve () override |
Run a k-eigenvalue OpenMC simulation. More... | |
void | importProperties () const |
Import temperature and density from a properties.h5 file. More... | |
xt::xtensor< double, 1 > | tallySum (openmc::Tally *tally, const unsigned int &score) const |
Compute the sum of a tally within each bin. More... | |
double | tallySumAcrossBins (std::vector< openmc::Tally * > tally, const unsigned int &score) const |
double | tallyMeanAcrossBins (std::vector< openmc::Tally * > tally, const unsigned int &score) const |
bool | cellIsVoid (const cellInfo &cell_info) const |
bool | cellHasZeroInstances (const cellInfo &cell_info) const |
std::string | materialName (const int32_t index) const |
xt::xtensor< double, 1 > | relativeError (const xt::xtensor< double, 1 > &sum, const xt::xtensor< double, 1 > &sum_sq, const int &n_realizations) const |
const Real & | densityConversionFactor () const |
int | nParticles () const |
int | nTotalParticles () const |
int32_t | cellID (const int32_t index) const |
int32_t | materialID (const int32_t index) const |
std::string | printPoint (const Point &p) const |
std::string | printMaterial (const int32_t &index) const |
void | writeSourceBank (const std::string &filename) |
unsigned int | numElemsInSubdomain (const SubdomainID &id) const |
bool | isLocalElem (const Elem *elem) const |
unsigned int | globalElemID (const unsigned int &id) const |
virtual void | setCellTemperature (const int32_t &id, const int32_t &instance, const Real &T, const cellInfo &cell_info) const |
virtual void | setCellDensity (const Real &density, const cellInfo &cell_info) const |
virtual std::string | printCell (const cellInfo &cell_info, const bool brief=false) const |
virtual std::vector< int32_t > | cellFill (const cellInfo &cell_info, int &fill_type) const |
bool | materialFill (const cellInfo &cell_info, int32_t &material_index) const |
long unsigned int | numCells () const |
template<typename T > | |
void | checkDuplicateEntries (const std::vector< T > &var, const std::string &name) const |
void | checkDuplicateVariableName (const std::string &name) const |
bool | stringHasEnding (std::string const &full, std::string const &ending) const |
Static Public Member Functions | |
static InputParameters | validParams () |
Protected Member Functions | |
void | getOpenMCUserObjects () |
Find all userobjects which are changing OpenMC data structures. More... | |
void | sendNuclideDensitiesToOpenMC () |
Set the nuclide densities for any materials being modified via MOOSE. More... | |
void | sendTallyNuclidesToOpenMC () |
Set the tally nuclides for any tallies being modified via MOOSE. More... | |
void | fillElementalAuxVariable (const unsigned int &var_num, const std::vector< unsigned int > &elem_ids, const Real &value) |
std::string | sourceBankFileName () const |
Protected Attributes | |
const bool & | _verbose |
Whether to print diagnostic information about model setup and the transfers. More... | |
const Real * | _power |
Power by which to normalize the OpenMC results, for k-eigenvalue mode. More... | |
const Real * | _source_strength |
Source strength by which to normalize the OpenMC results, for fixed source mode. More... | |
bool | _reuse_source |
const bool | _specified_scaling |
Whether a mesh scaling was specified by the user. More... | |
const Real & | _scaling |
const bool & | _skip_statepoint |
Whether to skip writing statepoints from OpenMC. More... | |
int | _fixed_point_iteration |
unsigned int | _total_n_particles |
Total number of particles simulated. More... | |
long unsigned int | _n_openmc_cells |
Total number of unique OpenMC cell IDs + instances combinations. More... | |
int | _n_cell_digits |
openmc::RunMode | _run_mode |
OpenMC run mode. More... | |
std::vector< OpenMCNuclideDensities * > | _nuclide_densities_uos |
Userobjects for changing OpenMC material compositions. More... | |
std::vector< OpenMCTallyNuclides * > | _tally_nuclides_uos |
Userobjects for changing OpenMC tally nuclides. More... | |
std::vector< unsigned int > | _local_to_global_elem |
Mapping from local element indices to global element indices for this rank. More... | |
Static Protected Attributes | |
static constexpr Real | _density_conversion_factor {0.001} |
Conversion unit to transfer between kg/m3 and g/cm3. More... | |
static constexpr int | MATERIAL_VOID {-1} |
ID used by OpenMC to indicate that a material fill is VOID. More... | |
Base class for all MOOSE wrappings of OpenMC
typedef std::pair<int32_t, int32_t> OpenMCProblemBase::cellInfo |
Type definition for storing the relevant aspects of the OpenMC geometry; the first value is the cell index, while the second is the cell instance.
OpenMCProblemBase::OpenMCProblemBase | ( | const InputParameters & | params | ) |
|
overridevirtual |
unsigned int OpenMCProblemBase::addExternalVariable | ( | const std::string & | name, |
const std::vector< SubdomainName > * | block = nullptr |
||
) |
Add a constant monomial auxiliary variable
[in] | name | name of the variable |
[in] | block | optional subdomain names on which to restrict the variable |
void OpenMCProblemBase::catchOpenMCError | ( | const int & | err, |
const std::string | descriptor | ||
) | const |
Print a full error message when catching errors from OpenMC
[in] | err | OpenMC error code |
[in] | descriptor | descriptive message for error |
|
virtual |
Get the fill of an OpenMC cell
[in] | cell_info | cell ID, instance |
[out] | fill_type | fill type of the cell, one of MATERIAL, UNIVERSE, or LATTICE |
bool OpenMCProblemBase::cellHasZeroInstances | ( | const cellInfo & | cell_info | ) | const |
Whether this cell has zero instances
[in] | cell_info | cell info |
int32_t OpenMCProblemBase::cellID | ( | const int32_t | index | ) | const |
Get the cell ID from the cell index
[in] | index | cell index |
bool OpenMCProblemBase::cellIsVoid | ( | const cellInfo & | cell_info | ) | const |
Whether a cell is filled with VOID (vacuum)
[in] | cell_info | cell ID, instance |
|
inlineinherited |
Check for duplicate entries in a 1-d vector
[in] | var | input vector |
[in] | name | string to use for printing error message |
|
inherited |
Check whether the user has already created a variable using one of the protected names that the wrapping is using.
[in] | name | variable name |
|
inline |
Get the density conversion factor (multiplicative factor)
std::string OpenMCProblemBase::enumToTallyScore | ( | const std::string & | score | ) | const |
Convert from a MOOSE-type enum into a valid OpenMC tally score string
[in] | score | MOOSE-type enum string |
std::string OpenMCProblemBase::estimatorToString | ( | openmc::TallyEstimator | estimator | ) | const |
Convert a tally estimator to a string (for output purposes).
[in] | estimator | OpenMC tally estimator enum |
|
override |
Run a k-eigenvalue OpenMC simulation.
|
protected |
Set an auxiliary elemental variable to a specified value
[in] | var_num | variable number |
[in] | elem_ids | element IDs to set |
[in] | value | value to set |
bool OpenMCProblemBase::firstSolve | ( | ) | const |
Whether this is the first time OpenMC is running.
|
virtual |
Find the geometry type in the OpenMC model
[out] | has_csg_universe | whether there is at least 1 CSG universe |
[out] | has_dag_universe | whether there is at least 1 DagMC universe |
|
protected |
Find all userobjects which are changing OpenMC data structures.
|
inline |
Get the global element ID from the local element ID
[in] | id | local element ID |
|
inline |
Whether the problem has user defined scaling or not.
void OpenMCProblemBase::importProperties | ( | ) | const |
Import temperature and density from a properties.h5 file.
bool OpenMCProblemBase::isHeatingScore | ( | const std::string & | score | ) | const |
Whether the score is a heating-type score
bool OpenMCProblemBase::isLocalElem | ( | const Elem * | elem | ) | const |
Whether the element is owned by this rank
bool OpenMCProblemBase::isReactionRateScore | ( | const std::string & | score | ) | const |
Whether the score is a reaction rate score
bool OpenMCProblemBase::materialFill | ( | const cellInfo & | cell_info, |
int32_t & | material_index | ||
) | const |
Whether the cell has a material fill (if so, then get the material index). Void counts as a material, with a material index of -1.
[in] | cell_info | cell ID, instance |
[out] | material_index | material index in the cell |
int32_t OpenMCProblemBase::materialID | ( | const int32_t | index | ) | const |
Get the material ID from the material index; for VOID cells, this returns -1
[in] | index | material index |
std::string OpenMCProblemBase::materialName | ( | const int32_t | index | ) | const |
Get the material name given its index. If the material does not have a name, return the ID.
[in] | index |
int OpenMCProblemBase::nParticles | ( | ) | const |
Get the number of particles used in the current Monte Carlo calculation
|
inline |
Total number of particles run (not multiplied by batches)
long unsigned int OpenMCProblemBase::numCells | ( | ) | const |
Calculate the number of unique OpenMC cells (each with a unique ID & instance)
unsigned int OpenMCProblemBase::numElemsInSubdomain | ( | const SubdomainID & | id | ) | const |
Get the total (i.e. summed across all ranks, if distributed) number of elements in a given block
[in] | id | subdomainID return number of elements in block |
|
virtual |
Get a descriptive, formatted, string describing a cell
[in] | cell_info | cell index, instance pair |
[in] | brief | whether to print a shorter string |
std::string OpenMCProblemBase::printMaterial | ( | const int32_t & | index | ) | const |
Get a descriptive, formatted, string describing a material
[in] | index | material index |
std::string OpenMCProblemBase::printPoint | ( | const Point & | p | ) | const |
Print point coordinates with a neater formatting than the default MOOSE printing
xt::xtensor<double, 1> OpenMCProblemBase::relativeError | ( | const xt::xtensor< double, 1 > & | sum, |
const xt::xtensor< double, 1 > & | sum_sq, | ||
const int & | n_realizations | ||
) | const |
Compute relative error
[in] | sum | sum of scores |
[in] | sum_sq | sum of scores squared |
[in] | n_realizations | number of realizations |
|
inline |
Get the scaling value applied to the [Mesh] to convert to OpenMC's centimeters units
|
protected |
Set the nuclide densities for any materials being modified via MOOSE.
|
protected |
Set the tally nuclides for any tallies being modified via MOOSE.
|
virtual |
Set the cell density, and print helpful error message if a failure occurs
[in] | density | density |
[in] | cell_info | cell info for which we are setting the density |
|
virtual |
Set the cell temperature, and print helpful error message if a failure occurs; this sets the temperature for the id + instance, which could be one of N cells filling the 'cell_info' parent cell (which is what we actually use for error printing)
[in] | id | cell ID |
[in] | instance | cell instance |
[in] | T | temperature |
[in] | cell_info | cell info for which we are setting interior temperature, for error printing |
|
inlineprotected |
Get name of source bank file to write
[out] | file | name |
|
inherited |
Whether a string ends in a particular sub-string
[in] | full | full string |
[in] | ending | sub-string ending |
std::string OpenMCProblemBase::subdomainName | ( | const SubdomainID & | id | ) | const |
Get the subdomain name for a given ID. If not named, we return the ID
[in] | id | subdomain ID |
openmc::TallyEstimator OpenMCProblemBase::tallyEstimator | ( | tally::TallyEstimatorEnum | estimator | ) | const |
Convert from a MooseEnum for tally estimator to an OpenMC enum
[in] | estimator | MOOSE estimator enum |
double OpenMCProblemBase::tallyMeanAcrossBins | ( | std::vector< openmc::Tally * > | tally, |
const unsigned int & | score | ||
) | const |
Compute the mean of a tally across all of its bins
[in] | tally | OpenMC tallies (multiple if repeated mesh tallies) |
[in] | score | tally score |
std::string OpenMCProblemBase::tallyScoreToEnum | ( | const std::string & | score | ) | const |
Convert into a MOOSE-type enum from a valid OpenMC tally score string
[in] | score | OpenMC tally score string |
xt::xtensor<double, 1> OpenMCProblemBase::tallySum | ( | openmc::Tally * | tally, |
const unsigned int & | score | ||
) | const |
Compute the sum of a tally within each bin.
For example, suppose we have a cell tally with 4 bins, one for each of 4 different cells. This function will return the sum of the tally in each of those bins, so the return xtensor will have a length of 4, with each value representing the sum for that bin.
[in] | tally | OpenMC tally |
[in] | score | tally score |
double OpenMCProblemBase::tallySumAcrossBins | ( | std::vector< openmc::Tally * > | tally, |
const unsigned int & | score | ||
) | const |
Compute the sum of a tally across all of its bins
[in] | tally | OpenMC tallies (multiple if repeated mesh tallies) |
[in] | score | tally score |
openmc::TriggerMetric OpenMCProblemBase::triggerMetric | ( | trigger::TallyTriggerTypeEnum | trigger | ) | const |
Convert from a MooseEnum for a trigger metric to an OpenMC enum
[in] | trigger | trigger metric |
openmc::TriggerMetric OpenMCProblemBase::triggerMetric | ( | std::string | trigger | ) | const |
|
static |
void OpenMCProblemBase::writeSourceBank | ( | const std::string & | filename | ) |
Write the source bank to HDF5 for postprocessing or for use in subsequent solves
[in] | filename | file name |
|
staticprotected |
Conversion unit to transfer between kg/m3 and g/cm3.
|
protected |
Fixed point iteration index used in relaxation; because we sometimes run OpenMC in a pseudo-transient coupling with NekRS, we simply increment this by 1 each time we call openmc::run(). This uses a zero indexing, so after the first iteration, we have finished iteration 0, and so on.
|
protected |
Mapping from local element indices to global element indices for this rank.
|
protected |
Number of digits to use to display the cell ID for diagnostic messages; this is estimated conservatively based on the total number of cells, even though there may be distributed cells such that the maximum cell ID is far smaller than the total number of cells.
|
protected |
Total number of unique OpenMC cell IDs + instances combinations.
|
protected |
Userobjects for changing OpenMC material compositions.
|
protected |
Power by which to normalize the OpenMC results, for k-eigenvalue mode.
|
protected |
Whether to take the starting fission source from iteration \(n\) as the fission source converged from iteration \(n-1\). Setting this to true will in most cases lead to improved convergence of the initial source as iterations progress because you don't "start from scratch" each iteration and do the same identical (within a random number seed) converging of the fission source.
|
protected |
OpenMC run mode.
|
protected |
Multiplicative factor to apply to the mesh in the [Mesh] block in order to convert whatever units that mesh is in into OpenMC's length scale of centimeters. For instance, it is commonplace to develop fuel performance models with a length scale of meters. Rather than onerously convert all MOOSE inputs to which OpenMC will be coupled to units of centimeters, this parameter allows us to scale the mesh we couple to OpenMC. Note that this does not actually scale the mesh itself, but simply multiplies the mesh coordinates by this parameter when identifying the mapping between elements and cells.
By default, this parameter is set to 1.0, meaning that OpenMC is coupled to another MOOSE application with an input written in terms of centimeters. Set this parameter to 100 if the coupled MOOSE application is in units of meters, for instance.
To summarize by example - if the MOOSE application uses units of meters, with a mesh named mesh.exo, then the OpenMC-wrapped input file should also use that mesh (with units of meters) in its [Mesh] block (or perhaps a coarser version of that mesh if the resolution of coupling does not need to match - the units just have to be the same). Then, you should set 'scaling = 100.0' so that the mapping is performed correctly.
|
protected |
Whether to skip writing statepoints from OpenMC.
|
protected |
Source strength by which to normalize the OpenMC results, for fixed source mode.
|
protected |
Whether a mesh scaling was specified by the user.
|
protected |
Userobjects for changing OpenMC tally nuclides.
|
protected |
Total number of particles simulated.
|
protected |
Whether to print diagnostic information about model setup and the transfers.
|
staticprotected |
ID used by OpenMC to indicate that a material fill is VOID.