Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default value for vector type input parameters #116

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/actions/ChemicalReactions.C
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ ChemicalReactions::validParams()
InputParameters params = AddVariableAction::validParams();
params.addRequiredParam<std::vector<NonlinearVariableName>>(
"species", "List of (tracked) species included in reactions (both products and reactants)");
params.addParam<std::vector<Real>>("reaction_coefficient", "The reaction coefficients.");
params.addParam<std::vector<Real>>("reaction_coefficient", {}, "The reaction coefficients.");
params.addParam<bool>(
"include_electrons", false, "Whether or not electrons are being considered.");
params.addParam<bool>("track_energy", false, "Whether or not to track gas energy/temperature.");
Expand All @@ -64,7 +64,7 @@ ChemicalReactions::validParams()
"List of (tracked) energy values. (Optional; requires 'track_energy' to be True.)");
params.addParam<std::string>("electron_density", "The variable used for density of electrons.");
params.addParam<std::vector<VariableName>>(
"electron_energy", "Electron energy, used for energy-dependent reaction rates.");
"electron_energy", {}, "Electron energy, used for energy-dependent reaction rates.");
params.addParam<std::vector<std::string>>("gas_species",
"All of the background gas species in the system.");
params.addParam<std::vector<Real>>("gas_fraction", "The initial fraction of each gas species.");
Expand Down Expand Up @@ -92,10 +92,10 @@ ChemicalReactions::validParams()
"Sample rate constants with E/N (reduced_field) or Te (electron_energy).");
params.addParam<bool>(
"scalar_problem", false, "The problem is scalar if it is a pure ODE problem (Global/0D).");
params.addParam<std::vector<std::string>>("equation_constants",
"The constants included in the reaction equation(s).");
params.addParam<std::vector<std::string>>(
"equation_values", "The values of the constants included in the reaction equation(s).");
"equation_constants", {}, "The constants included in the reaction equation(s).");
params.addParam<std::vector<std::string>>(
"equation_values", {}, "The values of the constants included in the reaction equation(s).");
params.addParam<std::vector<VariableName>>(
"equation_variables", "Any nonlinear variables that appear in the equations.");
params.addParam<std::vector<VariableName>>(
Expand Down
29 changes: 15 additions & 14 deletions src/actions/ChemicalReactionsBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ChemicalReactionsBase::validParams()
"species", "List of (tracked) species included in reactions (both products and reactants)");
params.addParam<std::vector<std::string>>(
"aux_species", "Auxiliary species that are not included in nonlinear solve.");
params.addParam<std::vector<Real>>("reaction_coefficient", "The reaction coefficients.");
params.addParam<std::vector<Real>>("reaction_coefficient", {}, "The reaction coefficients.");
params.addParam<bool>(
"include_electrons", false, "Whether or not electrons are being considered.");
params.addParam<bool>(
Expand All @@ -65,9 +65,9 @@ ChemicalReactionsBase::validParams()
"track_rates", false, "Whether or not to track production rates for each reaction");
params.addParam<std::string>("electron_density", "The variable used for density of electrons.");
params.addParam<std::vector<NonlinearVariableName>>(
"electron_energy", "Electron energy, used for energy-dependent reaction rates.");
"electron_energy", {}, "Electron energy, used for energy-dependent reaction rates.");
params.addParam<std::vector<NonlinearVariableName>>(
"gas_energy", "Gas energy, used for energy-dependent reaction rates.");
"gas_energy", {}, "Gas energy, used for energy-dependent reaction rates.");
params.addParam<std::vector<std::string>>("gas_species",
"All of the background gas species in the system.");
params.addParam<std::vector<Real>>("gas_fraction", "The initial fraction of each gas species.");
Expand All @@ -81,10 +81,10 @@ ChemicalReactionsBase::validParams()
"sampling_variable",
"reduced_field",
"Sample rate constants with E/N (reduced_field) or Te (electron_energy).");
params.addParam<std::vector<std::string>>("equation_constants",
"The constants included in the reaction equation(s).");
params.addParam<std::vector<std::string>>(
"equation_values", "The values of the constants included in the reaction equation(s).");
"equation_constants", {}, "The constants included in the reaction equation(s).");
params.addParam<std::vector<std::string>>(
"equation_values", {}, "The values of the constants included in the reaction equation(s).");
params.addParam<std::vector<VariableName>>(
"equation_variables", "Any nonlinear variables that appear in the equations.");
params.addParam<std::vector<VariableName>>(
Expand All @@ -93,8 +93,8 @@ ChemicalReactionsBase::validParams()
false,
"If true, the input file parser will look for a parameter denoting lumped "
"species (NEUTRAL for now...eventually arbitrary?).");
params.addParam<std::vector<std::string>>("lumped",
"The neutral species that will be lumped together.");
params.addParam<std::vector<std::string>>(
"lumped", {}, "The neutral species that will be lumped together.");
params.addParam<std::string>("lumped_name",
"The name of the variable that will account for multiple species.");
params.addParam<bool>(
Expand Down Expand Up @@ -189,7 +189,7 @@ ChemicalReactionsBase::ChemicalReactionsBase(const InputParameters & params)
else
_aux_species.push_back("none");

if (getParam<bool>("lumped_species") && !isParamValid("lumped"))
if (getParam<bool>("lumped_species") && _lumped_species.size() == 0)
mooseError("The lumped_species parameter is set to true, but vector of neutrals (lumped = "
"'...') is not set.");

Expand Down Expand Up @@ -832,17 +832,17 @@ ChemicalReactionsBase::ChemicalReactionsBase(const InputParameters & params)

if (_energy_change[i])
{
if (!isParamValid("electron_energy") && !isParamValid("gas_energy"))
if (_electron_energy.size() == 0 && _gas_energy.size() == 0)
mooseError("Reactions have energy changes, but no electron or gas temperature variable is "
"included!");
}
}
if (isParamValid("electron_energy"))
if (_electron_energy.size() > 0)
{
_electron_energy_term.push_back(true);
_energy_variable.push_back(_electron_energy[0]);
}
if (isParamValid("gas_energy"))
if (_gas_energy.size() > 0)
{
_electron_energy_term.push_back(false);
_energy_variable.push_back(_gas_energy[0]);
Expand Down Expand Up @@ -901,15 +901,16 @@ ChemicalReactionsBase::ChemicalReactionsBase(const InputParameters & params)
}
if (unbalanced)
{
std::string error_str;
string error_str;
for (unsigned int i = 0; i < faulty_reaction.size(); ++i)
{
error_str.append(" ");
error_str.append(faulty_reaction[i]);
error_str.append("\n");
}

mooseError("The following equations are unbalanced:\n", error_str,
mooseError("The following equations are unbalanced:\n",
error_str,
"Fix unbalanced reactions or particle conservation will not be enforced.");
}
}
Expand Down