Reaktoro 
A unified framework for modeling chemically reactive systems
AqueousMixture.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2015 Allan Leal
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // Reaktoro includes
21 #include <Reaktoro/Thermodynamics/Species/AqueousSpecies.hpp>
22 #include <Reaktoro/Thermodynamics/Mixtures/GeneralMixture.hpp>
23 
24 namespace Reaktoro {
25 
29 {
32 
35 
38 
41 
44 
47 };
48 
59 class AqueousMixture : public GeneralMixture<AqueousSpecies>
60 {
61 public:
64 
67  explicit AqueousMixture(const std::vector<AqueousSpecies>& species);
68 
70  virtual ~AqueousMixture();
71 
73  auto setWaterDensity(const ThermoScalarFunction& rho) -> void;
74 
76  auto setWaterDielectricConstant(const ThermoScalarFunction& epsilon) -> void;
77 
84  auto setInterpolationPoints(const std::vector<double>& temperatures, const std::vector<double>& pressures) -> void;
85 
87  auto numNeutralSpecies() const -> unsigned;
88 
90  auto numChargedSpecies() const -> unsigned;
91 
93  auto indicesNeutralSpecies() const -> const Indices&;
94 
96  auto indicesChargedSpecies() const -> const Indices&;
97 
99  auto indicesCations() const -> const Indices&;
100 
102  auto indicesAnions() const -> const Indices&;
103 
105  auto indexWater() const -> Index;
106 
110  auto indexNeutralSpecies(std::string name) const -> Index;
111 
115  auto indexNeutralSpeciesAny(const std::vector<std::string>& names) const -> Index;
116 
120  auto indexChargedSpecies(std::string name) const -> Index;
121 
125  auto indexChargedSpeciesAny(const std::vector<std::string>& names) const -> Index;
126 
130  auto indexCation(std::string name) const -> Index;
131 
135  auto indexAnion(std::string name) const -> Index;
136 
138  auto namesNeutralSpecies() const -> std::vector<std::string>;
139 
141  auto namesChargedSpecies() const -> std::vector<std::string>;
142 
144  auto namesCations() const -> std::vector<std::string>;
145 
147  auto namesAnions() const -> std::vector<std::string>;
148 
150  auto chargesChargedSpecies() const -> Vector;
151 
153  auto chargesCations() const -> Vector;
154 
156  auto chargesAnions() const -> Vector;
157 
163  auto dissociationMatrix() const -> const Matrix&;
164 
168  auto molalities(const Vector& n) const -> ChemicalVector;
169 
173  auto stoichiometricMolalities(const ChemicalVector& m) const -> ChemicalVector;
174 
178  auto effectiveIonicStrength(const ChemicalVector& m) const -> ChemicalScalar;
179 
183  auto stoichiometricIonicStrength(const ChemicalVector& ms) const -> ChemicalScalar;
184 
189  auto state(double T, double P, const Vector& n) const -> AqueousMixtureState;
190 
191 private:
193  Index idx_water;
194 
196  Indices idx_neutral_species;
197 
199  Indices idx_charged_species;
200 
202  Indices idx_cations;
203 
205  Indices idx_anions;
206 
208  Matrix dissociation_matrix;
209 
211  ThermoScalarFunction rho, rho_default;
212 
214  ThermoScalarFunction epsilon, epsilon_default;
215 
217  void initializeIndices(const std::vector<AqueousSpecies>& species);
218 
220  void initializeDissociationMatrix(const std::vector<AqueousSpecies>& species);
221 };
222 
223 } // namespace Reaktoro
Provide a base of implementation for the mixture classes.
Definition: GeneralMixture.hpp:57
Eigen::MatrixXd Matrix
Define an alias to the matrix type of the Eigen library.
Definition: Matrix.hpp:387
ThermoScalar rho
The density of water (in units of kg/m3)
Definition: AqueousMixture.hpp:31
std::vector< Index > Indices
Define a type that represents a collection of indices.
Definition: Index.hpp:29
auto names(const NamedValues &values) -> std::vector< std::string >
Return the names of the entries in a container.
Definition: Utils.hxx:22
A type used to describe the state of an aqueous mixture.
Definition: AqueousMixture.hpp:28
A type used to describe the state of a mixture.
Definition: GeneralMixture.hpp:36
ChemicalScalarBase< double, Vector > ChemicalScalar
A type that represents a chemical scalar and its derivatives.
Definition: ChemicalScalar.hpp:35
Temperature T
The temperature of the mixture (in units of K)
Definition: GeneralMixture.hpp:39
ThermoScalar epsilon
The relative dielectric constant of water (no units)
Definition: AqueousMixture.hpp:34
Pressure P
The pressure of the mixture (in units of Pa)
Definition: GeneralMixture.hpp:42
ChemicalScalar Is
The stoichiometric ionic strength of the aqueous mixture and their partial derivatives (in units of m...
Definition: AqueousMixture.hpp:40
ChemicalScalar Ie
The effective ionic strength of the aqueous mixture and their partial derivatives (in units of mol/kg...
Definition: AqueousMixture.hpp:37
Eigen::VectorXd Vector
Define an alias to the vector type of the Eigen library.
Definition: Matrix.hpp:384
ChemicalVector ms
The stoichiometric molalities of the ionic species and their partial derivatives (in units of mol/kg)...
Definition: AqueousMixture.hpp:46
ChemicalVectorBase< Vector, Vector, Vector, Matrix > ChemicalVector
A type that represents a vector of chemical scalars and their derivatives.
Definition: ChemicalVector.hpp:39
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
ChemicalVector m
The molalities of the aqueous species and their partial derivatives (in units of mol/kg) ...
Definition: AqueousMixture.hpp:43
A type used to describe an aqueous mixture.
Definition: AqueousMixture.hpp:59