Reaktoro
A unified framework for modeling chemically reactive systems
Gems.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/Interfaces/Interface.hpp>
22 
23 // Forward declarations
24 class TNode;
25 
26 namespace Reaktoro {
27 
30 {
32  bool warmstart = true;
33 };
34 
36 class Gems : public Interface
37 {
38 public:
40  Gems();
41 
44  Gems(std::string filename);
45 
47  virtual ~Gems();
48 
50  virtual auto temperature() const -> double;
51 
53  virtual auto pressure() const -> double;
54 
56  virtual auto speciesAmounts() const -> Vector;
57 
59  virtual auto numElements() const -> unsigned;
60 
62  virtual auto numSpecies() const -> unsigned;
63 
65  virtual auto numPhases() const -> unsigned;
66 
68  virtual auto numSpeciesInPhase(Index iphase) const -> unsigned;
69 
71  virtual auto elementName(Index ielement) const -> std::string;
72 
74  virtual auto elementMolarMass(Index ielement) const -> double;
75 
77  virtual auto elementStoichiometry(Index ispecies, Index ielement) const -> double;
78 
80  virtual auto speciesName(Index ispecies) const -> std::string;
81 
83  virtual auto phaseName(Index iphase) const -> std::string;
84 
89  virtual auto properties(ThermoModelResult& res, double T, double P) -> void;
90 
95  virtual auto properties(ChemicalModelResult& res, double T, double P, VectorConstRef n) -> void;
96 
98  virtual auto clone() const -> std::shared_ptr<Interface>;
99 
103  auto set(double T, double P) -> void;
104 
109  auto set(double T, double P, VectorConstRef n) -> void;
110 
112  auto setOptions(const GemsOptions& options) -> void;
113 
118  auto equilibrate(double T, double P, VectorConstRef b) -> void;
119 
121  auto converged() const -> bool;
122 
124  auto numIterations() const -> unsigned;
125 
127  auto elapsedTime() const -> double;
128 
130  auto node() const -> std::shared_ptr<TNode>;
131 
132 private:
133  struct Impl;
134 
135  std::shared_ptr<Impl> pimpl;
136 };
137 
138 } // namespace Reaktoro
auto setOptions(const GemsOptions &options) -> void
Set the options of the Gems instance.
Definition: Gems.cpp:350
virtual auto numPhases() const -> unsigned
Return the number of phases.
Definition: Gems.cpp:201
auto equilibrate(double T, double P, VectorConstRef b) -> void
Calculate the equilibrium state of the system.
Definition: Gems.cpp:355
Gems()
Construct a default Gems instance.
Definition: Gems.cpp:156
virtual ~Gems()
Destroy this Gems instance.
Definition: Gems.cpp:170
The result of a chemical model function that calculates the chemical properties of species.
Definition: ChemicalModel.hpp:29
A wrapper class for Gems code.
Definition: Gems.hpp:36
auto converged() const -> bool
Return the convergence result of the equilibrium calculation.
Definition: Gems.cpp:376
virtual auto elementName(Index ielement) const -> std::string
Return the name of an element.
Definition: Gems.cpp:211
virtual auto temperature() const -> double
Return the temperature (in units of K)
Definition: Gems.cpp:173
virtual auto pressure() const -> double
Return the pressure (in units of Pa)
Definition: Gems.cpp:178
virtual auto clone() const -> std::shared_ptr< Interface >
Return a clone of this Gems instance.
Definition: Gems.cpp:318
The result of a thermodynamic model function that calculates standard thermodynamic properties of spe...
Definition: ThermoModel.hpp:29
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto node() const -> std::shared_ptr< TNode >
Return a shared pointer to the TNode instance of Gems.
Definition: Gems.cpp:392
bool warmstart
The flag that indicates if smart start initial approximation is used.
Definition: Gems.hpp:32
virtual auto elementMolarMass(Index ielement) const -> double
Return the molar mass of an element (in units of kg/mol)
Definition: Gems.cpp:218
A class used to interface other codes with Reaktoro.
Definition: Interface.hpp:36
auto set(double T, double P) -> void
Set the temperature and pressure of the Gems instance.
Definition: Gems.cpp:323
virtual auto numSpeciesInPhase(Index iphase) const -> unsigned
Return the number of species in a phase.
Definition: Gems.cpp:206
virtual auto phaseName(Index iphase) const -> std::string
Return the name of a phase.
Definition: Gems.cpp:233
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
virtual auto properties(ThermoModelResult &res, double T, double P) -> void
Return the thermodynamic properties of the phases and its species.
Definition: Gems.cpp:238
virtual auto elementStoichiometry(Index ispecies, Index ielement) const -> double
Return the stoichiometry of an element in a species.
Definition: Gems.cpp:223
auto numIterations() const -> unsigned
Return the number of iterations of the equilibrium calculation.
Definition: Gems.cpp:382
virtual auto speciesName(Index ispecies) const -> std::string
Return the name of a species.
Definition: Gems.cpp:228
virtual auto numSpecies() const -> unsigned
Return the number of species.
Definition: Gems.cpp:196
virtual auto speciesAmounts() const -> Vector
Return the amounts of the species (in units of mol)
Definition: Gems.cpp:183
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:33
auto elapsedTime() const -> double
Return the wall time of the equilibrium calculation (in units of s)
Definition: Gems.cpp:387
virtual auto numElements() const -> unsigned
Return the number of elements.
Definition: Gems.cpp:191
A type that describes the options for Gems.
Definition: Gems.hpp:29