https://mooseframework.inl.gov
Loading...
Searching...
No Matches
GeochemistryTimeDependentReactor.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
13
16{
18 params.addParam<unsigned>(
19 "ramp_max_ionic_strength_subsequent",
20 0,
21 "The number of iterations over which to progressively increase the maximum ionic strength "
22 "(from zero to max_ionic_strength) during time-stepping. Unless a great deal occurs in each "
23 "time step, this parameter can be set quite small");
24 params.addCoupledVar(
25 "mode",
26 0.0,
27 "This may vary temporally. If mode=1 then 'dump' mode is used, which means all non-kinetic "
28 "mineral masses are removed from the system before the equilibrium solution is sought (ie, "
29 "removal occurs at the beginning of the time step). If mode=2 then 'flow-through' mode is "
30 "used, which means all mineral masses are removed from the system after it the "
31 "equilbrium solution has been found (ie, at the end of a time step). If mode=3 then 'flush' "
32 "mode is used, then before the equilibrium solution is sought (ie, at the start of a time "
33 "step) water+species is removed from the system at the same rate as pure water + non-mineral "
34 "solutes are entering the system (specified in source_species_rates). If mode=4 then "
35 "'heat-exchanger' mode is used, which means the entire current aqueous solution is removed, "
36 "then the source_species are added, then the temperature is set to 'cold_temperature', the "
37 "system is solved and any precipitated minerals are removed, then the temperature is set to "
38 "'temperature', the system re-solved and any precipitated minerals are removed. If mode is "
39 "any other number, no special mode is active (the system simply responds to the "
40 "source_species_rates, controlled_activity_value, etc).");
41 params.addCoupledVar(
42 "temperature",
43 25,
44 "Temperature. This has two different meanings if mode!=4. (1) If no species are being "
45 "added to the solution (no source_species_rates are positive) then this is the temperature "
46 "of the aqueous solution. (2) If species are being added, this is the temperature of the "
47 "species being added. In case (2), the final aqueous-solution temperature is computed "
48 "assuming the species are added, temperature is equilibrated and then, if species are also "
49 "being removed, they are removed. If you wish to add species and simultaneously alter the "
50 "temperature, you will have to use a sequence of heat-add-heat-add, etc steps. In the case "
51 "that mode=4, temperature is the final temperature of the aqueous solution");
52 params.addCoupledVar(
53 "cold_temperature",
54 25,
55 "This is only used if mode=4, where it is the cold temperature of the heat exchanger.");
56 params.addRangeCheckedParam<unsigned>(
57 "heating_increments",
58 1,
59 "heating_increments > 0",
60 "This is only used if mode=4. Internal to this object, the temperature is ramped from "
61 "cold_temperature to temperature in heating_increments increments. This helps difficult "
62 "problems converge");
63 params.addParam<Real>("initial_temperature",
64 25.0,
65 "The initial aqueous solution is equilibrated at this system before adding "
66 "reactants, changing temperature, etc.");
67 params.addParam<Real>("close_system_at_time",
68 0.0,
69 "Time at which to 'close' the system, that is, change a kg_solvent_water "
70 "constraint to moles_bulk_water, and all free_molality and "
71 "free_moles_mineral_species to moles_bulk_species");
72 params.addParam<std::vector<std::string>>(
73 "remove_fixed_activity_name",
74 {},
75 "The name of the species that should have their activity or fugacity constraint removed at "
76 "time given in remove_fixed_activity_time. There should be an equal number of these names "
77 "as times given in remove_fixed_activity_time. Each of these must be in the basis and have "
78 "an activity or fugacity constraint");
79 params.addParam<std::vector<Real>>("remove_fixed_activity_time",
80 {},
81 "The times at which the species in remove_fixed_activity_name "
82 "should have their activity or fugacity constraint removed.");
83 params.addParam<std::vector<std::string>>(
84 "source_species_names",
85 {},
86 "The name of the species that are added at rates given in source_species_rates. There must "
87 "be an equal number of these as source_species_rates.");
88 params.addCoupledVar("source_species_rates",
89 "Rates, in mols/time_unit, of addition of the species with names given in "
90 "source_species_names. A negative value corresponds to removing a species: "
91 "be careful that you don't cause negative mass problems!");
92 params.addParam<std::vector<std::string>>(
93 "controlled_activity_name",
94 {},
95 "The names of the species that have their activity or fugacity constrained. There should be "
96 "an equal number of these names as values given in controlled_activity_value. NOTE: if "
97 "these species are not in the basis, or they do not have an activity (or fugacity) "
98 "constraint then their activity cannot be controlled: in this case MOOSE will ignore the "
99 "value you prescribe in controlled_activity_value.");
100 params.addCoupledVar("controlled_activity_value",
101 "Values of the activity or fugacity of the species in "
102 "controlled_activity_name list. These should always be positive");
103 params.addParam<bool>(
104 "evaluate_kinetic_rates_always",
105 true,
106 "If true, then, evaluate the kinetic rates at every Newton step during the solve using the "
107 "current values of molality, activity, etc (ie, implement an implicit solve). If false, "
108 "then evaluate the kinetic rates using the values of molality, activity, etc, at the start "
109 "of the current time step (ie, implement an explicit solve)");
110 params.addParam<std::vector<std::string>>(
111 "kinetic_species_name",
112 {},
113 "Names of the kinetic species given initial values in kinetic_species_initial_value");
114 params.addParam<std::vector<Real>>(
115 "kinetic_species_initial_value",
116 {},
117 "Initial number of moles, mass or volume (depending on kinetic_species_unit) for each of the "
118 "species named in kinetic_species_name");
119 MultiMooseEnum kin_species_unit("dimensionless moles molal kg g mg ug kg_per_kg_solvent "
120 "g_per_kg_solvent mg_per_kg_solvent ug_per_kg_solvent cm3");
121 params.addParam<MultiMooseEnum>(
122 "kinetic_species_unit",
123 kin_species_unit,
124 "Units of the numerical values given in kinetic_species_initial_value. Moles: mole number. "
125 "kg: kilograms. g: grams. mg: milligrams. ug: micrograms. cm3: cubic centimeters");
126 return params;
127}
128
131{
134 params.addClassDescription("UserObject that controls the time-dependent geochemistry reaction "
135 "processes. Spatial dependence is not possible using this class");
136 return params;
137}
138
140 const InputParameters & parameters)
141 : GeochemistryReactorBase(parameters),
142 _temperature(coupledValue("temperature")),
143 _cold_temperature(coupledValue("cold_temperature")),
144 _heating_increments(getParam<unsigned>("heating_increments")),
145 _new_temperature(getParam<Real>("initial_temperature")),
146 _previous_temperature(getParam<Real>("initial_temperature")),
147 _egs(_mgd,
148 _gac,
149 _is,
150 _swapper,
151 getParam<std::vector<std::string>>("swap_out_of_basis"),
152 getParam<std::vector<std::string>>("swap_into_basis"),
153 getParam<std::string>("charge_balance_species"),
154 getParam<std::vector<std::string>>("constraint_species"),
155 getParam<std::vector<Real>>("constraint_value"),
156 getParam<MultiMooseEnum>("constraint_unit"),
157 getParam<MultiMooseEnum>("constraint_meaning"),
158 _previous_temperature,
159 getParam<unsigned>("extra_iterations_to_make_consistent"),
160 getParam<Real>("min_initial_molality"),
161 getParam<std::vector<std::string>>("kinetic_species_name"),
162 getParam<std::vector<Real>>("kinetic_species_initial_value"),
163 getParam<MultiMooseEnum>("kinetic_species_unit")),
164 _solver(_mgd.basis_species_name.size(),
165 _mgd.kin_species_name.size(),
166 _is,
167 getParam<Real>("abs_tol"),
168 getParam<Real>("rel_tol"),
169 getParam<unsigned>("max_iter"),
170 getParam<Real>("max_initial_residual"),
171 _small_molality,
172 _max_swaps_allowed,
173 getParam<std::vector<std::string>>("prevent_precipitation"),
174 getParam<Real>("max_ionic_strength"),
175 getParam<unsigned>("ramp_max_ionic_strength_initial"),
176 getParam<bool>("evaluate_kinetic_rates_always")),
177 _num_kin(_egs.getNumKinetic()),
178 _close_system_at_time(getParam<Real>("close_system_at_time")),
179 _closed_system(false),
180 _source_species_names(getParam<std::vector<std::string>>("source_species_names")),
181 _num_source_species(_source_species_names.size()),
182 _source_species_rates(coupledValues("source_species_rates")),
183 _remove_fixed_activity_name(getParam<std::vector<std::string>>("remove_fixed_activity_name")),
184 _remove_fixed_activity_time(getParam<std::vector<Real>>("remove_fixed_activity_time")),
185 _num_removed_fixed(_remove_fixed_activity_name.size()),
186 _removed_fixed_activity(_num_removed_fixed, false),
187 _controlled_activity_species_names(
188 getParam<std::vector<std::string>>("controlled_activity_name")),
189 _num_controlled_activity(_controlled_activity_species_names.size()),
190 _controlled_activity_species_values(coupledValues("controlled_activity_value")),
191 _mole_additions(_num_basis + _num_kin),
192 _dmole_additions(_num_basis + _num_kin, _num_basis + _num_kin),
193 _mode(coupledValue("mode")),
194 _minerals_dumped(),
195 _ramp_subsequent(getParam<unsigned>("ramp_max_ionic_strength_subsequent"))
196{
197 // check sources and set the rates
198 if (coupledComponents("source_species_rates") != _num_source_species)
199 paramError("source_species_names", "must have the same size as source_species_rates");
200 for (unsigned i = 0; i < _num_source_species; ++i)
201 if (!(_mgd.basis_species_index.count(_source_species_names[i]) == 1 ||
204 paramError("source_species_names",
205 "The name " + _source_species_names[i] +
206 " does not appear in the basis, equilibrium or kinetic species list");
207
208 // check and set activity controllers
209 for (unsigned i = 0; i < _num_removed_fixed; ++i)
210 {
213 "remove_fixed_activity_name",
214 "The species ",
216 " is not in the basis, so cannot have its activity or fugacity constraint removed");
217 else
218 {
219 const unsigned basis_ind = _mgd.basis_species_index.at(_remove_fixed_activity_name[i]);
223 paramError("remove_fixed_activity_name",
224 "The species ",
226 " is does not have an activity or fugacity constraint so cannot have such a "
227 "constraint removed");
228 }
229 }
231 paramError("remove_fixed_activity_name",
232 "must be of the same size as remove_fixed_activity_time");
233 if (coupledComponents("controlled_activity_value") != _num_controlled_activity)
234 paramError("controlled_activity_name", "must have the same size as controlled_activity_value");
235
236 // record coupled variables
237 const std::vector<MooseVariableFEBase *> & coupled_vars = getCoupledMooseVars();
238 for (unsigned int i = 0; i < coupled_vars.size(); i++)
239 addMooseVariableDependency(coupled_vars[i]);
240
241 // setup minerals_dumped
242 for (unsigned i = 0; i < _mgd.basis_species_name.size(); ++i)
245 for (unsigned j = 0; j < _mgd.eqm_species_name.size(); ++j)
248 for (unsigned k = 0; k < _mgd.kin_species_name.size(); ++k)
251}
252
253void
258void
263
264void
266{
267 // solve the geochemical system with its initial composition and with dt=0 so no kinetic additions
268 if (_num_my_nodes == 0)
269 return; // rather peculiar case where user has used many processors
270 _mole_additions.zero();
274 _tot_iter[0],
275 _abs_residual[0],
276 0.0,
279}
280
281void
283{
284 if (_current_node->id() != 0)
285 return;
286
288
289 _mole_additions.zero();
291
292 // remove appropriate constraints
294 {
296 _closed_system = true;
297 }
298 for (unsigned i = 0; i < _num_removed_fixed; ++i)
299 {
301 {
304 _removed_fixed_activity[i] = true;
305 }
306 }
307
308 // control activity
309 for (unsigned ca = 0; ca < _num_controlled_activity; ++ca)
310 {
311 const std::vector<GeochemicalSystem::ConstraintMeaningEnum> & cm = _egs.getConstraintMeaning();
313 {
314 const unsigned basis_ind =
319 }
320 }
321
322 // compute moles added
323 for (unsigned i = 0; i < _num_source_species; ++i)
324 {
325 const Real this_rate = (*_source_species_rates[i])[0];
327 {
328 const unsigned basis_ind = _mgd.basis_species_index.at(_source_species_names[i]);
329 _mole_additions(basis_ind) += this_rate;
330 }
332 {
333 const unsigned eqm_j = _mgd.eqm_species_index.at(_source_species_names[i]);
334 for (unsigned basis_ind = 0; basis_ind < _num_basis; ++basis_ind)
335 _mole_additions(basis_ind) += _mgd.eqm_stoichiometry(eqm_j, basis_ind) * this_rate;
336 }
337 else
338 {
339 const unsigned kin_ind = _mgd.kin_species_index.at(_source_species_names[i]);
340 _mole_additions(_num_basis + kin_ind) += this_rate;
341 }
342 }
343 for (unsigned i = 0; i < _num_basis + _num_kin; ++i)
344 _mole_additions(i) *= _dt;
345
346 // activate special modes
347 if (_mode[0] == 1.0)
348 preSolveDump();
349 else if (_mode[0] == 3.0)
351 else if (_mode[0] == 4.0)
352 {
355 }
356 else // nothing special: simply compute the desired temperature
358
359 // set temperature, if necessary
361 {
364 }
366
367 // solve the geochemical system
370 _tot_iter[0],
371 _abs_residual[0],
372 _dt,
375
376 // activate special modes
377 if (_mode[0] == 2.0)
379 else if (_mode[0] == 4.0)
381}
382
383const GeochemicalSystem &
385{
386 return _egs;
387}
388
389const DenseVector<Real> &
391{
392 return _mole_additions;
393}
394
395const std::stringstream &
397{
398 return _solver_output[0];
399}
400
401unsigned
403{
404 return _tot_iter[0];
405}
406
407Real
409{
410 return _abs_residual[0];
411}
412
413Real
415 const std::string & species) const
416{
417 if (_minerals_dumped.count(species) == 1)
418 return _minerals_dumped.at(species);
419 return 0.0;
420}
421
422Real
423GeochemistryTimeDependentReactor::newTemperature(const DenseVector<Real> & mole_additions) const
424{
426 return _temperature[0];
427
428 // if no reactants are being added, the system temperature will be _temperature[0]
429 bool any_additions = false;
430 for (unsigned i = 0; i < _num_basis + _num_kin; ++i)
431 if (mole_additions(i) > 0)
432 {
433 any_additions = true;
434 break;
435 }
436 if (!any_additions)
437 return _temperature[0];
438
439 // assume heat capacities of inputs and outputs are the same, so final temperature is dictated
440 // by masses, also assume that the input happens first, then temperature equilibration, then
441 // the outputs occur
442 Real new_temperature = _temperature[0];
443 const std::vector<Real> & current_bulk = _egs.getBulkMolesOld();
444 Real current_kg = current_bulk[0] / GeochemistryConstants::MOLES_PER_KG_WATER;
445 Real input_kg = std::max(mole_additions(0), 0.0) / GeochemistryConstants::MOLES_PER_KG_WATER;
446 for (unsigned i = 1; i < _num_basis; ++i)
447 {
448 current_kg += current_bulk[i] * _mgd.basis_species_molecular_weight[i] / 1000.0;
449 input_kg += std::max(mole_additions(i), 0.0) * _mgd.basis_species_molecular_weight[i] / 1000.0;
450 }
451 for (unsigned k = 0; k < _num_kin; ++k)
452 input_kg += std::max(mole_additions(k + _num_basis), 0.0) *
454 new_temperature =
455 (_previous_temperature * current_kg + _temperature[0] * input_kg) / (current_kg + input_kg);
456 return new_temperature;
457}
458
459void
461{
462 // remove basis mineral moles
463 const std::vector<Real> & current_molal = _egs.getSolventMassAndFreeMolalityAndMineralMoles();
464 for (unsigned i = 1; i < _num_basis; ++i)
466 {
467 _mole_additions(i) = -current_molal[i]; // might overwrite the rates set above, which is good
468 _minerals_dumped[_mgd.basis_species_name[i]] += current_molal[i];
469 }
470
472
473 // add the chemicals immediately instead of during the solve (as occurs for other modes)
474 for (unsigned basis_ind = 0; basis_ind < _num_basis; ++basis_ind)
475 {
476 _egs.addToBulkMoles(basis_ind, _mole_additions(basis_ind));
477 _mole_additions(basis_ind) = 0.0;
478 }
479 // dump needs free mineral moles to be exactly zero and the above addToBulkMoles will have set
480 // this for standard minerals, but not things related to sorption or kinetic minerals, so:
482
483 // Now need to swap all minerals out of the basis
484 const std::vector<Real> & eqm_molality = _egs.getEquilibriumMolality();
485 unsigned swap_into_basis = 0;
486 for (unsigned i = 0; i < _num_basis; ++i)
488 {
489 const bool legitimate_swap_found = _egs.getSwapper().findBestEqmSwap(
490 i, _mgd, eqm_molality, false, false, false, swap_into_basis);
491 if (legitimate_swap_found)
492 {
493 try
494 {
495 _egs.performSwap(i, swap_into_basis);
496 }
497 catch (const MooseException & e)
498 {
499 mooseError(e.what());
500 }
501 }
502 }
503}
504
505void
507{
509
510 // Here we conserve mass, so compute the mass of the solution, without the free mineral moles.
511 // We don't include the free mineral moles because users of GeochemistWorkbench will want
512 // "flush" to operate like Bethke Eqn(13.14)
513 // I assume we also don't include kinetic-mineral moles
515 for (unsigned i = 1; i < _num_basis; ++i)
517 kg_in += _mole_additions(i) * _mgd.basis_species_molecular_weight[i] / 1000.0;
518 for (unsigned kin = 0; kin < _num_kin; ++kin)
519 if (!_mgd.kin_species_mineral[kin])
520 kg_in += _mole_additions(kin + _num_basis) * _mgd.kin_species_molecular_weight[kin] / 1000.0;
521
522 const std::vector<Real> & current_bulk = _egs.getBulkMolesOld();
523 const std::vector<Real> & current_molal = _egs.getSolventMassAndFreeMolalityAndMineralMoles();
524 const std::vector<Real> & kin_moles = _egs.getKineticMoles();
525
526 // compute the current mass, without moles from free minerals and without kinetic minerals
527 Real current_kg = current_bulk[0] / GeochemistryConstants::MOLES_PER_KG_WATER;
528 for (unsigned i = 1; i < _num_basis; ++i)
529 {
530 Real kinetic_contribution = 0.0;
531 for (unsigned k = 0; k < _num_kin; ++k)
533 kinetic_contribution += kin_moles[k] * _mgd.kin_stoichiometry(k, i);
535 current_kg += (current_bulk[i] - current_molal[i] - kinetic_contribution) *
537 else
538 current_kg += (current_bulk[i] - kinetic_contribution) *
540 }
541
542 const Real fraction_to_remove = kg_in / current_kg;
543 for (unsigned i = 0; i < _num_basis; ++i)
544 {
545 Real all_kinetic_contribution = 0.0;
546 for (unsigned k = 0; k < _num_kin; ++k)
547 all_kinetic_contribution += kin_moles[k] * _mgd.kin_stoichiometry(k, i);
549 _mole_additions(i) -=
550 fraction_to_remove * (current_bulk[i] - current_molal[i] - all_kinetic_contribution);
551 else
552 _mole_additions(i) -= fraction_to_remove * (current_bulk[i] - all_kinetic_contribution);
553 }
554 for (unsigned k = 0; k < _num_kin; ++k)
556 _mole_additions(k + _num_basis) -= fraction_to_remove * kin_moles[k];
557}
558
559void
561{
562 // copy the current_molal values into a new vector
563 const std::vector<Real> current_molal = _egs.getSolventMassAndFreeMolalityAndMineralMoles();
564 // remove minerals
565 for (unsigned i = 1; i < _num_basis; ++i)
567 {
568 const Real to_remove = current_molal[i] - _small_molality * 10.0;
569 _egs.addToBulkMoles(i, -to_remove);
571 }
572
573 // copy the current kinetic moles into a new vector
574 const std::vector<Real> kin_moles = _egs.getKineticMoles();
575 // remove minerals
576 for (unsigned k = 0; k < _num_kin; ++k)
578 {
579 const Real to_remove = kin_moles[k] - _small_molality;
580 for (unsigned i = 0; i < _num_basis; ++i)
581 if (_mgd.kin_stoichiometry(k, i) != 0)
583 -_mgd.kin_stoichiometry(k, i) *
584 to_remove); // remember bulk moles contains kinetic contributions
586 _minerals_dumped[_mgd.kin_species_name[k]] += to_remove;
587 }
588
590}
591
592void
594{
595 const std::vector<Real> & current_bulk = _egs.getBulkMolesOld();
596 for (unsigned i = 0; i < _num_basis; ++i)
597 _mole_additions(i) -= current_bulk[i];
598 const std::vector<Real> & kin_moles = _egs.getKineticMoles();
599 for (unsigned k = 0; k < _num_kin; ++k)
600 _mole_additions(k + _num_basis) -= kin_moles[k];
601}
602
603void
605{
606 // remove precipitates
608
609 DenseVector<Real> zero_mole_additions(_num_basis + _num_kin);
610 DenseMatrix<Real> zero_dmole_additions(_num_basis + _num_kin, _num_basis + _num_kin);
611
612 const Real del_temperature = (_temperature[0] - _previous_temperature) / _heating_increments;
613
614 for (unsigned incr = 0; incr < _heating_increments; ++incr)
615 {
616 // set temperature
617 _new_temperature = _previous_temperature + del_temperature;
621
622 zero_mole_additions.zero();
623 zero_dmole_additions.zero();
624
625 // solve the geochemical system
628 _tot_iter[0],
629 _abs_residual[0],
630 _dt,
631 zero_mole_additions,
632 zero_dmole_additions);
633
634 // remove precipitates
636 }
637}
registerMooseObject("GeochemistryApp", GeochemistryTimeDependentReactor)
InputParameters emptyInputParameters()
const std::vector< MooseVariableFieldBase * > & getCoupledMooseVars() const
unsigned int coupledComponents(const std::string &var_name) const
void solveSystem(GeochemicalSystem &egs, std::stringstream &ss, unsigned &tot_iter, Real &abs_residual, Real dt, DenseVector< Real > &mole_additions, DenseMatrix< Real > &dmole_additions)
Solve the system.
void setRampMaxIonicStrength(unsigned ramp_max_ionic_strength)
Sets the value of _ramp_max_ionic_strength.
This class holds information about bulk composition, molalities, activities, activity coefficients,...
const std::vector< GeochemicalSystem::ConstraintMeaningEnum > & getConstraintMeaning() const
const GeochemistrySpeciesSwapper & getSwapper() const
void setMineralRelatedFreeMoles(Real value)
Set the free mole number of mineral-related species to the value provided.
void setKineticMoles(unsigned kin, Real moles)
Sets the current AND old mole number for a kinetic species.
void computeConsistentConfiguration()
Compute a reasonably consistent configuration that can be used as an initial condition in a Newton pr...
void changeConstraintToBulk(unsigned basis_ind)
Changes the constraint to MOLES_BULK_SPECIES (or MOLES_BULK_WATER if basis_ind = 0) for the basis ind...
void performSwap(unsigned swap_out_of_basis, unsigned swap_into_basis)
Perform the basis swap, and ensure that the resulting system is consistent.
Real getKineticMoles(unsigned kin) const
void addToBulkMoles(unsigned basis_ind, Real value)
Add to the MOLES_BULK_SPECIES (or MOLES_BULK_WATER if basis_ind = 0) for the basis species.
void setConstraintValue(unsigned basis_ind, Real value)
Set the constraint value for the basis species.
const std::vector< Real > & getBulkMolesOld() const
const std::vector< Real > & getSolventMassAndFreeMolalityAndMineralMoles() const
ConstraintMeaningEnum
Each basis species has one of the following constraints.
void closeSystem()
Changes a KG_SOLVENT_WATER constraint to MOLES_BULK_WATER (if there is such a constraint) and all FRE...
Real getEquilibriumMolality(unsigned j) const
void setTemperature(Real temperature)
Sets the temperature to the given quantity.
Base class that controls the spatio-temporal solution of geochemistry reactions.
virtual void finalize() override
std::vector< unsigned > _tot_iter
Number of iterations used by the solver at each node.
virtual void initialize() override
static InputParameters validParams()
const unsigned _num_my_nodes
Number of nodes handled by this processor (will need to be made un-const when mesh adaptivity is hand...
std::vector< Real > _abs_residual
L1norm of the solver residual at each node.
const unsigned _num_basis
number of basis species
ModelGeochemicalDatabase _mgd
my copy of the underlying ModelGeochemicalDatabase
std::vector< std::stringstream > _solver_output
The solver output at each node.
const Real _small_molality
A small value of molality.
bool findBestEqmSwap(unsigned basis_ind, const ModelGeochemicalDatabase &mgd, const std::vector< Real > &eqm_molality, bool minerals_allowed, bool gas_allowed, bool sorption_allowed, unsigned &best_eqm_species) const
For the the given basis index, find the equilibrium index that it should be swapped with.
Class that controls the time-dependent (but not space-dependent) geochemistry reactions.
const unsigned _ramp_subsequent
the ramp_max_ionic_strength to use during time-stepping
const VariableValue & _cold_temperature
Cold temperature specified by user, which is used only when mode==4.
const unsigned _heating_increments
If mode=4 then temperature is ramped from _cold_temperature to _temperature in heating_increments inc...
virtual const GeochemicalSystem & getGeochemicalSystem(dof_id_type node_id) const override
Real _previous_temperature
Temperature at which the _egs was last made consistent.
std::unordered_map< std::string, Real > _minerals_dumped
Moles of mineral removed by dump and flow-through.
void postSolveExchanger()
This is relevant for mode=4 simulations (heat-exchanger simulations).
const unsigned _num_controlled_activity
Number of species with controlled activity or fugacity.
Real newTemperature(const DenseVector< Real > &mole_additions) const
Based on _temperature[0], mole_additions, the current mass of the system and the current temperature ...
const std::vector< const VariableValue * > _source_species_rates
Rates of the source species.
const unsigned _num_source_species
Number of source species.
DenseMatrix< Real > _dmole_additions
Derivative of moles_added.
void preSolveFlush()
Activate the special "flush" mode prior to solving the geochemical system:
const std::vector< Real > _remove_fixed_activity_time
Times at which to remove the fixed activity or fugacity from the species in _remove_fixed_activity_na...
const VariableValue & _temperature
Temperature specified by user.
void postSolveFlowThrough()
Activate the special "flow-through" mode after solving the geochemical system:
static InputParameters sharedParams()
params that are shared with AddTimeDependentReactionSolverAction
const std::vector< std::string > _controlled_activity_species_names
Names of the species with controlled activity or fugacity.
virtual const DenseVector< Real > & getMoleAdditions(dof_id_type node_id) const override
void removeCurrentSpecies()
Alter _mole_additions so that it will represent the situation in which all current species are remove...
const std::vector< std::string > _remove_fixed_activity_name
Names of species to remove the fixed activity or fugacity constraint from.
virtual Real getMolesDumped(dof_id_type node_id, const std::string &species) const override
const unsigned _num_kin
Number of kinetic species.
const unsigned _num_removed_fixed
Number of elements in the vector _remove_fixed_activity_name;.
bool _closed_system
Whether the system has been closed.
GeochemistryTimeDependentReactor(const InputParameters &parameters)
DenseVector< Real > _mole_additions
Moles of each basis species added at the current timestep, along with kinetic rates.
const Real _close_system_at_time
Defines the time at which to close the system.
virtual const std::stringstream & getSolverOutput(dof_id_type node_id) const override
virtual unsigned getSolverIterations(dof_id_type node_id) const override
const std::vector< std::string > _source_species_names
Names of the source species.
void preSolveDump()
Activate the special "dump" mode prior to solving the geochemical system:
std::vector< bool > _removed_fixed_activity
Whether the activity or activity constraint has been removfed.
const VariableValue & _mode
Mode of the system (flush, flow-through, etc)
const std::vector< const VariableValue * > _controlled_activity_species_values
Activity or fugacity of the species with controlled activity or fugacity.
Real _new_temperature
Temperature at which the solution is required.
virtual Real getSolverResidual(dof_id_type node_id) const override
GeochemicalSystem _egs
The equilibrium geochemical system that holds all the molalities, activities, etc.
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
virtual const char * what() const
void addMooseVariableDependency(MooseVariableFieldBase *var)
const Node *const & _current_node
virtual void zero() override final
std::vector< bool > eqm_species_mineral
eqm_species_mineral[i] = true iff the i^th equilibrium species is a mineral
DenseMatrix< Real > eqm_stoichiometry
eqm_stoichiometry(i, j) = stoichiometric coefficient for equilibrium species "i" in terms of the basi...
std::vector< Real > basis_species_molecular_weight
all quantities have a molecular weight (g)
DenseMatrix< Real > kin_stoichiometry
kin_stoichiometry(i, j) = stoichiometric coefficient for kinetic species "i" in terms of the basis sp...
std::vector< bool > kin_species_mineral
kin_species_mineral[j] = true iff the j^th kinetic species is a mineral
std::vector< std::string > kin_species_name
kin_species_name[j] = name of the j^th kinetic species
std::vector< bool > basis_species_mineral
basis_species_mineral[j] = true iff the j^th basis species is a mineral
std::unordered_map< std::string, unsigned > eqm_species_index
eqm_species_index[name] = index of the equilibrium species (secondary aqueous species,...
std::vector< std::string > basis_species_name
basis_species_name[j] = name of the j^th basis species
std::unordered_map< std::string, unsigned > basis_species_index
basis_species_index[name] = index of the basis species, within all ModelGeochemicalDatabase internal ...
std::unordered_map< std::string, unsigned > kin_species_index
kin_species_index[name] = index of the kinetic species, within all ModelGeochemicalDatabase internal ...
std::vector< std::string > eqm_species_name
eqm_species_name[i] = name of the i^th eqm species
std::vector< Real > kin_species_molecular_weight
all quantities have a molecular weight (g/mol)