Reaktoro
A unified framework for modeling chemically reactive systems
ChemicalProperties.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 // Reaktoro includes
21 #include <Reaktoro/Common/ChemicalScalar.hpp>
22 #include <Reaktoro/Common/ChemicalVector.hpp>
23 #include <Reaktoro/Common/ThermoScalar.hpp>
24 #include <Reaktoro/Common/ThermoVector.hpp>
25 #include <Reaktoro/Core/ChemicalSystem.hpp>
26 #include <Reaktoro/Thermodynamics/Models/ChemicalModel.hpp>
27 #include <Reaktoro/Thermodynamics/Models/ThermoModel.hpp>
28 
29 namespace Reaktoro {
30 
33 {
34 public:
37 
39  ChemicalProperties(const ChemicalSystem& system);
40 
44  auto update(double T, double P) -> void;
45 
48  auto update(VectorConstRef n) -> void;
49 
54  auto update(double T, double P, VectorConstRef n) -> void;
55 
62  auto update(double T, double P, VectorConstRef n, const ThermoModelResult& tres, const ChemicalModelResult& cres) -> void;
63 
65  auto temperature() const -> Temperature;
66 
68  auto pressure() const -> Pressure;
69 
71  auto composition() const -> Composition;
72 
74  auto thermoModelResult() const -> const ThermoModelResult&;
75 
77  auto chemicalModelResult() const -> const ChemicalModelResult&;
78 
80  auto moleFractions() const -> ChemicalVector;
81 
84 
87 
89  auto lnActivities() const -> ChemicalVectorConstRef;
90 
93 
95  auto chemicalPotentials() const -> ChemicalVector;
96 
99 
102 
105 
108 
111 
114 
117 
120 
122  auto phaseMolarGibbsEnergies() const -> ChemicalVector;
123 
125  auto phaseMolarEnthalpies() const -> ChemicalVector;
126 
128  auto phaseMolarVolumes() const -> ChemicalVector;
129 
131  auto phaseMolarEntropies() const -> ChemicalVector;
132 
135 
138 
141 
144 
147 
149  auto phaseSpecificEnthalpies() const -> ChemicalVector;
150 
152  auto phaseSpecificVolumes() const -> ChemicalVector;
153 
155  auto phaseSpecificEntropies() const -> ChemicalVector;
156 
159 
162 
165 
168 
170  auto phaseDensities() const -> ChemicalVector;
171 
173  auto phaseMasses() const -> ChemicalVector;
174 
176  auto phaseAmounts() const -> ChemicalVector;
177 
179  auto phaseVolumes() const -> ChemicalVector;
180 
182  auto volume() const -> ChemicalScalar;
183 
186  auto subvolume(const Indices& iphases) const -> ChemicalScalar;
187 
190  auto fluidVolume() const -> ChemicalScalar;
191 
194  auto solidVolume() const -> ChemicalScalar;
195 
196 private:
198  ChemicalSystem system;
199 
201  Index num_species;
202 
204  Index num_phases;
205 
207  Temperature T;
208 
210  Pressure P;
211 
213  Vector n;
214 
216  ChemicalVector x;
217 
219  ThermoModelResult tres;
220 
222  ChemicalModelResult cres;
223 };
224 
225 } // namespace Reaktoro
auto phaseDensities() const -> ChemicalVector
Return the densities of the phases (in units of kg/m3).
Definition: ChemicalProperties.cpp:349
auto moleFractions() const -> ChemicalVector
Return the mole fractions of the species.
Definition: ChemicalProperties.cpp:119
auto standardPartialMolarVolumes() const -> ThermoVectorConstRef
Return the standard partial molar volumes of the species (in units of m3/mol).
Definition: ChemicalProperties.cpp:162
auto fluidVolume() const -> ChemicalScalar
Return the total fluid volume of the system (in units of m3).
Definition: ChemicalProperties.cpp:401
auto pressure() const -> Pressure
Return the pressure of the system (in units of Pa).
Definition: ChemicalProperties.cpp:99
auto lnActivityConstants() const -> ThermoVectorConstRef
Return the ln activity constants of the species.
Definition: ChemicalProperties.cpp:129
auto phaseMolarHeatCapacitiesConstV() const -> ChemicalVector
Return the molar isochoric heat capacities of the phases (in units of J/(mol*K)).
Definition: ChemicalProperties.cpp:292
auto phaseAmounts() const -> ChemicalVector
Return the molar amounts of the phases (in units of mol).
Definition: ChemicalProperties.cpp:371
ChemicalVectorBase< VectorConstRef, VectorConstRef, VectorConstRef, MatrixConstRef > ChemicalVectorConstRef
A type that represents a vector of chemical properties and their derivatives.
Definition: ChemicalVector.hpp:45
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
ThermoVectorBase< VectorConstRef, VectorConstRef, VectorConstRef > ThermoVectorConstRef
A type that defines a vector of thermodynamic properties.
Definition: ThermoVector.hpp:42
The result of a chemical model function that calculates the chemical properties of species.
Definition: ChemicalModel.hpp:30
ThermoVectorBase< Vector, Vector, Vector > ThermoVector
A type that defines a vector of thermodynamic properties.
Definition: ScalarTypes.hpp:41
A type that describes pressure in units of Pa.
Definition: ThermoScalar.hpp:194
auto standardPartialMolarGibbsEnergies() const -> ThermoVectorConstRef
Return the standard partial molar Gibbs energies of the species (in units of J/mol).
Definition: ChemicalProperties.cpp:152
auto phaseSpecificEntropies() const -> ChemicalVector
Return the specific entropies of the phases (in units of J/(kg*K)).
Definition: ChemicalProperties.cpp:324
auto phaseSpecificGibbsEnergies() const -> ChemicalVector
Return the specific Gibbs energies of the phases (in units of J/kg).
Definition: ChemicalProperties.cpp:309
auto temperature() const -> Temperature
Return the temperature of the system (in units of K).
Definition: ChemicalProperties.cpp:94
auto chemicalPotentials() const -> ChemicalVector
Return the chemical potentials of the species (in units of J/mol).
Definition: ChemicalProperties.cpp:144
auto phaseMolarGibbsEnergies() const -> ChemicalVector
Return the molar Gibbs energies of the phases (in units of J/mol).
Definition: ChemicalProperties.cpp:198
auto solidVolume() const -> ChemicalScalar
Return the total solid volume of the system (in units of m3).
Definition: ChemicalProperties.cpp:407
auto phaseMolarEntropies() const -> ChemicalVector
Return the molar entropies of the phases (in units of J/(mol*K)).
Definition: ChemicalProperties.cpp:254
auto phaseSpecificEnthalpies() const -> ChemicalVector
Return the specific enthalpies of the phases (in units of J/kg).
Definition: ChemicalProperties.cpp:314
The result of a thermodynamic model function that calculates standard thermodynamic properties of spe...
Definition: ThermoModel.hpp:30
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
A type that describes temperature in units of K.
Definition: ChemicalVector.hpp:377
A type that describes temperature in units of K.
Definition: ThermoScalar.hpp:177
auto standardPartialMolarInternalEnergies() const -> ThermoVector
Return the standard partial molar internal energies of the species (in units of J/mol).
Definition: ChemicalProperties.cpp:174
auto phaseMolarVolumes() const -> ChemicalVector
Return the molar volumes of the phases (in units of m3/mol).
Definition: ChemicalProperties.cpp:232
auto lnActivityCoefficients() const -> ChemicalVectorConstRef
Return the ln activity coefficients of the species.
Definition: ChemicalProperties.cpp:124
auto phaseMasses() const -> ChemicalVector
Return the masses of the phases (in units of kg).
Definition: ChemicalProperties.cpp:354
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:33
ChemicalProperties()
Construct a default ChemicalProperties instance.
Definition: ChemicalProperties.cpp:27
auto subvolume(const Indices &iphases) const -> ChemicalScalar
Return the total volume occupied by given phases (in units of m3).
Definition: ChemicalProperties.cpp:396
auto partialMolarVolumes() const -> ChemicalVectorConstRef
Return the partial molar volume of the species in that phase (in units of m3/mol).
Definition: ChemicalProperties.cpp:139
auto phaseMolarHeatCapacitiesConstP() const -> ChemicalVector
Return the molar isobaric heat capacities of the phases (in units of J/(mol*K)).
Definition: ChemicalProperties.cpp:275
auto thermoModelResult() const -> const ThermoModelResult &
Return the result of the PhaseThermoModel function of each phase.
Definition: ChemicalProperties.cpp:109
auto update(double T, double P) -> void
Update the thermodynamic properties of the chemical system.
Definition: ChemicalProperties.cpp:36
auto phaseSpecificVolumes() const -> ChemicalVector
Return the specific volumes of the phases (in units of m3/kg).
Definition: ChemicalProperties.cpp:319
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
auto standardPartialMolarEntropies() const -> ThermoVector
Return the standard partial molar entropies of the species (in units of J/(mol*K)).
Definition: ChemicalProperties.cpp:167
auto phaseVolumes() const -> ChemicalVector
Return the volumes of the phases (in units of m3).
Definition: ChemicalProperties.cpp:386
auto standardPartialMolarEnthalpies() const -> ThermoVectorConstRef
Return the standard partial molar enthalpies of the species (in units of J/mol).
Definition: ChemicalProperties.cpp:157
auto standardPartialMolarHelmholtzEnergies() const -> ThermoVector
Return the standard partial molar Helmholtz energies of the species (in units of J/mol).
Definition: ChemicalProperties.cpp:181
ChemicalScalarBase< double, RowVector > ChemicalScalar
A type that represents a chemical property and its derivatives.
Definition: ChemicalScalar.hpp:35
std::vector< Index > Indices
Define a type that represents a collection of indices.
Definition: Index.hpp:29
auto standardPartialMolarHeatCapacitiesConstP() const -> ThermoVectorConstRef
Return the standard partial molar isobaric heat capacities of the species (in units of J/(mol*K)).
Definition: ChemicalProperties.cpp:188
ChemicalVectorBase< Vector, Vector, Vector, Matrix > ChemicalVector
A type that represents a vector of chemical properties and their derivatives.
Definition: ChemicalVector.hpp:39
auto phaseMolarInternalEnergies() const -> ChemicalVector
Return the molar internal energies of the phases (in units of J/mol).
Definition: ChemicalProperties.cpp:261
auto lnActivities() const -> ChemicalVectorConstRef
Return the ln activities of the species.
Definition: ChemicalProperties.cpp:134
auto phaseSpecificHeatCapacitiesConstV() const -> ChemicalVector
Return the specific isochoric heat capacities of the phases (in units of J/(kg*K)).
Definition: ChemicalProperties.cpp:344
auto phaseSpecificHelmholtzEnergies() const -> ChemicalVector
Return the specific Helmholtz energies of the phases (in units of J/kg).
Definition: ChemicalProperties.cpp:334
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:31
auto composition() const -> Composition
Return the molar amounts of the species (in units of mol).
Definition: ChemicalProperties.cpp:104
auto volume() const -> ChemicalScalar
Return the volume of the system (in units of m3).
Definition: ChemicalProperties.cpp:391
auto phaseSpecificHeatCapacitiesConstP() const -> ChemicalVector
Return the specific isobaric heat capacities of the phases (in units of J/(kg*K)).
Definition: ChemicalProperties.cpp:339
auto phaseMolarEnthalpies() const -> ChemicalVector
Return the molar enthalpies of the phases (in units of J/mol).
Definition: ChemicalProperties.cpp:215
auto standardPartialMolarHeatCapacitiesConstV() const -> ThermoVectorConstRef
Return the standard partial molar isochoric heat capacities of the species (in units of J/(mol*K)).
Definition: ChemicalProperties.cpp:193
auto chemicalModelResult() const -> const ChemicalModelResult &
Return the result of the PhaseChemicalModel function of each phase.
Definition: ChemicalProperties.cpp:114
auto phaseSpecificInternalEnergies() const -> ChemicalVector
Return the specific internal energies of the phases (in units of J/kg).
Definition: ChemicalProperties.cpp:329
auto phaseMolarHelmholtzEnergies() const -> ChemicalVector
Return the molar Helmholtz energies of the phases (in units of J/mol).
Definition: ChemicalProperties.cpp:268