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-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 <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 
33 enum class PhaseType
34 {
35  Solid, Liquid, Gas, Plasma
36 };
37 
41 class Phase
42 {
43 public:
45  Phase();
46 
48  auto setName(std::string name) -> void;
49 
51  auto setType(PhaseType type) -> void;
52 
54  auto setSpecies(const std::vector<Species>& species) -> void;
55 
57  auto setThermoModel(const PhaseThermoModel& model) -> void;
58 
60  auto setChemicalModel(const PhaseChemicalModel& model) -> void;
61 
63  auto numElements() const -> unsigned;
64 
66  auto numSpecies() const -> unsigned;
67 
69  auto name() const -> std::string;
70 
72  auto type() const -> PhaseType;
73 
75  auto elements() const -> const std::vector<Element>&;
76 
78  auto elements() -> std::vector<Element>&;
79 
81  auto species() const -> const std::vector<Species>&;
82 
84  auto species() -> std::vector<Species>&;
85 
87  auto species(Index index) const -> const Species&;
88 
90  auto isFluid() const -> bool;
91 
93  auto isSolid() const -> bool;
94 
97  auto thermoModel() const -> const PhaseThermoModel&;
98 
101  auto chemicalModel() const -> const PhaseChemicalModel&;
102 
106  auto indexSpecies(std::string name) const -> Index;
107 
111  auto indexSpeciesWithError(std::string name) const -> Index;
112 
116  auto indexSpeciesAny(const std::vector<std::string>& names) const -> Index;
117 
121  auto indexSpeciesAnyWithError(const std::vector<std::string>& names) const -> Index;
122 
127  auto properties(PhaseThermoModelResult& res, double T, double P) const -> void;
128 
134  auto properties(PhaseChemicalModelResult& res, double T, double P, VectorConstRef n) const -> void;
135 
136 private:
137  struct Impl;
138 
139  std::shared_ptr<Impl> pimpl;
140 };
141 
143 auto operator<(const Phase& lhs, const Phase& rhs) -> bool;
144 
146 auto operator==(const Phase& lhs, const Phase& rhs) -> bool;
147 
148 } // namespace Reaktoro
A type used to define a phase and its attributes.
Definition: Phase.hpp:41
A type used to describe a species and its attributes.
Definition: Species.hpp:41
auto names(const NamedValues &values) -> std::vector< std::string >
Return the names of the entries in a container.
Definition: Utils.hxx:22
std::function< void(PhaseChemicalModelResult &, Temperature, Pressure, VectorConstRef)> PhaseChemicalModel
The signature of the chemical model function that calculates the chemical properties of the species i...
Definition: PhaseChemicalModel.hpp:63
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:33
The result of a chemical model function that calculates the chemical properties of species...
Definition: PhaseChemicalModel.hpp:32
std::function< void(PhaseThermoModelResult &, Temperature, Pressure)> PhaseThermoModel
The signature of the chemical model function that calculates the thermodynamic properties of the spec...
Definition: PhaseThermoModel.hpp:59
PhaseType
A type to define the possible state of matter of a phase.
Definition: Phase.hpp:33
The result of a thermodynamic model function that calculates the thermodynamic properties of species...
Definition: PhaseThermoModel.hpp:31
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
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
auto elements() -> std::vector< std::string >
Return a vector of all known 116 chemical elements.
Definition: ElementUtils.cpp:155