Reaktoro
A unified framework for modeling chemically reactive systems
PhreeqcUtils.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2018 Allan Leal
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <map>
22 #include <string>
23 #include <vector>
24 
25 // Reaktoro includes
26 #include <Reaktoro/Math/Matrix.hpp>
27 #include <Reaktoro/Common/ScalarTypes.hpp>
28 
29 // Phreeqc includes
30 #include <Reaktoro/Interfaces/PhreeqcLegacy.hpp>
31 
32 namespace Reaktoro {
33 
34 namespace PhreeqcUtils {
35 
39 auto load(PHREEQC& phreeqc, std::string database) -> void;
40 
45 auto execute(PHREEQC& phreeqc, std::string input, std::string output) -> void;
46 
51 auto findElement(const PHREEQC& phreeqc, std::string name) -> PhreeqcElement*;
52 
57 auto findSpecies(const PHREEQC& phreeqc, std::string name) -> PhreeqcSpecies*;
58 
63 auto findPhase(const PHREEQC& phreeqc, std::string name) -> PhreeqcPhase*;
64 
67 auto elements(const PhreeqcSpecies* species) -> std::map<PhreeqcElement*, double>;
68 
71 auto elements(const PhreeqcPhase* phase) -> std::map<PhreeqcElement*, double>;
72 
77 auto stoichiometry(std::string element, const PhreeqcSpecies* species) -> double;
78 
83 auto stoichiometry(std::string element, const PhreeqcPhase* phase) -> double;
84 
86 auto name(const PhreeqcElement* element) -> std::string;
87 
89 auto name(const PhreeqcSpecies* species) -> std::string;
90 
92 auto name(const PhreeqcPhase* phase) -> std::string;
93 
99 auto reactionEquation(const PhreeqcSpecies* species) -> std::map<std::string, double>;
100 
105 auto reactionEquation(const PhreeqcPhase* phase) -> std::map<std::string, double>;
106 
108 auto isAqueousSpecies(const PhreeqcSpecies* species) -> bool;
109 
111 auto isExchangeSpecies(const PhreeqcSpecies* species) -> bool;
112 
114 auto isGaseousSpecies(const PhreeqcPhase* phase) -> bool;
115 
117 auto isMineralSpecies(const PhreeqcPhase* phase) -> bool;
118 
122 auto index(std::string name, const std::vector<PhreeqcSpecies*>& species) -> unsigned;
123 
127 auto index(std::string name, const std::vector<PhreeqcPhase*>& phases) -> unsigned;
128 
131 auto activeAqueousSpecies(const PHREEQC& phreeqc) -> std::vector<PhreeqcSpecies*>;
132 
134 auto activeExchangeSpecies(const PHREEQC& phreeqc) -> std::vector<PhreeqcSpecies*>;
135 
139 auto activeProductSpecies(const PHREEQC& phreeqc) -> std::vector<PhreeqcSpecies*>;
140 
143 auto activeGaseousSpecies(const PHREEQC& phreeqc) -> std::vector<PhreeqcPhase*>;
144 
147 auto activePhasesInEquilibriumPhases(const PHREEQC& phreeqc) -> std::vector<PhreeqcPhase*>;
148 
151 auto activePhasesInSaturationList(const PHREEQC& phreeqc) -> std::vector<PhreeqcPhase*>;
152 
156 auto speciesAmounts(const PHREEQC& phreeqc, const std::vector<PhreeqcSpecies*>& species) -> Vector;
157 
161 auto speciesAmounts(const PHREEQC& phreeqc, const std::vector<PhreeqcPhase*>& phases) -> Vector;
162 
167 auto lnEquilibriumConstant(const PhreeqcSpecies* species, double T, double P) -> ThermoScalar;
168 
173 auto lnEquilibriumConstant(const PhreeqcPhase* phase, double T, double P) -> ThermoScalar;
174 
175 } // namespace PhreeqcUtils
176 } // namespace Reaktoro
auto index(const T &value, const std::vector< T > &values) -> Index
Find the index of a value in a container of values.
Definition: SetUtils.hxx:21
auto database(std::string name) -> std::string
Return the contents of a built-in database as a string.
Definition: DatabaseUtils.cpp:65
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto elements() -> std::vector< std::string >
Return a vector of all known 116 chemical elements.
Definition: ElementUtils.cpp:155
ThermoScalarBase< double > ThermoScalar
A type that defines a scalar thermo property.
Definition: ScalarTypes.hpp:40