Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
Prop.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive phases.
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/Types.hpp>
22 
23 namespace Reaktoro {
24 
25 // Forward declarations
26 class ChemicalProps;
27 class ChemicalSystem;
28 
32 using PropFn = Fn<real(const ChemicalProps& props)>;
33 
35 class Prop
36 {
37 public:
39  explicit Prop(const PropFn& propfn);
40 
43  auto eval(const ChemicalProps& props) -> real;
44 
47  auto operator()(const ChemicalProps& props) -> real;
48 
50  static auto elementAmount(const ChemicalSystem& system, const String& element) -> Prop;
51 
53  static auto elementAmountInPhase(const ChemicalSystem& system, const String& element, const String& phase) -> Prop;
54 
56  static auto elementMass(const ChemicalSystem& system, const String& element) -> Prop;
57 
59  static auto elementMassInPhase(const ChemicalSystem& system, const String& element, const String& phase) -> Prop;
60 
62  static auto speciesAmount(const ChemicalSystem& system, const String& species) -> Prop;
63 
65  static auto speciesMass(const ChemicalSystem& system, const String& species) -> Prop;
66 
68  static auto speciesMoleFraction(const ChemicalSystem& system, const String& species) -> Prop;
69 
71  static auto speciesActivityCoefficient(const ChemicalSystem& system, const String& species) -> Prop;
72 
74  static auto speciesActivity(const ChemicalSystem& system, const String& species) -> Prop;
75 
77  static auto speciesChemicalPotential(const ChemicalSystem& system, const String& species) -> Prop;
78 
80  static auto speciesStandardVolume(const ChemicalSystem& system, const String& species) -> Prop;
81 
83  static auto speciesStandardGibbsEnergy(const ChemicalSystem& system, const String& species) -> Prop;
84 
86  static auto speciesStandardEnthalpy(const ChemicalSystem& system, const String& species) -> Prop;
87 
89  static auto speciesStandardEntropy(const ChemicalSystem& system, const String& species) -> Prop;
90 
92  static auto speciesStandardInternalEnergy(const ChemicalSystem& system, const String& species) -> Prop;
93 
95  static auto speciesStandardHelmholtzEnergy(const ChemicalSystem& system, const String& species) -> Prop;
96 
98  static auto speciesStandardHeatCapacitiesConstP(const ChemicalSystem& system, const String& species) -> Prop;
99 
101  static auto speciesStandardHeatCapacitiesConstV(const ChemicalSystem& system, const String& species) -> Prop;
102 
104  static auto phaseAmount(const ChemicalSystem& system, const String& phase) -> Prop;
105 
107  static auto phaseMass(const ChemicalSystem& system, const String& phase) -> Prop;
108 
110  static auto phaseVolume(const ChemicalSystem& system, const String& phase) -> Prop;
111 
113  static auto phaseGibbsEnergy(const ChemicalSystem& system, const String& phase) -> Prop;
114 
116  static auto phaseEnthalpy(const ChemicalSystem& system, const String& phase) -> Prop;
117 
119  static auto phaseEntropy(const ChemicalSystem& system, const String& phase) -> Prop;
120 
122  static auto phaseInternalEnergy(const ChemicalSystem& system, const String& phase) -> Prop;
123 
125  static auto phaseHelmholtzEnergy(const ChemicalSystem& system, const String& phase) -> Prop;
126 
128  static auto temperature(const ChemicalSystem& system) -> Prop;
129 
131  static auto pressure(const ChemicalSystem& system) -> Prop;
132 
134  static auto amount(const ChemicalSystem& system) -> Prop;
135 
137  static auto mass(const ChemicalSystem& system) -> Prop;
138 
140  static auto volume(const ChemicalSystem& system) -> Prop;
141 
143  static auto gibbsEnergy(const ChemicalSystem& system) -> Prop;
144 
146  static auto enthalpy(const ChemicalSystem& system) -> Prop;
147 
149  static auto entropy(const ChemicalSystem& system) -> Prop;
150 
152  static auto internalEnergy(const ChemicalSystem& system) -> Prop;
153 
155  static auto helmholtzEnergy(const ChemicalSystem& system) -> Prop;
156 
157 private:
159  PropFn propfn;
160 };
161 
162 } // namespace Reaktoro
The class that computes chemical properties of a chemical system.
Definition: ChemicalProps.hpp:34
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
Used to retrieve a specified property from the chemical properties of a system.
Definition: Prop.hpp:36
static auto speciesStandardHelmholtzEnergy(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar Helmholtz energy of formation of...
static auto speciesAmount(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the amount of a species in the system (in mol).
static auto phaseMass(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the sum of species masses in a phase of the system (in kg).
static auto internalEnergy(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the internal energy of formation of the system (in J).
static auto phaseHelmholtzEnergy(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the Helmholtz energy of formation of a phase in the system ...
static auto phaseEnthalpy(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the enthalpy of formation of a phase in the system (in J).
static auto speciesMass(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the mass of a species in the system (in kg).
static auto elementMassInPhase(const ChemicalSystem &system, const String &element, const String &phase) -> Prop
Return a property function that evaluates the mass of an element in a phase of the system (in kg).
auto operator()(const ChemicalProps &props) -> real
Evaluate the property with given chemical properties of the system.
static auto phaseGibbsEnergy(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the Gibbs energy of formation of a phase in the system (in ...
static auto speciesChemicalPotential(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the chemical potentials of a species in the system (in J/mo...
static auto enthalpy(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the enthalpy of formation of the system (in J).
static auto mass(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the sum of species masses in the system (in kg).
static auto pressure(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the pressure of the system (in Pa).
static auto phaseEntropy(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the entropy of formation of the a phase in system (in J/K).
auto eval(const ChemicalProps &props) -> real
Evaluate the property with given chemical properties of the system.
static auto elementAmountInPhase(const ChemicalSystem &system, const String &element, const String &phase) -> Prop
Return a property function that evaluates the amount of an element in a phase of the system (in mol).
static auto helmholtzEnergy(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the Helmholtz energy of formation of the system (in J).
static auto speciesStandardEnthalpy(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar enthalpy of formation of a speci...
static auto phaseInternalEnergy(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the internal energy of formation of a phase in the system (...
static auto phaseVolume(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the volume of a phase in the system (in m3).
static auto elementAmount(const ChemicalSystem &system, const String &element) -> Prop
Return a property function that evaluates the amount of an element in the system (in mol).
static auto speciesStandardEntropy(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar entropy of formation of a specie...
static auto speciesStandardInternalEnergy(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar internal energy of formation of ...
static auto speciesStandardHeatCapacitiesConstV(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar isochoric heat capacity of a spe...
Prop(const PropFn &propfn)
Construct a Prop evaluator object with given property evaluation function.
static auto elementMass(const ChemicalSystem &system, const String &element) -> Prop
Return a property function that evaluates the mass of an element in the system (in kg).
static auto speciesStandardGibbsEnergy(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar Gibbs energy of formation of a s...
static auto amount(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the sum of species amounts in the system (in mol).
static auto speciesActivity(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the activity of a species in the system.
static auto gibbsEnergy(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the Gibbs energy of formation of the system (in J).
static auto speciesStandardHeatCapacitiesConstP(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar isobaric heat capacity of a spec...
static auto speciesActivityCoefficient(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the activity coefficient of a species in the system.
static auto temperature(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the temperature of the system (in K).
static auto speciesMoleFraction(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the mole fraction of a species in the system.
static auto speciesStandardVolume(const ChemicalSystem &system, const String &species) -> Prop
Return a property function that evaluates the standard partial molar volume of a species in the syste...
static auto entropy(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the entropy of formation of the system (in J/K).
static auto volume(const ChemicalSystem &system) -> Prop
Return a property function that evaluates the volume of the system (in m3).
static auto phaseAmount(const ChemicalSystem &system, const String &phase) -> Prop
Return a property function that evaluates the sum of species amounts in a phase of the system (in mol...
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
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
Fn< real(const ChemicalProps &props)> PropFn
The function type for evaluation of a property of a chemical system.
Definition: Prop.hpp:32
std::function< F > Fn
Convenient alias for std::function<R(Args...)>.
Definition: Types.hpp:110