Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
AqueousProps.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 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 // Reaktoro includes
21 #include <Reaktoro/Common/Matrix.hpp>
22 #include <Reaktoro/Common/Types.hpp>
23 #include <Reaktoro/Core/ActivityModel.hpp>
24 
25 namespace Reaktoro {
26 
27 // Forward declarations
28 class ChemicalProps;
29 class ChemicalState;
30 class ChemicalSystem;
31 class Phase;
32 class Species;
33 class SpeciesList;
34 
37 {
38 public:
41 
43  explicit AqueousProps(ChemicalState const& state);
44 
46  explicit AqueousProps(ChemicalProps const& props);
47 
49  AqueousProps(AqueousProps const& other);
50 
52  virtual ~AqueousProps();
53 
56 
68  static auto compute(ChemicalProps const& props) -> AqueousProps const&;
69 
73  auto setActivityModel(StringOrIndex const& species, ActivityModelGenerator const& generator) -> void;
74 
76  auto update(ChemicalState const& state) -> void;
77 
79  auto update(ChemicalProps const& props) -> void;
80 
82  auto temperature() const -> real;
83 
85  auto pressure() const -> real;
86 
88  auto waterAmount() const -> real;
89 
91  auto waterMass() const -> real;
92 
94  auto charge() const -> real;
95 
97  auto chargeMolality() const -> real;
98 
100  auto elementMolality(StringOrIndex const& symbol) const -> real;
101 
103  auto elementMolalities() const -> ArrayXr;
104 
106  auto speciesMolality(StringOrIndex const& name) const -> real;
107 
109  auto speciesMolalities() const -> ArrayXr;
110 
112  auto ionicStrength() const -> real;
113 
115  auto ionicStrengthEffective() const -> real;
116 
119 
121  auto pH() const -> real;
122 
124  auto pE() const -> real;
125 
127  auto Eh() const -> real;
128 
142  auto alkalinity() const -> real;
143 
148 
151  auto saturationIndex(StringOrIndex const& species) const -> real;
152 
155  auto saturationIndices() const -> ArrayXr;
156 
159  auto saturationRatio(StringOrIndex const& species) const -> real;
160 
163  auto saturationRatios() const -> ArrayXr;
164 
167  auto saturationRatiosLn() const -> ArrayXr;
168 
170  auto props() const -> ChemicalProps const&;
171 
173  auto system() const -> ChemicalSystem const&;
174 
176  auto phase() const -> Phase const&;
177 
179  auto output(std::ostream& out) const -> void;
180 
182  auto output(String const& filename) const -> void;
183 
184  // DEPRECATED METHODS : TO BE REMOVED IN THE NEAR FUTURE
185 
188  [[deprecated("Rely on the use of saturationIndex(species) instead.")]]
189  auto saturationIndexLn(StringOrIndex const& species) const -> real;
190 
193  [[deprecated("Rely on the use of saturationIndex(species) instead.")]]
194  auto saturationIndexLg(StringOrIndex const& species) const -> real;
195 
198  [[deprecated("Rely on the use of saturationIndices() instead.")]]
199  auto saturationIndicesLn() const -> ArrayXr;
200 
203  [[deprecated("Rely on the use of saturationIndices() instead.")]]
204  auto saturationIndicesLg() const -> ArrayXr;
205 
206 private:
207  struct Impl;
208 
209  Ptr<Impl> pimpl;
210 };
211 
213 auto operator<<(std::ostream& out, AqueousProps const& state) -> std::ostream&;
214 
215 } // namespace Reaktoro
The chemical properties of an aqueous phase.
Definition: AqueousProps.hpp:37
auto temperature() const -> real
Return the temperature of the aqueous phase (in K).
AqueousProps(ChemicalState const &state)
Construct an AqueousProps object with given chemical state of the system.
auto pressure() const -> real
Return the pressure of the aqueous phase (in Pa).
auto chargeMolality() const -> real
Return the molality concentration in the aqueous phase (in molal).
auto props() const -> ChemicalProps const &
Return the underlying ChemicalProps object.
auto pE() const -> real
Return the pE of the aqueous phase.
auto pH() const -> real
Return the pH of the aqueous phase.
auto charge() const -> real
Return the electric charge in the aqueous phase (in mol).
auto elementMolalities() const -> ArrayXr
Return the molality concentrations of the elements (in molal).
auto saturationIndexLn(StringOrIndex const &species) const -> real
Return the saturation index of a given species (in natural log).
virtual ~AqueousProps()
Destroy this AqueousProps object.
static auto compute(ChemicalProps const &props) -> AqueousProps const &
Compute an AqueousProps object with given ChemicalProps object.
auto saturationRatio(StringOrIndex const &species) const -> real
Return the saturation ratio ( ) of a non-aqueous species.
auto saturationIndices() const -> ArrayXr
Return the saturation indices of all non-aqueous species.
auto output(std::ostream &out) const -> void
Output the properties of the aqueous phase to a stream.
auto saturationRatios() const -> ArrayXr
Return the saturation ratios of all non-aqueous species.
auto saturationIndex(StringOrIndex const &species) const -> real
Return the saturation index ( ) of a non-aqueous species.
auto speciesMolality(StringOrIndex const &name) const -> real
Return the molality of an aqueous solute species (in molal).
auto operator=(AqueousProps other) -> AqueousProps &
Assign a AqueousProps object to this object.
auto waterAmount() const -> real
Return the amount of solvent water in the aqueous phase (in mol).
auto update(ChemicalProps const &props) -> void
Update the aqueous properties with given chemical properties of the system.
auto Eh() const -> real
Return the reduction potential of the aqueous phase (in V).
auto setActivityModel(StringOrIndex const &species, ActivityModelGenerator const &generator) -> void
Set an activity model for a non-aqueous species that will be used in the calculation of its saturatio...
AqueousProps(ChemicalSystem const &system)
Construct an uninitialized AqueousProps object with given chemical system.
auto speciesMolalities() const -> ArrayXr
Return the molality concentrations of the species (in molal).
AqueousProps(ChemicalProps const &props)
Construct an AqueousProps object with given chemical properties of the system.
auto phase() const -> Phase const &
Return the underlying Phase object corresponding to the aqueous phase.
auto system() const -> ChemicalSystem const &
Return the underlying ChemicalSystem object.
auto ionicStrengthEffective() const -> real
Return the effective ionic strength of the aqueous phase (in molal).
AqueousProps(AqueousProps const &other)
Construct a copy of a AqueousProps object.
auto saturationSpecies() const -> SpeciesList
Return the non-aqueous species that could be formed from the aqueous solution.
auto saturationRatiosLn() const -> ArrayXr
Return the saturation ratios of all non-aqueous species (in natural log).
auto waterMass() const -> real
Return the mass of solvent water in the aqueous phase (in kg).
auto ionicStrength() const -> real
Return the effective ionic strength of the aqueous phase (in molal). Equivalent to ionicStrengthEffec...
auto alkalinity() const -> real
Return the explicitly conservative form of total alkalinity of the aqueous phase (in eq/L).
auto saturationIndicesLg() const -> ArrayXr
Return the saturation indices of all non-aqueous species (in log base 10).
auto ionicStrengthStoichiometric() const -> real
Return the stoichiometric ionic strength of the aqueous phase (in molal).
auto update(ChemicalState const &state) -> void
Update the aqueous properties with given chemical state of the system.
auto saturationIndexLg(StringOrIndex const &species) const -> real
Return the saturation index of a given species (in log base 10).
auto saturationIndicesLn() const -> ArrayXr
Return the saturation indices of all non-aqueous species (in natural log).
auto elementMolality(StringOrIndex const &symbol) const -> real
Return the molality of an element (in molal).
The class that computes chemical properties of a chemical system.
Definition: ChemicalProps.hpp:34
The chemical state of a chemical system.
Definition: ChemicalState.hpp:41
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
A type used to define a phase and its attributes.
Definition: Phase.hpp:33
A type used as a collection of species.
Definition: SpeciesList.hpp:29
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
Fn< ActivityModel(SpeciesList const &species)> ActivityModelGenerator
The type for functions that construct an ActivityModel for a phase.
Definition: ActivityModel.hpp:53
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
std::unique_ptr< T > Ptr
Convenient alias for std::unique_ptr<T>.
Definition: Types.hpp:102
std::variant< Index, int, std::string > StringOrIndex
The type used to accept either a name or an index.
Definition: Types.hpp:58
autodiff::ArrayXreal ArrayXr
Convenient alias to Eigen type.
Definition: Matrix.hpp:87