Reaktoro 
A unified framework for modeling chemically reactive systems
Phase.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 <memory>
22 #include <string>
23 
24 // Reaktoro includes
25 #include <Reaktoro/Core/Element.hpp>
26 #include <Reaktoro/Core/Species.hpp>
27 #include <Reaktoro/Thermodynamics/Models/PhaseChemicalModel.hpp>
28 #include <Reaktoro/Thermodynamics/Models/PhaseThermoModel.hpp>
29 
30 namespace Reaktoro {
31 
32 // Forward declarations
33 class PhaseChemicalProperties;
34 class PhaseThermoProperties;
35 
37 enum class PhaseType
38 {
39  Solid, Liquid, Gas, Plasma
40 };
41 
45 class Phase
46 {
47 public:
49  Phase();
50 
52  auto setName(std::string name) -> void;
53 
55  auto setType(PhaseType type) -> void;
56 
58  auto setSpecies(const std::vector<Species>& species) -> void;
59 
61  auto setThermoModel(const PhaseThermoModel& model) -> void;
62 
64  auto setChemicalModel(const PhaseChemicalModel& model) -> void;
65 
67  auto numElements() const -> unsigned;
68 
70  auto numSpecies() const -> unsigned;
71 
73  auto name() const -> std::string;
74 
76  auto type() const -> PhaseType;
77 
79  auto elements() const -> const std::vector<Element>&;
80 
82  auto elements() -> std::vector<Element>&;
83 
85  auto species() const -> const std::vector<Species>&;
86 
88  auto species() -> std::vector<Species>&;
89 
91  auto species(Index index) const -> const Species&;
92 
94  auto isFluid() const -> bool;
95 
97  auto isSolid() const -> bool;
98 
101  auto thermoModel() const -> const PhaseThermoModel&;
102 
105  auto chemicalModel() const -> const PhaseChemicalModel&;
106 
110  auto indexSpecies(std::string name) const -> Index;
111 
115  auto indexSpeciesWithError(std::string name) const -> Index;
116 
120  auto indexSpeciesAny(const std::vector<std::string>& names) const -> Index;
121 
125  auto indexSpeciesAnyWithError(const std::vector<std::string>& names) const -> Index;
126 
128  auto properties(double T, double P) const -> PhaseThermoProperties;
129 
131  auto properties(double T, double P, const Vector& n) const -> PhaseChemicalProperties;
132 
133 private:
134  struct Impl;
135 
136  std::shared_ptr<Impl> pimpl;
137 };
138 
140 auto operator<(const Phase& lhs, const Phase& rhs) -> bool;
141 
143 auto operator==(const Phase& lhs, const Phase& rhs) -> bool;
144 
145 } // namespace Reaktoro
A type used to define a phase and its attributes.
Definition: Phase.hpp:45
std::function< PhaseThermoModelResult(double, double)> PhaseThermoModel
The signature of the thermodynamic model function that calculates the standard thermodynamic properti...
Definition: PhaseThermoModel.hpp:60
A type used to describe a species and its attributes.
Definition: Species.hpp:41
auto index(const T &value, const std::vector< T > &values) -> Index
Find the index of a value in a container of values.
Definition: SetUtils.hxx:21
auto names(const NamedValues &values) -> std::vector< std::string >
Return the names of the entries in a container.
Definition: Utils.hxx:22
Defines a class for querying thermodynamic and chemical properties of a phase.
Definition: PhaseThermoProperties.hpp:33
PhaseType
A type to define the possible state of matter of a phase.
Definition: Phase.hpp:37
Eigen::VectorXd Vector
Define an alias to the vector type of the Eigen library.
Definition: Matrix.hpp:384
Defines a class for querying thermodynamic and chemical properties of a phase.
Definition: PhaseChemicalProperties.hpp:33
std::function< PhaseChemicalModelResult(double, double, const Vector &)> PhaseChemicalModel
The signature of the chemical model function that calculates the chemical properties of a phase...
Definition: PhaseChemicalModel.hpp:70
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto elements() -> std::vector< std::string >
Return a vector of all known 116 chemical elements.
Definition: ElementUtils.cpp:155