Reaktoro
A unified framework for modeling chemically reactive systems
ChemicalModel.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 <functional>
22 
23 // Reaktoro includes
24 #include <Reaktoro/Thermodynamics/Models/PhaseChemicalModel.hpp>
25 
26 namespace Reaktoro {
27 
30 {
31 public:
34 
38  ChemicalModelResult(Index nphases, Index nspecies);
39 
43  auto resize(Index nphases, Index nspecies) -> void;
44 
49  auto phaseProperties(Index iphase, Index ispecies, Index nspecies) -> PhaseChemicalModelResult;
50 
55  auto phaseProperties(Index iphase, Index ispecies, Index nspecies) const -> PhaseChemicalModelResultConst;
56 
58  inline auto lnActivityCoefficients() -> ChemicalVectorRef { return ln_activity_coefficients; }
59 
61  inline auto lnActivityCoefficients() const -> ChemicalVectorConstRef { return ln_activity_coefficients; }
62 
64  inline auto lnActivities() -> ChemicalVectorRef { return ln_activities; }
65 
67  inline auto lnActivities() const -> ChemicalVectorConstRef { return ln_activities; }
68 
70  inline auto partialMolarVolumes() -> ChemicalVectorRef { return partial_molar_volumes; }
71 
73  inline auto partialMolarVolumes() const -> ChemicalVectorConstRef { return partial_molar_volumes; }
74 
76  inline auto phaseMolarVolumes() -> ChemicalVectorRef { return phase_molar_volumes; }
77 
79  inline auto phaseMolarVolumes() const -> ChemicalVectorConstRef { return phase_molar_volumes; }
80 
82  inline auto phaseResidualMolarGibbsEnergies() -> ChemicalVectorRef { return phase_residual_molar_gibbs_energies; }
83 
85  inline auto phaseResidualMolarGibbsEnergies() const -> ChemicalVectorConstRef { return phase_residual_molar_gibbs_energies; }
86 
88  inline auto phaseResidualMolarEnthalpies() -> ChemicalVectorRef { return phase_residual_molar_enthalpies; }
89 
91  inline auto phaseResidualMolarEnthalpies() const -> ChemicalVectorConstRef { return phase_residual_molar_enthalpies; }
92 
94  inline auto phaseResidualMolarHeatCapacitiesCp() -> ChemicalVectorRef { return phase_residual_molar_heat_capacities_cp; }
95 
97  inline auto phaseResidualMolarHeatCapacitiesCp() const -> ChemicalVectorConstRef { return phase_residual_molar_heat_capacities_cp; }
98 
100  inline auto phaseResidualMolarHeatCapacitiesCv() -> ChemicalVectorRef { return phase_residual_molar_heat_capacities_cv; }
101 
103  inline auto phaseResidualMolarHeatCapacitiesCv() const -> ChemicalVectorConstRef { return phase_residual_molar_heat_capacities_cv; }
104 
105 private:
107  ChemicalVector ln_activity_coefficients;
108 
110  ChemicalVector ln_activities;
111 
113  ChemicalVector partial_molar_volumes;
114 
116  ChemicalVector phase_molar_volumes;
117 
119  ChemicalVector phase_residual_molar_gibbs_energies;
120 
122  ChemicalVector phase_residual_molar_enthalpies;
123 
125  ChemicalVector phase_residual_molar_heat_capacities_cp;
126 
128  ChemicalVector phase_residual_molar_heat_capacities_cv;
129 };
130 
133 
134 } // namespace Reaktoro
std::function< void(ChemicalModelResult &, Temperature, Pressure, VectorConstRef)> ChemicalModel
The signature of the chemical model function that calculates the chemical properties of the species i...
Definition: ChemicalModel.hpp:132
auto phaseResidualMolarHeatCapacitiesCv() -> ChemicalVectorRef
Return the residual molar isochoric heat capacities of the phases w.r.t. to its ideal state (in units...
Definition: ChemicalModel.hpp:100
auto phaseResidualMolarHeatCapacitiesCp() -> ChemicalVectorRef
Return the residual molar isobaric heat capacities of the phases w.r.t. to its ideal state (in units ...
Definition: ChemicalModel.hpp:94
auto phaseMolarVolumes() -> ChemicalVectorRef
Return the molar volumes of the phases (in units of m3/mol).
Definition: ChemicalModel.hpp:76
The result of a chemical model function that calculates the chemical properties of species.
Definition: ChemicalModel.hpp:30
A type that describes pressure in units of Pa.
Definition: ThermoScalar.hpp:194
auto resize(Index nphases, Index nspecies) -> void
Resize this ChemicalModelResultBase with a given number of species.
Definition: ChemicalModel.cpp:36
auto lnActivityCoefficients() const -> ChemicalVectorConstRef
Return the natural log of the activity coefficients of the species.
Definition: ChemicalModel.hpp:61
auto partialMolarVolumes() const -> ChemicalVectorConstRef
Return the partial molar volume of species each phase (in units of m3/mol).
Definition: ChemicalModel.hpp:73
ChemicalModelResult()
Construct a default ChemicalModelResultBase instance.
Definition: ChemicalModel.cpp:22
auto phaseResidualMolarGibbsEnergies() -> ChemicalVectorRef
Return the residual molar Gibbs energies of the phases w.r.t. to its ideal state (in units of J/mol).
Definition: ChemicalModel.hpp:82
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
PhaseChemicalModelResultBase< ChemicalScalarConstRef, ChemicalVectorConstRef > PhaseChemicalModelResultConst
The chemical properties of the species in a phase (constant).
Definition: PhaseChemicalModel.hpp:63
A type that describes temperature in units of K.
Definition: ThermoScalar.hpp:177
auto phaseMolarVolumes() const -> ChemicalVectorConstRef
Return the molar volumes of the phases (in units of m3/mol).
Definition: ChemicalModel.hpp:79
auto lnActivityCoefficients() -> ChemicalVectorRef
Return the natural log of the activity coefficients of the species.
Definition: ChemicalModel.hpp:58
auto partialMolarVolumes() -> ChemicalVectorRef
Return the partial molar volume of species each phase (in units of m3/mol).
Definition: ChemicalModel.hpp:70
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
auto phaseResidualMolarHeatCapacitiesCp() const -> ChemicalVectorConstRef
Return the residual molar isobaric heat capacities of the phases w.r.t. to its ideal state (in units ...
Definition: ChemicalModel.hpp:97
auto phaseResidualMolarEnthalpies() const -> ChemicalVectorConstRef
Return the residual molar enthalpies of the phases w.r.t. to its ideal state (in units of J/mol).
Definition: ChemicalModel.hpp:91
auto phaseProperties(Index iphase, Index ispecies, Index nspecies) -> PhaseChemicalModelResult
Return a view of the chemical properties of a phase.
Definition: ChemicalModel.cpp:48
PhaseChemicalModelResultBase< ChemicalScalarRef, ChemicalVectorRef > PhaseChemicalModelResult
The chemical properties of the species in a phase.
Definition: PhaseChemicalModel.hpp:60
auto phaseResidualMolarHeatCapacitiesCv() const -> ChemicalVectorConstRef
Return the residual molar isochoric heat capacities of the phases w.r.t. to its ideal state (in units...
Definition: ChemicalModel.hpp:103
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:31
A template base class to represent a vector of chemical properties and their partial derivatives.
Definition: ChemicalVector.hpp:51
auto phaseResidualMolarGibbsEnergies() const -> ChemicalVectorConstRef
Return the residual molar Gibbs energies of the phases w.r.t. to its ideal state (in units of J/mol).
Definition: ChemicalModel.hpp:85
auto phaseResidualMolarEnthalpies() -> ChemicalVectorRef
Return the residual molar enthalpies of the phases w.r.t. to its ideal state (in units of J/mol).
Definition: ChemicalModel.hpp:88
auto lnActivities() -> ChemicalVectorRef
Return the natural log of the activities of the species.
Definition: ChemicalModel.hpp:64
auto lnActivities() const -> ChemicalVectorConstRef
Return the natural log of the activities of the species.
Definition: ChemicalModel.hpp:67