![]() |
OGS
|
|
Drives the chemistry step in the operator-split reactive transport loop.
Per timestep:
chemical_system_id, store the transported totals \(c_{T\alpha}\), the current porous-medium state (porosity, mineral fractions, reactive surface area), and the process variables (e.g. temperature \(T\), pressure \(p\), time \(t\), and timestep \(\Delta t\)) in the corresponding ChemicalSystem. Each chemical_system_id is treated as one local batch reactor.chemical_system_id, run PHREEQC via IPhreeqc, and obtain the reacted state after advancing chemistry over \(\Delta t\):Accessors:
Internal data:
chemical_system_id definition (aqueous solution, kinetic and equilibrium reactants, exchangers, surface sites).Definition at line 110 of file PhreeqcIO.h.
#include <PhreeqcIO.h>
Public Member Functions | |
| PhreeqcIO (MeshLib::Mesh const &mesh, GlobalLinearSolver &linear_solver, std::string const &project_file_name, std::string &&database, std::unique_ptr< ChemicalSystem > &&chemical_system, std::vector< ReactionRate > &&reaction_rates, std::unique_ptr< UserPunch > &&user_punch, std::unique_ptr< Output > &&output, std::unique_ptr< Dump > &&dump, Knobs &&knobs) | |
| ~PhreeqcIO () | |
| void | initialize () override |
| void | initializeChemicalSystemConcrete (std::vector< double > const &concentrations, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Medium const &medium, ParameterLib::SpatialPosition const &pos, double const t) override |
| void | setChemicalSystemConcrete (std::vector< double > const &concentrations, GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Medium const *medium, MaterialPropertyLib::VariableArray const &vars, ParameterLib::SpatialPosition const &pos, double const t, double const dt) override |
| void | setAqueousSolutionsPrevFromDumpFile () override |
| void | executeSpeciationCalculation (double const dt) override |
| double | getConcentration (int const component_id, GlobalIndexType const chemical_system_id) const override |
| void | updateVolumeFractionPostReaction (GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Medium const &medium, ParameterLib::SpatialPosition const &pos, double const porosity, double const t, double const dt) override |
| void | updatePorosityPostReaction (GlobalIndexType const &chemical_system_id, MaterialPropertyLib::Medium const &medium, double &porosity) override |
| void | computeSecondaryVariable (std::size_t const ele_id, std::vector< GlobalIndexType > const &chemical_system_indices) override |
| std::vector< std::string > const | getComponentList () const override |
| Public Member Functions inherited from ChemistryLib::ChemicalSolverInterface | |
| ChemicalSolverInterface (MeshLib::Mesh const &mesh, GlobalLinearSolver &linear_solver_) | |
| std::vector< std::size_t > const & | activeElementIDs () const |
| virtual Eigen::SparseMatrix< double > const * | getStoichiometricMatrix () const |
| virtual double | getKineticPrefactor (std::size_t reaction_id) const |
| virtual | ~ChemicalSolverInterface ()=default |
Public Attributes | |
| std::string const | _phreeqc_input_file |
| Public Attributes inherited from ChemistryLib::ChemicalSolverInterface | |
| std::vector< GlobalIndexType > | chemical_system_index_map |
| MeshLib::Mesh const & | _mesh |
| GlobalLinearSolver & | linear_solver |
Private Member Functions | |
| void | writeInputsToFile (double const dt) |
| void | callPhreeqc () const |
| void | readOutputsFromFile () |
| PhreeqcIO & | operator<< (double const dt) |
Private Attributes | |
| std::string const | _database |
| std::unique_ptr< ChemicalSystem > | _chemical_system |
| std::vector< ReactionRate > const | _reaction_rates |
| std::unique_ptr< UserPunch > | _user_punch |
| std::unique_ptr< Output > const | _output |
| std::unique_ptr< Dump > const | _dump |
| Knobs const | _knobs |
| double | _dt = std::numeric_limits<double>::quiet_NaN() |
| const int | phreeqc_instance_id = 0 |
| std::size_t | _num_chemical_systems = -1 |
Friends | |
| std::ostream & | operator<< (std::ostream &os, PhreeqcIO const &phreeqc_io) |
| std::istream & | operator>> (std::istream &in, PhreeqcIO &phreeqc_io) |
| ChemistryLib::PhreeqcIOData::PhreeqcIO::PhreeqcIO | ( | MeshLib::Mesh const & | mesh, |
| GlobalLinearSolver & | linear_solver, | ||
| std::string const & | project_file_name, | ||
| std::string && | database, | ||
| std::unique_ptr< ChemicalSystem > && | chemical_system, | ||
| std::vector< ReactionRate > && | reaction_rates, | ||
| std::unique_ptr< UserPunch > && | user_punch, | ||
| std::unique_ptr< Output > && | output, | ||
| std::unique_ptr< Dump > && | dump, | ||
| Knobs && | knobs ) |
Definition at line 258 of file PhreeqcIO.cpp.
References ChemistryLib::ChemicalSolverInterface::ChemicalSolverInterface(), _chemical_system, _database, _dump, _knobs, _output, _phreeqc_input_file, _reaction_rates, _user_punch, ChemistryLib::ChemicalSolverInterface::linear_solver, OGS_FATAL, phreeqc_instance_id, and ChemistryLib::PhreeqcIOData::specifyFileName().
Referenced by operator<<(), operator<<, and operator>>.
| ChemistryLib::PhreeqcIOData::PhreeqcIO::~PhreeqcIO | ( | ) |
Definition at line 311 of file PhreeqcIO.cpp.
References phreeqc_instance_id.
|
private |
Definition at line 644 of file PhreeqcIO.cpp.
References _phreeqc_input_file, INFO(), OGS_FATAL, and phreeqc_instance_id.
Referenced by executeSpeciationCalculation().
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 912 of file PhreeqcIO.cpp.
References _chemical_system.
|
overridevirtual |
Run PHREEQC for all local chemical systems for the current timestep.
Uses the state previously provided by initializeChemicalSystemConcrete() / setChemicalSystemConcrete() for each chemical_system_id. Each local system is advanced as an isolated batch reactor over \(\Delta t\): no mass is exchanged between different systems inside PHREEQC.
PHREEQC returns, for each system:
After this call completes, these reacted values are available for porosity update and for assembling the reaction/source term in the transport equation.
| dt | Timestep size \(\Delta t\) used for kinetic reactions. |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 396 of file PhreeqcIO.cpp.
References callPhreeqc(), readOutputsFromFile(), and writeInputsToFile().
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 862 of file PhreeqcIO.cpp.
References _chemical_system.
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 405 of file PhreeqcIO.cpp.
References _chemical_system, ChemistryLib::PhreeqcIOData::pH, and MathLib::LinAlg::setLocalAccessibleVector().
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 316 of file PhreeqcIO.cpp.
References _chemical_system, _num_chemical_systems, _user_punch, and ChemistryLib::ChemicalSolverInterface::chemical_system_index_map.
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 328 of file PhreeqcIO.cpp.
References _chemical_system, and MaterialPropertyLib::Medium::phase().
|
inlineprivate |
Definition at line 181 of file PhreeqcIO.h.
References PhreeqcIO(), and _dt.
|
private |
Definition at line 657 of file PhreeqcIO.cpp.
References _output, DBUG(), and OGS_FATAL.
Referenced by executeSpeciationCalculation().
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 426 of file PhreeqcIO.cpp.
References _dump, _num_chemical_systems, and OGS_FATAL.
|
overridevirtual |
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 370 of file PhreeqcIO.cpp.
References _chemical_system, and MaterialPropertyLib::Medium::phase().
|
overridevirtual |
Update porosity after chemical reactions.
This applies porosity changes caused by precipitation / dissolution in the local chemical system. The updated porosity can then be used to update flow parameters (e.g. permeability) in the next timestep.
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 894 of file PhreeqcIO.cpp.
References _chemical_system.
|
overridevirtual |
Apply mineral precipitation / dissolution to the solid fraction in OGS.
Called after executeSpeciationCalculation(). For a given chemical_system_id, this function updates the solid / mineral inventory and related volume fractions based on the PHREEQC results for the last timestep.
Typical effect:
Reimplemented from ChemistryLib::ChemicalSolverInterface.
Definition at line 875 of file PhreeqcIO.cpp.
References _chemical_system.
|
private |
Definition at line 452 of file PhreeqcIO.cpp.
References _phreeqc_input_file, DBUG(), and OGS_FATAL.
Referenced by executeSpeciationCalculation().
|
friend |
Definition at line 476 of file PhreeqcIO.cpp.
References PhreeqcIO(), _chemical_system, _dt, _dump, _knobs, _num_chemical_systems, _output, _reaction_rates, and _user_punch.
|
friend |
Definition at line 681 of file PhreeqcIO.cpp.
References PhreeqcIO(), _chemical_system, _num_chemical_systems, _output, _user_punch, ChemistryLib::PhreeqcIOData::Component, ChemistryLib::PhreeqcIOData::EquilibriumReactant, BaseLib::findElementOrError(), ChemistryLib::PhreeqcIOData::KineticReactant, OGS_FATAL, ChemistryLib::PhreeqcIOData::pe, ChemistryLib::PhreeqcIOData::pH, ChemistryLib::PhreeqcIOData::SecondaryVariable, and MathLib::LinAlg::setLocalAccessibleVector().
|
private |
Definition at line 188 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), computeSecondaryVariable(), getComponentList(), getConcentration(), initialize(), initializeChemicalSystemConcrete(), operator<<, operator>>, setChemicalSystemConcrete(), updatePorosityPostReaction(), and updateVolumeFractionPostReaction().
|
private |
Definition at line 187 of file PhreeqcIO.h.
Referenced by PhreeqcIO().
|
private |
Definition at line 194 of file PhreeqcIO.h.
Referenced by operator<<(), and operator<<.
|
private |
Definition at line 192 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), operator<<, and setAqueousSolutionsPrevFromDumpFile().
|
private |
Definition at line 193 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), and operator<<.
|
private |
Definition at line 196 of file PhreeqcIO.h.
Referenced by initialize(), operator<<, operator>>, and setAqueousSolutionsPrevFromDumpFile().
|
private |
Definition at line 191 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), operator<<, operator>>, and readOutputsFromFile().
| std::string const ChemistryLib::PhreeqcIOData::PhreeqcIO::_phreeqc_input_file |
Definition at line 172 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), callPhreeqc(), and writeInputsToFile().
|
private |
Definition at line 189 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), and operator<<.
|
private |
Definition at line 190 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), initialize(), operator<<, and operator>>.
|
private |
Definition at line 195 of file PhreeqcIO.h.
Referenced by PhreeqcIO(), ~PhreeqcIO(), and callPhreeqc().