Reaktoro 
A unified framework for modeling chemically reactive systems
Interface.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright (C) 2014-2015 Allan Leal
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program 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
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #pragma once
19 
20 // C++ includes
21 #include <string>
22 #include <memory>
23 
24 // Reaktoro includes
25 #include <Reaktoro/Math/Matrix.hpp>
26 
27 namespace Reaktoro {
28 
29 // Forward declarations
30 class ChemicalState;
31 class ChemicalSystem;
32 struct PhaseThermoModelResult;
33 struct PhaseChemicalModelResult;
34 
36 class Interface
37 {
38 public:
40  virtual ~Interface() = 0;
41 
43  virtual auto temperature() const -> double = 0;
44 
46  virtual auto pressure() const -> double = 0;
47 
49  virtual auto speciesAmounts() const -> Vector = 0;
50 
52  virtual auto numElements() const -> unsigned = 0;
53 
55  virtual auto numSpecies() const -> unsigned = 0;
56 
58  virtual auto numPhases() const -> unsigned = 0;
59 
61  virtual auto numSpeciesInPhase(Index iphase) const -> unsigned = 0;
62 
64  virtual auto elementName(Index ielement) const -> std::string = 0;
65 
67  virtual auto elementMolarMass(Index ielement) const -> double = 0;
68 
70  virtual auto elementStoichiometry(Index ispecies, Index ielement) const -> double = 0;
71 
73  virtual auto speciesName(Index ispecies) const -> std::string = 0;
74 
76  virtual auto phaseName(Index iphase) const -> std::string = 0;
77 
82  virtual auto properties(Index iphase, double T, double P) -> PhaseThermoModelResult = 0;
83 
89  virtual auto properties(Index iphase, double T, double P, const Vector& nphase) -> PhaseChemicalModelResult = 0;
90 
92  virtual auto clone() const -> std::shared_ptr<Interface> = 0;
93 
95  auto formulaMatrix() const -> Matrix;
96 
98  auto indexElement(std::string element) const -> Index;
99 
101  auto indexSpecies(std::string species) const -> Index;
102 
104  auto indexPhase(std::string phase) const -> Index;
105 
107  auto indexPhaseWithSpecies(Index ispecies) const -> Index;
108 
110  auto indexFirstSpeciesInPhase(Index iphase) const -> Index;
111 
113  auto system() const -> ChemicalSystem;
114 
117  auto state(const ChemicalSystem& system) const -> ChemicalState;
118 
120  operator ChemicalSystem() const;
121 };
122 
123 } // namespace Reaktoro
Eigen::MatrixXd Matrix
Define an alias to the matrix type of the Eigen library.
Definition: Matrix.hpp:387
auto indexSpecies(std::string species) const -> Index
Return the index of a species.
Definition: Interface.cpp:80
auto indexPhase(std::string phase) const -> Index
Return the index of a phase.
Definition: Interface.cpp:89
virtual auto elementMolarMass(Index ielement) const -> double=0
Return the molar mass of an element (in units of kg/mol)
virtual auto speciesAmounts() const -> Vector=0
Return the amounts of the species (in units of mol)
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:47
auto system() const -> ChemicalSystem
Return a ChemicalSystem instance created from an instance of a class derived from Interface...
Definition: Interface.cpp:122
virtual auto clone() const -> std::shared_ptr< Interface >=0
Return a clone of this Interface instance.
virtual auto numSpecies() const -> unsigned=0
Return the number of species.
auto state(const ChemicalSystem &system) const -> ChemicalState
Return a ChemicalState instance created from an instance of a class derived from Interface.
Definition: Interface.cpp:177
auto formulaMatrix() const -> Matrix
Return the formula matrix of the species.
Definition: Interface.cpp:60
The result of the chemical model function that calculates the chemical properties of a phase...
Definition: PhaseChemicalModel.hpp:30
virtual auto temperature() const -> double=0
Return the temperature (in units of K)
virtual auto numPhases() const -> unsigned=0
Return the number of phases.
The result of the thermodynamic model function that calculates the standard thermodynamic properties ...
Definition: PhaseThermoModel.hpp:29
virtual auto phaseName(Index iphase) const -> std::string=0
Return the name of a phase.
virtual auto elementName(Index ielement) const -> std::string=0
Return the name of an element.
virtual auto numElements() const -> unsigned=0
Return the number of elements.
Eigen::VectorXd Vector
Define an alias to the vector type of the Eigen library.
Definition: Matrix.hpp:384
virtual ~Interface()=0
Virtual destructor.
Definition: Interface.cpp:57
virtual auto elementStoichiometry(Index ispecies, Index ielement) const -> double=0
Return the stoichiometry of an element in a species.
auto indexElement(std::string element) const -> Index
Return the index of an element.
Definition: Interface.cpp:71
A class used to interface other codes with Reaktoro.
Definition: Interface.hpp:36
virtual auto numSpeciesInPhase(Index iphase) const -> unsigned=0
Return the number of species in a phase.
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:60
auto indexFirstSpeciesInPhase(Index iphase) const -> Index
Return the index of the first species in a phase.
Definition: Interface.cpp:112
virtual auto properties(Index iphase, double T, double P) -> PhaseThermoModelResult=0
Return the thermodynamic properties of a phase.
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
virtual auto speciesName(Index ispecies) const -> std::string=0
Return the name of a species.
virtual auto pressure() const -> double=0
Return the pressure (in units of Pa)
auto indexPhaseWithSpecies(Index ispecies) const -> Index
Return the index of the phase with a species.
Definition: Interface.cpp:98