Reaktoro
v2.11.0
A unified framework for modeling chemically reactive systems
Home
Modules
Namespaces
Classes
Files
License
File List
Reaktoro
Core
ChemicalQuantity.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
// // C++ includes
21
// #include <memory>
22
// #include <string>
23
24
// // Reaktoro includes
25
// #include <Reaktoro/Common/Index.hpp>
26
// #include <Reaktoro/Common/Matrix.hpp>
27
// #include <Reaktoro/Common/Real.hpp>
28
29
// namespace Reaktoro {
30
31
// // Forward declarations
32
// class ChemicalProps;
33
// class ChemicalState;
34
// class ChemicalSystem;
35
// class ReactionSystem;
36
37
// /// A class that provides a convenient way to retrieve chemical quantities.
38
// /// Here the term chemical quantity is used in a broad sense. It means any
39
// /// quantity for an element, species, or phase in a chemical system that
40
// /// can be calculated at a chemical state whose temperature, pressure, and
41
// /// mole amounts of all species are known.
42
// ///
43
// /// In the example below, the volume of a phase named Gaseous and the pH
44
// /// of the aqueous phase (assuming both phases were defined in the chemical
45
// /// system) are retrieved:
46
// ///
47
// /// ~~~
48
// /// ChemicalQuantity q(state);
49
// ///
50
// /// const double vol = q["phaseVolume(Gaseous)"];
51
// /// const double pH = q["pH"];
52
// /// ~~~
53
// ///
54
// /// The table below shows all possible quantities that can be retrieved from
55
// /// a ChemicalQuantity instance. The first column, **Quantity**, lists the
56
// /// names of the quantities; the second column, **Units**, lists the default
57
// /// units of the quantity; and the third column, **Example**, lists the
58
// /// formatted strings needed to retrieve a quantity.
59
// ///
60
// /// | Quantity | Units | Example |
61
// /// | -------- | ----- | ------- |
62
// /// | temperature | kelvin | `"temperature(units=celsius)"` |
63
// /// | pressure | pascal | `"pressure(units=bar)"` |
64
// /// | volume | m3 | `"volume(units=cm3)"` |
65
// /// | activity | --- | `"activity(CO2(aq))"` |
66
// /// | activityCoefficient | --- | `"activityCoefficient(Na+)"` |
67
// /// | fugacity | bar | `"fugacity(CO2(g))"` |
68
// /// | chemicalPotential | J/mol | `"chemicalPotential(Cl-)"` |
69
// /// | elementAmount | mol | `"elementAmount(Ca)"` |
70
// /// | elementAmountInPhase | mol | `"elementAmountInPhase(Mg Aqueous)"` |
71
// /// | elementMass | kg | `"elementMass(Fe units=g)"` |
72
// /// | elementMassInPhase | kg | `"elementMassInPhase(C Gaseous)"` |
73
// /// | elementMolality | molal | `"elementMolality(Cl units=mmolal)"` |
74
// /// | elementMolarity | molar | `"elementMolarity(K units=mmolar)"` |
75
// /// | speciesAmount | mol | `"speciesAmount(H2O(l))"` |
76
// /// | speciesMass | kg | `"speciesMass(Calcite units=g)"` |
77
// /// | speciesMoleFraction | --- | `"speciesMoleFraction(HCO3-)"` |
78
// /// | speciesMolality | molal | `"speciesMolality(Ca++)"` |
79
// /// | speciesMolarity | molar | `"speciesMolarity(Mg++)"` |
80
// /// | phaseAmount | mol | `"phaseAmount(Aqueous)"` |
81
// /// | phaseMass | kg | `"phaseMass(Dolomite)"` |
82
// /// | phaseVolume | m3 | `"phaseVolume(Gaseous)"` |
83
// /// | pH | --- | `"pH"` |
84
// /// | pE | --- | `"pE"` |
85
// /// | Eh | volt | `"Eh"` |
86
// /// | ionicStrength | molal | `"ionicStrength"` |
87
// /// | fluidVolume | m3 | `"fluidVolume(units=liter)"` |
88
// /// | fluidVolumeFraction | --- | `"fluidVolumeFraction"` |
89
// /// | solidVolume | m3 | `"solidVolume(units=mm3)"` |
90
// /// | solidVolumeFraction | --- | `"solidVolumeFraction"` |
91
// /// | reactionRate | mol/s | `"reactionRate(Dolomite units=mmol/hour)"` |
92
// /// | reactionEquilibriumIndex | --- | `"reactionEquilibriumIndex(Quartz)"` |
93
// /// | tag | --- | `"tag"` |
94
// /// | t | s | `"t(units=minute)"` |
95
// /// | time | s | `"time(units=year)"` |
96
// /// | progress | --- | `"progress"` |
97
// ///
98
// class ChemicalQuantity
99
// {
100
// public:
101
// /// A type to describe a chemical quantity function.
102
// using Function = std::function<double()>;
103
104
// /// Disable the default ChemicalQuantity constructor.
105
// /// This is to enforce the initialization of ChemicalQuantity
106
// /// instance with a ChemicalSystem instance.
107
// ChemicalQuantity() = delete;
108
109
// /// Construct a ChemicalQuantity instance from a ChemicalSystem object.
110
// explicit ChemicalQuantity(const ChemicalSystem& system);
111
112
// /// Construct a ChemicalQuantity instance from a ReactionSystem object.
113
// explicit ChemicalQuantity(const ReactionSystem& reactions);
114
115
// /// Construct a ChemicalQuantity instance from a ChemicalState object.
116
// explicit ChemicalQuantity(const ChemicalState& state);
117
118
// /// Destroy this ChemicalQuantity instance.
119
// virtual ~ChemicalQuantity() = default;
120
121
// /// Return the chemical system of the ChemicalQuantity instance.
122
// auto system() const -> const ChemicalSystem&;
123
124
// /// Return the chemical reactions of the ChemicalQuantity instance.
125
// auto reactions() const -> const ReactionSystem&;
126
127
// /// Return the chemical state of the ChemicalQuantity instance.
128
// auto state() const -> const ChemicalState&;
129
130
// /// Return the chemical properties of the ChemicalQuantity instance.
131
// auto props() const -> const ChemicalProps&;
132
133
// /// Return the reaction rates of the ChemicalQuantity instance.
134
// auto rates() const -> const VectorXr&;
135
136
// /// Return the tag variable of the ChemicalQuantity instance.
137
// auto tag() const -> double;
138
139
// /// Update the state of this ChemicalQuantity instance.
140
// auto update(const ChemicalState& state) -> ChemicalQuantity&;
141
142
// /// Update the state of this ChemicalQuantity instance.
143
// auto update(const ChemicalState& state, double t) -> ChemicalQuantity&;
144
145
// /// Return the value of the quantity given as a formatted string.
146
// auto value(std::string str) const -> double;
147
148
// /// Return a created function that calculates the chemical quantity from a formatted string.
149
// auto function(std::string str) const -> Function;
150
151
// /// Return the value of the quantity given as a formatted string.
152
// auto operator()(std::string str) const -> double;
153
154
// private:
155
// struct Impl;
156
157
// std::shared_ptr<Impl> pimpl;
158
// };
159
160
// } // namespace Reaktoro
Generated on Fri Jan 19 2024 09:38:41 for Reaktoro by
1.9.1