Reaktoro
A unified framework for modeling chemically reactive systems
EquilibriumSolver.hpp
1 // This file is part of Reaktoro (https://reaktoro.org).
2 //
3 // Reaktoro is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // Reaktoro is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this library. If not, see <http://www.gnu.org/licenses/>.
15 
16 #pragma once
17 
18 // C++ includes
19 #include <memory>
20 
21 // Reaktoro includes
22 #include <Reaktoro/Math/Matrix.hpp>
23 
24 namespace Reaktoro {
25 
26 // Forward declarations
27 class ChemicalProperties;
28 class ChemicalState;
29 class ChemicalSystem;
30 class Partition;
31 class EquilibriumProblem;
32 struct EquilibriumOptions;
33 struct EquilibriumResult;
34 struct EquilibriumSensitivity;
35 
38 {
39 public:
42 
44  explicit EquilibriumSolver(const ChemicalSystem& system);
45 
47  explicit EquilibriumSolver(const Partition& partition);
48 
51 
53  virtual ~EquilibriumSolver();
54 
57 
59  auto setOptions(const EquilibriumOptions& options) -> void;
60 
62  auto setPartition(const Partition& partition) -> void;
63 
67  auto approximate(ChemicalState& state, double T, double P, VectorConstRef be) -> EquilibriumResult;
68 
72  auto approximate(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
73 
77 
81  auto solve(ChemicalState& state, double T, double P, VectorConstRef be) -> EquilibriumResult;
82 
88  auto solve(ChemicalState& state, double T, double P, const double* be) -> EquilibriumResult;
89 
93  auto solve(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
94 
97  auto solve(ChemicalState& state) -> EquilibriumResult;
98 
100  auto properties() const -> const ChemicalProperties&;
101 
106  auto sensitivity() -> const EquilibriumSensitivity&;
107 
109  auto dndT() -> VectorConstRef;
110 
112  auto dndP() -> VectorConstRef;
113 
115  auto dndb() -> VectorConstRef;
116 
117 private:
118  struct Impl;
119 
120  std::unique_ptr<Impl> pimpl;
121 };
122 
123 } // namespace Reaktoro
auto setPartition(const Partition &partition) -> void
Set the partition of the chemical system.
Definition: EquilibriumSolver.cpp:610
The options for the equilibrium calculations.
Definition: EquilibriumOptions.hpp:55
auto dndb() -> VectorConstRef
Compute the sensitivity of the species amounts with respect to element amounts.
Definition: EquilibriumSolver.cpp:672
auto properties() const -> const ChemicalProperties &
Return the chemical properties of the calculated equilibrium state.
Definition: EquilibriumSolver.cpp:652
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:61
A type that defines an equilibrium problem.
Definition: EquilibriumProblem.hpp:33
auto solve(ChemicalState &state, double T, double P, VectorConstRef be) -> EquilibriumResult
Solve an equilibrium problem with given molar amounts of the elements in the equilibrium partition.
Definition: EquilibriumSolver.cpp:631
auto sensitivity() -> const EquilibriumSensitivity &
Return the sensitivity of the equilibrium state.
Definition: EquilibriumSolver.cpp:657
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
A solver class for solving chemical equilibrium calculations.
Definition: EquilibriumSolver.hpp:38
A type that contains the sensitivity data of the equilibrium state.
Definition: EquilibriumSensitivity.hpp:31
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:33
virtual ~EquilibriumSolver()
Destroy this EquilibriumSolver instance.
Definition: EquilibriumSolver.cpp:596
auto approximate(ChemicalState &state, double T, double P, VectorConstRef be) -> EquilibriumResult
Find an initial feasible guess for an equilibrium problem.
Definition: EquilibriumSolver.cpp:615
auto dndP() -> VectorConstRef
Compute the sensitivity of the species amounts with respect to pressure.
Definition: EquilibriumSolver.cpp:667
Provide a computational representation of the Partition of a chemical system.
Definition: Partition.hpp:56
EquilibriumSolver()
Construct a default EquilibriumSolver instance.
Definition: EquilibriumSolver.cpp:580
auto dndT() -> VectorConstRef
Compute the sensitivity of the species amounts with respect to temperature.
Definition: EquilibriumSolver.cpp:662
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
< Alias to Eigen type Ref<VectorXd>.
Definition: Matrix.hpp:31
A type used to describe the result of an equilibrium calculation.
Definition: EquilibriumResult.hpp:35
auto operator=(EquilibriumSolver other) -> EquilibriumSolver &
Assign a copy of an EquilibriumSolver instance.
Definition: EquilibriumSolver.cpp:599
auto setOptions(const EquilibriumOptions &options) -> void
Set the options of the equilibrium solver.
Definition: EquilibriumSolver.cpp:605