16 #include "libmesh/string_to_enum.h" 30 "primary_species",
"The list of primary variables to add");
31 params.
addParam<std::vector<AuxVariableName>>(
32 "secondary_species",
"The list of aqueous equilibrium species to be output as aux variables");
33 params.
addParam<std::string>(
"reactions",
"The list of aqueous equilibrium reactions");
34 params.
addParam<std::vector<VariableName>>(
"pressure", {},
"Pressure variable");
37 params.
addClassDescription(
"Adds coupled equilibrium Kernels and AuxKernels for primary species");
43 _primary_species(getParam<
std::vector<NonlinearVariableName>>(
"primary_species")),
44 _secondary_species(getParam<
std::vector<AuxVariableName>>(
"secondary_species")),
45 _weights(_primary_species.size()),
46 _primary_participation(_primary_species.size()),
47 _sto_u(_primary_species.size()),
48 _sto_v(_primary_species.size()),
49 _coupled_v(_primary_species.size()),
50 _input_reactions(getParam<
std::string>(
"reactions")),
51 _pressure_var(getParam<
std::vector<VariableName>>(
"pressure")),
55 pcrecpp::RE re_reaction(
65 pcrecpp::RE_Options().set_extended(
true));
67 pcrecpp::RE re_terms(
"(\\S+)");
68 pcrecpp::RE re_coeff_and_species(
"(?: \\(? (.*?) \\)? )" 71 pcrecpp::RE_Options().set_extended(
true));
75 pcrecpp::StringPiece single_reaction, term;
76 std::string single_reaction_str;
80 while (re_reaction.FindAndConsume(&input, &single_reaction_str, &eq_coeff))
89 mooseError(
"No equilibrium reaction provided!");
101 std::string species, coeff_str;
104 bool secondary =
false;
106 std::vector<Real> local_stos;
107 std::vector<VariableName> local_species_list;
110 while (re_terms.FindAndConsume(&single_reaction, &term))
113 if (re_coeff_and_species.PartialMatch(term, &coeff_str, &species))
115 if (coeff_str.length())
116 coeff = std::stod(coeff_str);
126 local_stos.push_back(coeff);
127 local_species_list.push_back(species);
131 else if (term ==
"+" || term ==
"=" || term ==
"-")
145 mooseError(
"Error parsing term: ", term.as_string());
148 _stos.push_back(local_stos);
188 _console <<
"Aqueous equilibrium reactions:\n";
212 params_sub.
set<std::vector<Real>>(
"sto_v") =
_sto_v[i][
j];
213 params_sub.
set<std::vector<VariableName>>(
"v") =
_coupled_v[i][
j];
214 _problem->addKernel(
"CoupledBEEquilibriumSub",
223 params_cd.
set<std::vector<Real>>(
"sto_v") =
_sto_v[i][
j];
225 _problem->addKernel(
"CoupledDiffusionReactionSub",
237 params_conv.
set<std::vector<Real>>(
"sto_v") =
_sto_v[i][
j];
238 params_conv.
set<std::vector<VariableName>>(
"v") =
_coupled_v[i][
j];
241 _problem->addKernel(
"CoupledConvectionReactionSub",
260 params_eq.
set<std::vector<Real>>(
"sto_v") =
_stos[
j];
AddCoupledEqSpeciesAction(const InputParameters ¶ms)
std::vector< Real > _eq_const
Equilibrium constants for each reaction.
const std::vector< AuxVariableName > _secondary_species
Secondary species added as AuxVariables.
std::vector< VariableName > _eq_species
Equilibrium species.
InputParameters getValidParams(const std::string &name) const
std::vector< std::vector< bool > > _primary_participation
Participation of primary species in each reaction.
std::vector< std::string > _reactions
Vector of parsed reactions.
std::vector< std::vector< Real > > _sto_u
Stoichiometric coefficients of primary variables in each reaction.
static InputParameters validParams()
const std::string & _current_task
const RealVectorValue _gravity
Gravity (default is (0, 0, 0))
static InputParameters validParams()
virtual void act() override
std::set< std::string > _aux_species
Set of auxillary species.
std::vector< std::vector< Real > > _weights
Weight of each primary species in each reaction.
std::vector< std::vector< std::vector< Real > > > _sto_v
Stoichiometric coefficients of coupled primary variables in each reaction.
std::string _input_reactions
Reaction network read from input file.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const std::vector< NonlinearVariableName > _primary_species
Basis set of primary species.
std::vector< std::vector< Real > > _stos
Stoichiometric coefficients for each primary species in each reaction.
registerMooseAction("ChemicalReactionsApp", AddCoupledEqSpeciesAction, "add_kernel")
void mooseError(Args &&... args) const
const InputParameters & _pars
std::shared_ptr< FEProblemBase > & _problem
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
unsigned int _num_reactions
Number of reactions.
const ConsoleStream _console
std::vector< std::vector< std::vector< VariableName > > > _coupled_v
Coupled primary species for each reaction.
static const std::string k
std::vector< std::vector< VariableName > > _primary_species_involved
Primary species involved in the ith equilibrium reaction.
const std::vector< VariableName > _pressure_var
Pressure variable.