Reaktoro  v2.9.4
A unified framework for modeling chemically reactive systems
EquilibriumProblem.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2022 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/Constants.hpp>
22 #include <Reaktoro/Equilibrium/EquilibriumConditions.hpp>
23 #include <Reaktoro/Equilibrium/EquilibriumRestrictions.hpp>
24 #include <Reaktoro/Equilibrium/EquilibriumSpecs.hpp>
25 
26 namespace Reaktoro {
27 
28 // Forward declarations
29 class ChemicalState;
30 
33 {
34 public:
37 
39  explicit EquilibriumProblem(const EquilibriumSpecs& specs);
40 
43  auto startWithTemperature(real value) -> void;
44 
48  auto startWithTemperature(real value, Chars unit) -> void;
49 
52  auto startWithPressure(real value) -> void;
53 
57  auto startWithPressure(real value, Chars unit) -> void;
58 
62 
67  auto startWith(String species, real value, Chars unit) -> void;
68 
73  auto startWith(Index ispecies, real value, Chars unit) -> void;
74 
79  auto startWithState(const ChemicalState& state) -> void;
80 
112 
114  auto initialTemperature() const -> real;
115 
117  auto initialPressure() const -> real;
118 
121 
124 
126 
127 private:
128 
130  real m_initial_temperature = NaN;
131 
133  real m_initial_pressure = NaN;
134 
136  ArrayXr m_initial_species_amounts;
137 
139  ArrayXr m_initial_component_amounts;
140 
141 };
142 
143 } // namespace Reaktoro
The chemical state of a chemical system.
Definition: ChemicalState.hpp:41
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
The class used to define conditions to be satisfied at chemical equilibrium.
Definition: EquilibriumConditions.hpp:32
The class used to define chemical equilibrium problems.
Definition: EquilibriumProblem.hpp:33
auto initialTemperature() const -> real
Return the initial temperature of the system in the equilibrium calculation (in K).
EquilibriumProblem(const EquilibriumSpecs &specs)
Construct an EquilibriumProblem object with given specifications.
EquilibriumProblem(const ChemicalSystem &system)
Construct an EquilibriumProblem object with given chemical system.
auto startWith(Index ispecies, real value, Chars unit) -> void
Specify an initial condition for the abundance of a chemical species.
auto startWithTemperature(real value, Chars unit) -> void
Specify an initial temperature condition for the chemical system.
auto startWith(String species, real value, Chars unit) -> void
auto initialSpeciesAmounts() const -> ArrayXrConstRef
Return the initial amounts of the species in the equilibrium calculation (in mol).
auto startWithPressure(real value) -> void
Specify an initial pressure condition for the chemical system.
auto startWithPressure(real value, Chars unit) -> void
Specify an initial pressure condition for the chemical system.
auto startWithState(const ChemicalState &state) -> void
Specify an initial condition for temperature, pressure, and species amounts with a given chemical sta...
auto startWithTemperature(real value) -> void
Specify an initial temperature condition for the chemical system (in K).
auto startWithComponentAmounts(ArrayXrConstRef b) -> void
Specify the initial condition for the amounts of the conservative components.
auto system() const -> ChemicalSystem const &
Get the chemical system associated with the equilibrium conditions.
auto startWithSpeciesAmounts(ArrayXrConstRef n) -> void
Specify an initial condition for the species amounts.
auto initialPressure() const -> real
Return the initial pressure of the system in the equilibrium calculation (in Pa).
auto initialComponentAmounts() const -> ArrayXr
Return the initial amounts of the conservative components in the equilibrium calculation (in mol).
The class used to define reactivity restrictions in a chemical equilibrium calculation.
Definition: EquilibriumRestrictions.hpp:28
The class used to define conditions to be satisfied at chemical equilibrium.
Definition: EquilibriumSpecs.hpp:291
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
constexpr auto NaN
The value of NaN.
Definition: Constants.hpp:59
auto unit(Index rows, Index i) -> decltype(VectorXd::Unit(rows, i))
Return an expression of a unit vector.
Definition: Matrix.hpp:546
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
const char * Chars
Convenient alias for const char*.
Definition: Types.hpp:49
Eigen::Ref< const ArrayXr > ArrayXrConstRef
Convenient alias to Eigen type.
Definition: Matrix.hpp:89
autodiff::ArrayXreal ArrayXr
Convenient alias to Eigen type.
Definition: Matrix.hpp:87