29 params.
addRequiredParam<std::vector<NonlinearVariableName>>(
"primary_species",
30 "The list of primary species to add");
31 params.
addParam<std::vector<AuxVariableName>>(
32 "secondary_species",
"The list of solid kinetic species to be output as aux variables");
33 params.
addRequiredParam<std::string>(
"kin_reactions",
"The list of solid kinetic reactions");
35 "The list of equilibrium constants for all reactions");
37 "specific_reactive_surface_area",
38 "The list of specific reactive surface area for all minerals (m^2/L)");
40 "kinetic_rate_constant",
"The list of kinetic rate constant for all reactions (mol/m^2/s)");
42 "activation_energy",
"The list of activation energy values for all reactions (J/mol)");
43 params.
addParam<
Real>(
"gas_constant", 8.314,
"Gas constant. Default is 8.314 (J/mol/K)");
45 "reference_temperature",
"The list of reference temperatures for all reactions (K)");
47 "The system temperature for all reactions (K)");
48 params.
addClassDescription(
"Adds solid kinetic Kernels and AuxKernels for primary species");
54 _primary_species(getParam<
std::vector<NonlinearVariableName>>(
"primary_species")),
55 _secondary_species(getParam<
std::vector<AuxVariableName>>(
"secondary_species")),
56 _kinetic_species_involved(_primary_species.size()),
57 _weights(_primary_species.size()),
58 _input_reactions(getParam<
std::string>(
"kin_reactions")),
59 _logk(getParam<
std::vector<
Real>>(
"log10_keq")),
60 _r_area(getParam<
std::vector<
Real>>(
"specific_reactive_surface_area")),
61 _ref_kconst(getParam<
std::vector<
Real>>(
"kinetic_rate_constant")),
62 _e_act(getParam<
std::vector<
Real>>(
"activation_energy")),
63 _gas_const(getParam<
Real>(
"gas_constant")),
64 _ref_temp(getParam<
std::vector<
Real>>(
"reference_temperature")),
65 _sys_temp(getParam<
std::vector<VariableName>>(
"system_temperature"))
70 bool old_syntax =
false;
79 mooseError(
"Old solid kinetic reaction syntax present.\nReactions should now be comma " 80 "separated, and must have spaces between species and +/-/= operators.\n" 81 "See #9972 for details");
84 pcrecpp::RE re_reactions(
"(.+?)" 87 pcrecpp::RE_Options().set_extended(
true));
89 pcrecpp::RE re_terms(
"(\\S+)");
90 pcrecpp::RE re_coeff_and_species(
"(?: \\(? (.*?) \\)? )" 93 pcrecpp::RE_Options().set_extended(
true));
96 pcrecpp::StringPiece single_reaction, term;
97 std::string single_reaction_str;
100 while (re_reactions.FindAndConsume(&input, &single_reaction_str))
106 mooseError(
"No solid kinetic reaction provided!");
114 std::string species, coeff_str;
117 bool secondary =
false;
119 std::vector<Real> local_stos;
120 std::vector<VariableName> local_species_list;
123 while (re_terms.FindAndConsume(&single_reaction, &term))
126 if (re_coeff_and_species.PartialMatch(term, &coeff_str, &species))
128 if (coeff_str.length())
129 coeff = std::stod(coeff_str);
139 local_stos.push_back(coeff);
140 local_species_list.push_back(species);
144 else if (term ==
"+" || term ==
"=" || term ==
"-")
156 mooseError(
"Error parsing term: ", term.as_string());
159 _stos.push_back(local_stos);
177 _console <<
"Solid kinetic reactions:\n";
185 if (!std::is_permutation(
187 mooseError(
"All solid kinetic species must be added as secondary species");
191 mooseError(
"The number of values entered for log10_keq is not equal to the number of solid " 192 "kinetic reactions");
194 mooseError(
"The number of values entered for specific_reactive_surface_area is not equal to " 195 "the number of solid kinetic reactions");
197 mooseError(
"The number of values entered for kinetic_rate_constant is not equal to the number " 198 "of solid kinetic reactions");
200 mooseError(
"The number of values entered for activation_energy is not equal to the number of " 201 "solid kinetic reactions");
203 mooseError(
"The number of values entered for reference_temperature is not equal to the number " 204 "of solid kinetic reactions");
217 params_kin.
set<std::vector<Real>>(
"weight") =
_weights[i];
236 params_kin.
set<std::vector<VariableName>>(
"sys_temp") =
_sys_temp;
237 params_kin.
set<std::vector<Real>>(
"sto_v") =
_stos[i];
std::vector< std::vector< Real > > _stos
Stoichiometric coefficients for each primary species in each reaction.
const std::vector< Real > _ref_kconst
Reference kinetic rate constant.
std::vector< std::vector< VariableName > > _primary_species_involved
Primary species involved in the ith kinetic reaction.
const std::vector< Real > _logk
Log10 of equilibrium constant.
InputParameters getValidParams(const std::string &name) const
const std::vector< VariableName > _sys_temp
Actual system temperature.
static InputParameters validParams()
AddCoupledSolidKinSpeciesAction(const InputParameters ¶ms)
const std::vector< Real > _ref_temp
Reference temperature.
std::vector< std::string > _reactions
Vector of parsed reactions.
unsigned int _num_reactions
Number of reactions.
static InputParameters validParams()
std::vector< std::vector< VariableName > > _kinetic_species_involved
Secondary solid species involved the ith primary species.
const std::string & _current_task
const std::vector< Real > _r_area
Specific reactive surface area, m^2/L solution.
const Real _gas_const
Gas constant, (Default 8.314 J/mol/K)
const std::vector< AuxVariableName > _secondary_species
Secondary species added as AuxVariables.
const std::vector< NonlinearVariableName > _primary_species
Basis set of primary species.
const std::vector< Real > _e_act
Activation energy.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void act() override
std::string _input_reactions
Reaction network read from input file.
void mooseError(Args &&... args) const
std::vector< VariableName > _solid_kinetic_species
Secondary solid species read by the parser.
registerMooseAction("ChemicalReactionsApp", AddCoupledSolidKinSpeciesAction, "add_kernel")
std::shared_ptr< FEProblemBase > & _problem
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
const ConsoleStream _console
static const std::string k
std::vector< std::vector< Real > > _weights
Weight of each primary species in each reaction.