Go to the documentation of this file.
19 params.addRequiredCoupledVar(
21 "List of variables that represent the mass fractions. For the aqueous phase these are "
22 "concentrations of the primary species with units m^{3}(chemical)/m^{3}(fluid phase). For "
23 "the other phases (if any) these will typically be initialised to zero and will not change "
24 "throughout the simulation. Format is 'f_ph0^c0 f_ph0^c1 f_ph0^c2 ... f_ph0^c(N-1) f_ph1^c0 "
25 "f_ph1^c1 fph1^c2 ... fph1^c(N-1) ... fphP^c0 f_phP^c1 fphP^c2 ... fphP^c(N-1)' where "
26 "N=number of primary species and P=num_phases, and it is assumed that "
27 "f_ph^cN=1-sum(f_ph^c,{c,0,N-1}) so that f_ph^cN need not be given.");
28 params.addRequiredParam<
unsigned>(
"num_reactions",
29 "Number of equations in the system of chemical reactions");
30 params.addParam<
bool>(
"equilibrium_constants_as_log10",
32 "If true, the equilibrium constants are written in their log10 form, eg, "
33 "-2. If false, the equilibrium constants are written in absolute terms, "
35 params.addRequiredCoupledVar(
"equilibrium_constants",
36 "Equilibrium constant for each equation (dimensionless). If these "
37 "are temperature dependent AuxVariables, the Jacobian will not be "
39 params.addRequiredParam<std::vector<Real>>(
40 "primary_activity_coefficients",
41 "Activity coefficients for the primary species (dimensionless) (one for each)");
42 params.addRequiredParam<std::vector<Real>>(
44 "A matrix defining the aqueous reactions. The matrix is entered as a long vector: the first "
46 "entered first, followed by the second row, etc. There should be num_reactions rows. All "
47 "primary species should appear only on the LHS of each reaction (and there should be just "
48 "one secondary species on the RHS, by definition) so they may have negative coefficients. "
49 "Each row should have number of primary_concentrations entries, which are the stoichiometric "
50 "coefficients. The first coefficient must always correspond to the first primary species, "
52 params.addRequiredParam<std::vector<Real>>(
53 "secondary_activity_coefficients",
54 "Activity coefficients for the secondary species (dimensionless) (one for each reaction)");
55 params.addPrivateParam<std::string>(
"pf_material_type",
"mass_fraction");
56 params.addClassDescription(
57 "This Material forms a std::vector<std::vector ...> of mass-fractions "
58 "(total concentrations of primary species (m^{3}(primary species)/m^{3}(solution)) and since "
59 "this is for an aqueous system only, mass-fraction equals volume-fraction) corresponding to "
61 "aqueous equilibrium chemistry system. The first mass fraction is the "
62 "concentration of the first primary species, etc, and the last mass "
63 "fraction is the concentration of H2O.");
70 _sec_conc(_nodal_material
71 ? declareProperty<std::vector<Real>>(
"PorousFlow_secondary_concentration_nodal")
72 : declareProperty<std::vector<Real>>(
"PorousFlow_secondary_concentration_qp")),
73 _dsec_conc_dvar(_nodal_material ? declareProperty<std::vector<std::vector<Real>>>(
74 "dPorousFlow_secondary_concentration_nodal_dvar")
75 : declareProperty<std::vector<std::vector<Real>>>(
76 "dPorousFlow_secondary_concentration_qp_dvar")),
78 _temperature(_nodal_material ? getMaterialProperty<Real>(
"PorousFlow_temperature_nodal")
79 : getMaterialProperty<Real>(
"PorousFlow_temperature_qp")),
82 ? getMaterialProperty<std::vector<Real>>(
"dPorousFlow_temperature_nodal_dvar")
83 : getMaterialProperty<std::vector<Real>>(
"dPorousFlow_temperature_qp_dvar")),
85 _num_primary(_num_components - 1),
86 _aq_ph(_dictator.aqueousPhaseNumber()),
87 _aq_i(_aq_ph * _num_primary),
88 _num_reactions(getParam<unsigned>(
"num_reactions")),
89 _equilibrium_constants_as_log10(getParam<bool>(
"equilibrium_constants_as_log10")),
90 _num_equilibrium_constants(coupledComponents(
"equilibrium_constants")),
91 _equilibrium_constants(_num_equilibrium_constants),
92 _primary_activity_coefficients(getParam<std::vector<Real>>(
"primary_activity_coefficients")),
93 _reactions(getParam<std::vector<Real>>(
"reactions")),
94 _secondary_activity_coefficients(getParam<std::vector<Real>>(
"secondary_activity_coefficients"))
96 if (_dictator.numPhases() < 1)
97 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of fluid phases must "
102 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of "
103 "equilibrium constants is ",
105 " which must be equal to the number of reactions (",
111 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of primary activity "
114 " which must be equal to the number of primary species (",
120 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of stoichiometric "
121 "coefficients specified in 'reactions' (",
123 ") must be equal to the number of reactions (",
125 ") multiplied by the number of primary species (",
132 "PorousFlowMassFractionAqueousEquilibriumChemistry: The number of secondary activity "
135 " which must be equal to the number of secondary species (",
141 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: You have specified the number "
142 "of reactions to be ",
144 " but the Dictator knows that the number of aqueous equilibrium reactions is ",
145 _dictator.numAqueousEquilibrium());
149 : &coupledValue(
"equilibrium_constants", i));
171 if (_t_step == 0 && !_app.isRestarting())
233 const unsigned pf_wrt = _dictator.porousFlowVariableNum(
_mf_vars_num[
_aq_i + wrt]);
246 for (
unsigned v = 0; v <
_num_var; ++v)
249 for (
unsigned v = 0; v <
_num_var; ++v)
256 if (!_nodal_material)
261 (*_grad_mass_frac)[_qp][
_aq_ph][comp] = 0.0;
272 unsigned primary_num)
const
274 const unsigned index = reaction_num *
_num_primary + primary_num;
280 unsigned & zero_conc_index,
unsigned & zero_count)
const
314 _sec_conc[_qp][r] = std::numeric_limits<Real>::max();
335 unsigned reaction_num, std::vector<Real> & dsc)
const
353 unsigned zero_count = 0;
354 unsigned zero_conc_index = 0;
366 if (zero_count == 1 and
stoichiometry(reaction_num, zero_conc_index) == 1.0)
368 Real conc_without_zero = 1.0;
371 if (i == zero_conc_index)
382 dsc[zero_conc_index] = conc_without_zero;
384 else if (zero_count == 1 &&
stoichiometry(reaction_num, zero_conc_index) < 1.0)
385 dsc[zero_conc_index] = std::numeric_limits<Real>::max();
registerMooseObject("PorousFlowApp", PorousFlowMassFractionAqueousEquilibriumChemistry)
const std::vector< Real > _secondary_activity_coefficients
Activity coefficients for the secondary species.
const unsigned _num_equilibrium_constants
Number of equilibrium_constants provided.
const std::vector< Real > _reactions
Stoichiometry defining the aqeuous geochemistry equilibrium reactions.
InputParameters validParams< PorousFlowMaterialVectorBase >()
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const std::vector< Real > _primary_activity_coefficients
Activity coefficients for the primary species (dimensionless)
virtual void initQpStatefulProperties() override
Material designed to form a std::vector<std::vector> of mass fractions from primary-species concentra...
std::vector< const VariableGradient * > _grad_mf_vars
The gradient of the mass-fraction variables.
std::vector< const VariableValue * > _mf_vars
The mass-fraction variables.
MaterialProperty< std::vector< Real > > & _sec_conc
Secondary concentrations at quadpoint or nodes.
std::vector< const VariableValue * > _equilibrium_constants
Equilibrium constants (dimensionless)
void findZeroConcentration(unsigned &zero_conc_index, unsigned &zero_count) const
Checks gamp[i] = _primary_activity_coefficients[i] * (*_primary[i])[qp].
virtual void dQpSecondaryConcentration_dprimary(unsigned reaction_num, std::vector< Real > &dsc) const
Computes derivative of the secondary concentration with respect to the primary concentrations Must be...
virtual void computeQpProperties() override
MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
Mass fraction matrix at quadpoint or nodes.
const MaterialProperty< std::vector< Real > > & _dtemperature_dvar
d(temperature)/(d porflow variable)
MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
Derivative of the mass fraction matrix with respect to the porous flow variables.
MaterialProperty< std::vector< std::vector< RealGradient > > > *const _grad_mass_frac
Gradient of the mass fraction matrix at the quad points.
virtual void computeQpProperties() override
PorousFlowMassFractionAqueousEquilibriumChemistry(const InputParameters ¶meters)
const unsigned int _num_var
Number of PorousFlow variables.
const unsigned int _num_components
Number of fluid components.
Real stoichiometry(unsigned reaction_num, unsigned primary_num) const
The stoichiometric coefficient.
virtual void initQpSecondaryConcentrations()
Initialises (at _t_step = 0) the secondary concentrations.
MaterialProperty< std::vector< std::vector< Real > > > & _dsec_conc_dvar
Derivative of the secondary concentrations with respect to the porous flow variables.
const bool _equilibrium_constants_as_log10
Whether the equilibium constants are written in their log10 form, or in absolute terms.
virtual Real dQpSecondaryConcentration_dT(unsigned reaction_num) const
Computes derivative of the secondary concentration with respect to the temperature Must be overridden...
const unsigned int _num_primary
Number of primary species.
const unsigned int _aq_i
Index (into _mf_vars) of the first of the primary species.
const unsigned int _aq_ph
Aqueous phase number.
const unsigned int _num_reactions
Number of equations in the aqueous geochemistry system.
std::vector< unsigned int > _mf_vars_num
The variable number of the mass-fraction variables.
Material designed to form a std::vector<std::vector> of mass fractions from the individual mass fract...
InputParameters validParams< PorousFlowMassFractionAqueousEquilibriumChemistry >()
virtual void computeQpSecondaryConcentrations()
Compute the secondary-species concentration as defined by the chemistry Must be overridden by derived...