20 "List of variables that represent the mass fractions. For the aqueous phase these are " 21 "concentrations of the primary species with units m^{3}(chemical)/m^{3}(fluid phase). For " 22 "the other phases (if any) these will typically be initialised to zero and will not change " 23 "throughout the simulation. Format is 'f_ph0^c0 f_ph0^c1 f_ph0^c2 ... f_ph0^c(N-2) f_ph1^c0 " 24 "f_ph1^c1 fph1^c2 ... fph1^c(N-2) ... fphP^c0 f_phP^c1 fphP^c2 ... fphP^c(N-2)' where " 25 "N=number of primary species and P=num_phases, and it is assumed that " 26 "f_ph^c(N-1)=1-sum(f_ph^c,{c,0,N-2}) so that f_ph^c(N-1) need not be given.");
28 "Number of equations in the system of chemical reactions");
29 params.
addParam<
bool>(
"equilibrium_constants_as_log10",
31 "If true, the equilibrium constants are written in their log10 form, eg, " 32 "-2. If false, the equilibrium constants are written in absolute terms, " 35 "Equilibrium constant for each equation (dimensionless). If these " 36 "are temperature dependent AuxVariables, the Jacobian will not be " 39 "primary_activity_coefficients",
40 "Activity coefficients for the primary species (dimensionless) (one for each)");
43 "A matrix defining the aqueous reactions. The matrix is entered as a long vector: the first " 45 "entered first, followed by the second row, etc. There should be num_reactions rows. All " 46 "primary species should appear only on the LHS of each reaction (and there should be just " 47 "one secondary species on the RHS, by definition) so they may have negative coefficients. " 48 "Each row should have number of primary_concentrations entries, which are the stoichiometric " 49 "coefficients. The first coefficient must always correspond to the first primary species, " 52 "secondary_activity_coefficients",
53 "Activity coefficients for the secondary species (dimensionless) (one for each reaction)");
54 params.
addPrivateParam<std::string>(
"pf_material_type",
"mass_fraction");
56 "This Material forms a std::vector<std::vector ...> of mass-fractions " 57 "(total concentrations of primary species (m^{3}(primary species)/m^{3}(solution)) and since " 58 "this is for an aqueous system only, mass-fraction equals volume-fraction) corresponding to " 60 "aqueous equilibrium chemistry system. The first mass fraction is the " 61 "concentration of the first primary species, etc, and the last mass " 62 "fraction is the concentration of H2O.");
69 _sec_conc(_nodal_material
70 ? declareProperty<
std::vector<
Real>>(
"PorousFlow_secondary_concentration_nodal")
71 : declareProperty<
std::vector<
Real>>(
"PorousFlow_secondary_concentration_qp")),
72 _dsec_conc_dvar(_nodal_material ? declareProperty<
std::vector<
std::vector<
Real>>>(
73 "dPorousFlow_secondary_concentration_nodal_dvar")
74 : declareProperty<
std::vector<
std::vector<
Real>>>(
75 "dPorousFlow_secondary_concentration_qp_dvar")),
77 _temperature(_nodal_material ? getMaterialProperty<
Real>(
"PorousFlow_temperature_nodal")
78 : getMaterialProperty<
Real>(
"PorousFlow_temperature_qp")),
81 ? getMaterialProperty<
std::vector<
Real>>(
"dPorousFlow_temperature_nodal_dvar")
82 : getMaterialProperty<
std::vector<
Real>>(
"dPorousFlow_temperature_qp_dvar")),
84 _num_primary(_num_components - 1),
85 _aq_ph(_dictator.aqueousPhaseNumber()),
86 _aq_i(_aq_ph * _num_primary),
87 _num_reactions(getParam<unsigned>(
"num_reactions")),
88 _equilibrium_constants_as_log10(getParam<bool>(
"equilibrium_constants_as_log10")),
89 _num_equilibrium_constants(coupledComponents(
"equilibrium_constants")),
90 _equilibrium_constants(_num_equilibrium_constants),
91 _primary_activity_coefficients(getParam<
std::vector<
Real>>(
"primary_activity_coefficients")),
92 _reactions(getParam<
std::vector<
Real>>(
"reactions")),
93 _secondary_activity_coefficients(getParam<
std::vector<
Real>>(
"secondary_activity_coefficients"))
95 if (_dictator.numPhases() < 1)
96 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of fluid phases must " 101 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of " 102 "equilibrium constants is ",
104 " which must be equal to the number of reactions (",
110 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of primary activity " 113 " which must be equal to the number of primary species (",
119 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: The number of stoichiometric " 120 "coefficients specified in 'reactions' (",
122 ") must be equal to the number of reactions (",
124 ") multiplied by the number of primary species (",
131 "PorousFlowMassFractionAqueousEquilibriumChemistry: The number of secondary activity " 134 " which must be equal to the number of secondary species (",
140 mooseError(
"PorousFlowMassFractionAqueousEquilibriumChemistry: You have specified the number " 141 "of reactions to be ",
143 " but the Dictator knows that the number of aqueous equilibrium reactions is ",
144 _dictator.numAqueousEquilibrium());
150 const bool is_nodal = isCoupled(
"equilibrium_constants")
151 ? getFieldVar(
"equilibrium_constants", i)->isNodal()
155 (_nodal_material && is_nodal ? &coupledDofValues(
"equilibrium_constants", i)
156 : &coupledValue(
"equilibrium_constants", i));
179 if (_t_step == 0 && !_app.isRestarting())
241 const unsigned pf_wrt = _dictator.porousFlowVariableNum(
_mf_vars_num[
_aq_i + wrt]);
264 if (!_nodal_material)
269 (*_grad_mass_frac)[_qp][
_aq_ph][comp] = 0.0;
280 unsigned primary_num)
const 282 const unsigned index = reaction_num *
_num_primary + primary_num;
288 unsigned & zero_conc_index,
unsigned & zero_count)
const 322 _sec_conc[_qp][r] = std::numeric_limits<Real>::max();
343 unsigned reaction_num, std::vector<Real> & dsc)
const 361 unsigned zero_count = 0;
362 unsigned zero_conc_index = 0;
374 if (zero_count == 1 and
stoichiometry(reaction_num, zero_conc_index) == 1.0)
376 Real conc_without_zero = 1.0;
379 if (i == zero_conc_index)
390 dsc[zero_conc_index] = conc_without_zero;
392 else if (zero_count == 1 &&
stoichiometry(reaction_num, zero_conc_index) < 1.0)
393 dsc[zero_conc_index] = std::numeric_limits<Real>::max();
const bool _equilibrium_constants_as_log10
Whether the equilibium constants are written in their log10 form, or in absolute terms.
const unsigned int _num_reactions
Number of equations in the aqueous geochemistry system.
Material designed to form a std::vector<std::vector> of mass fractions from the individual mass fract...
MaterialProperty< std::vector< std::vector< std::vector< Real > > > > *const _dmass_frac_dvar
Derivative of the mass fraction matrix with respect to the porous flow variables. ...
void mooseError(Args &&... args)
static InputParameters validParams()
std::vector< unsigned int > _mf_vars_num
The variable number of the mass-fraction variables.
const std::vector< Real > _reactions
Stoichiometry defining the aqeuous geochemistry equilibrium reactions.
MaterialProperty< std::vector< Real > > & _sec_conc
Secondary concentrations at quadpoint or nodes.
virtual void computeQpProperties() override
virtual void computeQpSecondaryConcentrations()
Compute the secondary-species concentration as defined by the chemistry Must be overridden by derived...
const std::vector< Real > _primary_activity_coefficients
Activity coefficients for the primary species (dimensionless)
static InputParameters validParams()
virtual void computeQpProperties() override
virtual void resize(const std::size_t size) override final
virtual Real dQpSecondaryConcentration_dT(unsigned reaction_num) const
Computes derivative of the secondary concentration with respect to the temperature Must be overridden...
void findZeroConcentration(unsigned &zero_conc_index, unsigned &zero_count) const
Checks gamp[i] = _primary_activity_coefficients[i] * (*_primary[i])[qp].
Real stoichiometry(unsigned reaction_num, unsigned primary_num) const
The stoichiometric coefficient.
const MaterialProperty< std::vector< Real > > & _dtemperature_dvar
d(temperature)/(d porflow variable)
const unsigned int _num_components
Number of fluid components.
GenericMaterialProperty< std::vector< std::vector< RealGradient > >, is_ad > *const _grad_mass_frac
Gradient of the mass fraction matrix at the quad points.
GenericMaterialProperty< std::vector< std::vector< Real > >, is_ad > & _mass_frac
Mass fraction matrix at quadpoint or nodes.
std::vector< const GenericVariableGradient< is_ad > * > _grad_mf_vars
The gradient of the mass-fraction variables.
virtual void initQpStatefulProperties() override
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...
const unsigned int _aq_ph
Aqueous phase number.
const unsigned int _num_var
Number of PorousFlow variables.
const unsigned int _aq_i
Index (into _mf_vars) of the first of the primary species.
PorousFlowMassFractionAqueousEquilibriumChemistry(const InputParameters ¶meters)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
virtual void initQpSecondaryConcentrations()
Initialises (at _t_step = 0) the secondary concentrations.
const unsigned _num_equilibrium_constants
Number of equilibrium_constants provided.
const unsigned int _num_primary
Number of primary species.
std::vector< const GenericVariableValue< is_ad > * > _mf_vars
The mass-fraction variables.
Material designed to form a std::vector<std::vector> of mass fractions from primary-species concentra...
std::vector< const VariableValue * > _equilibrium_constants
Equilibrium constants (dimensionless)
MooseUnits pow(const MooseUnits &, int)
registerMooseObject("PorousFlowApp", PorousFlowMassFractionAqueousEquilibriumChemistry)
MaterialProperty< std::vector< std::vector< Real > > > & _dsec_conc_dvar
Derivative of the secondary concentrations with respect to the porous flow variables.
const std::vector< Real > _secondary_activity_coefficients
Activity coefficients for the secondary species.