Skip to content

Commit

Permalink
Merge pull request #235 from smpark7/leakage-postprocessor
Browse files Browse the repository at this point in the history
Add neutron leakage postprocessors and allow for optional group constants
  • Loading branch information
LukeSeifert authored Jan 2, 2024
2 parents 1e22257 + e56bb80 commit 6f75bab
Show file tree
Hide file tree
Showing 14 changed files with 355 additions and 83 deletions.
3 changes: 3 additions & 0 deletions include/materials/GenericMoltresMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class GenericMoltresMaterial : public NuclearMaterial
Real _peak_power_density_set_point;
Real _controller_gain;

// Map of group constant names to file group constant names
std::map<std::string, std::string> _file_map;

std::string _material;
bool _perform_control;
};
4 changes: 4 additions & 0 deletions include/materials/MoltresJsonMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ class MoltresJsonMaterial : public NuclearMaterial
void Construct(nlohmann::json xs_root);
virtual void computeQpProperties() override;

// Vector of group constants to be loaded
std::vector<std::string> _group_consts;

// Material associated with the group constants to be loaded
std::string _material_key;
};
44 changes: 29 additions & 15 deletions include/materials/NuclearMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ class NuclearMaterial : public GenericConstantMaterial

const VariableValue & _temperature;

// Number of neutron groups
unsigned int _num_groups;

// Number of precursor groups
unsigned int _num_precursor_groups;

// Group constant MaterialProperty(s)
MaterialProperty<std::vector<Real>> & _remxs;
MaterialProperty<std::vector<Real>> & _fissxs;
MaterialProperty<std::vector<Real>> & _nsf;
Expand Down Expand Up @@ -91,30 +98,37 @@ class NuclearMaterial : public GenericConstantMaterial
MaterialProperty<Real> & _d_beta_d_temp;
MaterialProperty<std::vector<Real>> & _d_decay_constant_d_temp;

// Group constant interpolation type
MooseEnum _interp_type;

unsigned _num_groups;
unsigned _num_precursor_groups;
// Vector of group constant names
std::vector<std::string> _xsec_names{"REMXS",
"FISSXS",
"NSF",
"FISSE",
"DIFFCOEF",
"RECIPVEL",
"CHI_T",
"CHI_P",
"CHI_D",
"GTRANSFXS",
"BETA_EFF",
"DECAY_CONSTANT"};

// Map of group constant names to group constant values
std::map<std::string, std::vector<std::vector<Real>>> _xsec_map;

// Group constant interpolators
std::map<std::string, std::vector<SplineInterpolation>> _xsec_spline_interpolators;
std::map<std::string, std::vector<MonotoneCubicInterpolation>> _xsec_monotone_cubic_interpolators;
std::map<std::string, std::vector<LinearInterpolation>> _xsec_linear_interpolators;
std::map<std::string, std::vector<BicubicSplineInterpolation>> _xsec_bicubic_spline_interpolators;

// Map of group constant names to number of neutron/precursor groups
std::map<std::string, int> _vec_lengths;
std::map<std::string, std::string> _file_map;

// Vector of temperature values
std::vector<double> _XsTemperature;
const std::vector<std::string> _xsec_names{"REMXS",
"FISSXS",
"NSF",
"FISSE",
"DIFFCOEF",
"RECIPVEL",
"CHI_T",
"CHI_P",
"CHI_D",
"GTRANSFXS",
"BETA_EFF",
"DECAY_CONSTANT"};

std::vector<std::vector<Real>> _remxs_consts = std::vector<std::vector<Real>>(2);
std::vector<std::vector<Real>> _fissxs_consts = std::vector<std::vector<Real>>(2);
Expand Down
21 changes: 21 additions & 0 deletions include/postprocessors/NeutronLeakage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once

#include "SideIntegralVariablePostprocessor.h"

/**
* This postprocessor computes the neutron leakage rate of a given neutron group
* along a boundary
*/
class NeutronLeakage : public SideIntegralVariablePostprocessor
{
public:
NeutronLeakage(const InputParameters & parameters);

static InputParameters validParams();

protected:
Real computeQpIntegral() override;

const MaterialProperty<std::vector<Real>> & _diffcoef;
unsigned int _group;
};
25 changes: 25 additions & 0 deletions include/postprocessors/TotalNeutronLeakage.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "SideIntegralPostprocessor.h"
#include "ScalarTransportBase.h"

/**
* This postprocess computes the total neutron leakage rate along a boundary for all neutron
* groups
*/
class TotalNeutronLeakage : public SideIntegralPostprocessor, public ScalarTransportBase
{
public:
TotalNeutronLeakage(const InputParameters & parameters);

static InputParameters validParams();

protected:
Real computeQpIntegral() override;

std::vector<MooseVariableFEBase *> _vars;
const MaterialProperty<std::vector<Real>> & _diffcoef;
unsigned int _num_groups;
std::vector<const VariableValue *> _group_fluxes;
std::vector<const VariableGradient *> _grad_group_fluxes;
};
2 changes: 0 additions & 2 deletions src/materials/GenericMoltresMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ GenericMoltresMaterial::GenericMoltresMaterial(const InputParameters & parameter
else
_perform_control = false;

_num_groups = getParam<unsigned>("num_groups");
_num_precursor_groups = getParam<unsigned>("num_precursor_groups");
std::string property_tables_root = getParam<std::string>("property_tables_root");

_file_map["REMXS"] = "REMXS";
Expand Down
91 changes: 54 additions & 37 deletions src/materials/MoltresJsonMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@ MoltresJsonMaterial::validParams()
params.addRequiredParam<std::string>("base_file", "The file containing macroscopic XS.");
params.addRequiredParam<std::string>("material_key",
"The file key where the macroscopic XS can be found.");
params.addParam<std::vector<std::string>>(
"group_constants",
std::vector<std::string>{"REMXS",
"FISSXS",
"NSF",
"FISSE",
"DIFFCOEF",
"RECIPVEL",
"CHI_T",
"CHI_P",
"CHI_D",
"GTRANSFXS",
"BETA_EFF",
"DECAY_CONSTANT"},
"Group constants to be determined.");
return params;
}

MoltresJsonMaterial::MoltresJsonMaterial(const InputParameters & parameters)
: NuclearMaterial(parameters)

: NuclearMaterial(parameters),
_group_consts(getParam<std::vector<std::string>>("group_constants")),
_material_key(getParam<std::string>("material_key"))
{

_num_groups = getParam<unsigned>("num_groups");
_num_precursor_groups = getParam<unsigned>("num_precursor_groups");
std::string base_file = getParam<std::string>("base_file");
_material_key = getParam<std::string>("material_key");

const std::string & file_name_ref = base_file;
std::ifstream myfile(file_name_ref.c_str());
Expand All @@ -48,11 +60,10 @@ MoltresJsonMaterial::MoltresJsonMaterial(const InputParameters & parameters)
void
MoltresJsonMaterial::Construct(nlohmann::json xs_root)
{
auto xsec_interpolators = _xsec_linear_interpolators;
std::set<std::string> gc_set(_group_consts.begin(), _group_consts.end());
bool oneInfo = false;
for (unsigned int j = 0; j < _xsec_names.size(); ++j)
{

auto o = _vec_lengths[_xsec_names[j]];
auto L = _XsTemperature.size();

Expand All @@ -62,39 +73,45 @@ MoltresJsonMaterial::Construct(nlohmann::json xs_root)

_xsec_map[_xsec_names[j]].resize(o);

for (decltype(_XsTemperature.size()) l = 0; l < L; ++l)
if (gc_set.find(_xsec_names[j]) != gc_set.end())
{
auto temp_key = std::to_string(static_cast<int>(_XsTemperature[l]));
auto dataset = xs_root[_material_key][temp_key][_xsec_names[j]];
if (_xsec_names[j] == "CHI_D" && dataset.empty())
for (decltype(_XsTemperature.size()) l = 0; l < L; ++l)
{
for (decltype(_num_groups) k = 1; k < _num_groups; ++k)
_xsec_map["CHI_D"][k].push_back(0.0);
_xsec_map["CHI_D"][0].push_back(1.0);
mooseWarning(
"CHI_D data missing -> assume delayed neutrons born in top group for material " +
_name);
continue;
}
if (dataset.empty())
mooseError("Unable to open database " + _material_key + "/" + temp_key + "/" +
_file_map[_xsec_names[j]]);
auto temp_key = std::to_string(static_cast<int>(_XsTemperature[l]));
auto dataset = xs_root[_material_key][temp_key][_xsec_names[j]];
if (_xsec_names[j] == "CHI_D" && dataset.empty())
{
for (decltype(_num_groups) k = 1; k < _num_groups; ++k)
_xsec_map["CHI_D"][k].push_back(0.0);
_xsec_map["CHI_D"][0].push_back(1.0);
mooseWarning(
"CHI_D data missing -> assume delayed neutrons born in top group for material " +
_name);
continue;
}
if (dataset.empty())
mooseError("Unable to open database " + _material_key + "/" + temp_key + "/" +
_xsec_names[j]);

int dims = dataset.size();
if (o == 0 and !oneInfo)
{
mooseInfo("Only precursor material data initialized (num_groups = 0) for material " + _name);
oneInfo = true;
}
if (o != dims && o != 0)
mooseError("The number of " + _material_key + "/" + temp_key + "/" +
_file_map[_xsec_names[j]] + " values does not match the "
"num_groups/num_precursor_groups parameter. " +
std::to_string(dims) + "!=" + std::to_string(o));
for (auto k = 0; k < o; ++k)
{
_xsec_map[_xsec_names[j]][k].push_back(dataset[k].get<double>());
int dims = dataset.size();
if (o == 0 and !oneInfo)
{
mooseInfo("Only precursor material data initialized (num_groups = 0) for material " + _name);
oneInfo = true;
}
if (o != dims && o != 0)
mooseError("The number of " + _material_key + "/" + temp_key + "/" +
_xsec_names[j] + " values does not match the "
"num_groups/num_precursor_groups parameter. " +
std::to_string(dims) + "!=" + std::to_string(o));
for (auto k = 0; k < o; ++k)
_xsec_map[_xsec_names[j]][k].push_back(dataset[k].get<double>());
}
} else
{
for (decltype(_XsTemperature.size()) l = 0; l < L; ++l)
for (auto k = 0; k < o; ++k)
_xsec_map[_xsec_names[j]][k].push_back(0.);
}
switch (_interp_type)
{
Expand Down
26 changes: 5 additions & 21 deletions src/materials/NuclearMaterial.C
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ InputParameters
NuclearMaterial::validParams()
{
InputParameters params = GenericConstantMaterial::validParams();
params.addRequiredParam<unsigned>("num_groups",
params.addRequiredParam<unsigned int>("num_groups",
"The number of groups the energy spectrum is divided into.");
params.addRequiredParam<unsigned>("num_precursor_groups",
params.addRequiredParam<unsigned int>("num_precursor_groups",
"The number of delayed neutron precursor groups.");
params.addCoupledVar(
"temperature", 937, "The temperature field for determining group constants.");
params.addRequiredParam<MooseEnum>("interp_type",
GenericMoltresMaterial::interpTypes(),
NuclearMaterial::interpTypes(),
"The type of interpolation to perform.");
params.addParam<bool>(
"sss2_input", true, "Whether serpent 2 was used to generate the input files.");
params.set<MooseEnum>("constant_on") = "NONE";

// the following two lines esentially make the two parameters optional
params.set<std::vector<std::string>>("prop_names") = std::vector<std::string>();
params.set<std::vector<Real>>("prop_values") = std::vector<Real>();
Expand All @@ -30,6 +29,8 @@ NuclearMaterial::validParams()
NuclearMaterial::NuclearMaterial(const InputParameters & parameters)
: GenericConstantMaterial(parameters),
_temperature(coupledValue("temperature")),
_num_groups(getParam<unsigned int>("num_groups")),
_num_precursor_groups(getParam<unsigned int>("num_precursor_groups")),
_remxs(declareProperty<std::vector<Real>>("remxs")),
_fissxs(declareProperty<std::vector<Real>>("fissxs")),
_nsf(declareProperty<std::vector<Real>>("nsf")),
Expand Down Expand Up @@ -58,11 +59,7 @@ NuclearMaterial::NuclearMaterial(const InputParameters & parameters)
_d_beta_d_temp(declareProperty<Real>("d_beta_d_temp")),
_d_decay_constant_d_temp(declareProperty<std::vector<Real>>("d_decay_constant_d_temp")),
_interp_type(getParam<MooseEnum>("interp_type"))

{
_num_groups = getParam<unsigned>("num_groups");
_num_precursor_groups = getParam<unsigned>("num_precursor_groups");

auto n = _xsec_names.size();
for (decltype(n) j = 0; j < n; ++j)
{
Expand All @@ -73,19 +70,6 @@ NuclearMaterial::NuclearMaterial(const InputParameters & parameters)
else
_vec_lengths[_xsec_names[j]] = _num_groups;
}
_file_map["REMXS"] = "REMXS";
_file_map["NSF"] = "NSF";
_file_map["DIFFCOEF"] = "DIFFCOEF";
_file_map["BETA_EFF"] = "BETA_EFF";
_file_map["FLUX"] = "FLUX";
_file_map["FISSXS"] = "FISSXS";
_file_map["FISSE"] = "FISSE";
_file_map["RECIPVEL"] = "RECIPVEL";
_file_map["CHI_T"] = "CHI_T";
_file_map["CHI_P"] = "CHI_P";
_file_map["CHI_D"] = "CHI_D";
_file_map["GTRANSFXS"] = "GTRANSFXS";
_file_map["DECAY_CONSTANT"] = "DECAY_CONSTANT";
}

void
Expand Down
31 changes: 31 additions & 0 deletions src/postprocessors/NeutronLeakage.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "NeutronLeakage.h"

registerMooseObject("MoltresApp", NeutronLeakage);

InputParameters
NeutronLeakage::validParams()
{
InputParameters params = SideIntegralVariablePostprocessor::validParams();
params.addClassDescription("Postprocessor for computing neutron leakage along provided "
"boundaries");
params.addRequiredParam<unsigned int>("group_number",
"The group for which this postprocessor "
"calculates leakage");
params.addCoupledVar("temperature",
"The temperature used to interpolate the diffusion coefficient");
return params;
}

NeutronLeakage::NeutronLeakage(const InputParameters & parameters)
: SideIntegralVariablePostprocessor(parameters),
_diffcoef(getMaterialProperty<std::vector<Real>>("diffcoef")),
_group(getParam<unsigned int>("group_number") - 1)
{
addMooseVariableDependency(&mooseVariableField());
}

Real
NeutronLeakage::computeQpIntegral()
{
return _u[_qp] / 4 - _normals[_qp] * _grad_u[_qp] * _diffcoef[_qp][_group] / 2;
}
Loading

0 comments on commit 6f75bab

Please sign in to comment.