Reaktoro 
A unified framework for modeling chemically reactive systems
EquilibriumSolver.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 
23 // Reaktoro includes
24 #include <Reaktoro/Math/Matrix.hpp>
25 
26 namespace Reaktoro {
27 
28 // Forward declarations
29 class ChemicalProperties;
30 class ChemicalState;
31 class ChemicalSystem;
32 class Partition;
33 struct EquilibriumOptions;
34 struct EquilibriumProblem;
35 struct EquilibriumResult;
36 struct EquilibriumSensitivity;
37 
40 {
41 public:
44 
46  explicit EquilibriumSolver(const ChemicalSystem& system);
47 
50 
52  virtual ~EquilibriumSolver();
53 
56 
58  auto setOptions(const EquilibriumOptions& options) -> void;
59 
61  auto setPartition(const Partition& partition) -> void;
62 
66  auto approximate(ChemicalState& state, double T, double P, const Vector& be) -> EquilibriumResult;
67 
71  auto approximate(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
72 
76 
80  auto solve(ChemicalState& state, double T, double P, const Vector& be) -> EquilibriumResult;
81 
87  auto solve(ChemicalState& state, double T, double P, const double* be) -> EquilibriumResult;
88 
92  auto solve(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
93 
96  auto solve(ChemicalState& state) -> EquilibriumResult;
97 
99  auto properties() const -> const ChemicalProperties&;
100 
105  auto sensitivity() -> const EquilibriumSensitivity&;
106 
107 private:
108  struct Impl;
109 
110  std::unique_ptr<Impl> pimpl;
111 };
112 
113 } // namespace Reaktoro
auto operator=(EquilibriumSolver other) -> EquilibriumSolver &
Assign a copy of an EquilibriumSolver instance.
Definition: EquilibriumSolver.cpp:541
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:36
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:47
auto setOptions(const EquilibriumOptions &options) -> void
Set the options of the equilibrium solver.
Definition: EquilibriumSolver.cpp:547
The options for the equilibrium calculations.
Definition: EquilibriumOptions.hpp:44
A type that contains the sensitivity data of the equilibrium state.
Definition: EquilibriumSensitivity.hpp:31
auto approximate(ChemicalState &state, double T, double P, const Vector &be) -> EquilibriumResult
Find an initial feasible guess for an equilibrium problem.
Definition: EquilibriumSolver.cpp:557
auto setPartition(const Partition &partition) -> void
Set the partition of the chemical system.
Definition: EquilibriumSolver.cpp:552
auto properties() const -> const ChemicalProperties &
Return the chemical properties of the calculated equilibrium state.
Definition: EquilibriumSolver.cpp:592
auto sensitivity() -> const EquilibriumSensitivity &
Return the sensitivity of the equilibrium state.
Definition: EquilibriumSolver.cpp:597
Eigen::VectorXd Vector
Define an alias to the vector type of the Eigen library.
Definition: Matrix.hpp:384
A type that defines an equilibrium problem.
Definition: EquilibriumProblem.hpp:34
A type used to describe the result of an equilibrium calculation.
Definition: EquilibriumResult.hpp:27
Provide a computational representation of the Partition of a chemical system.
Definition: Partition.hpp:55
EquilibriumSolver()
Construct a default EquilibriumSolver instance.
Definition: EquilibriumSolver.cpp:526
virtual ~EquilibriumSolver()
Destroy this EquilibriumSolver instance.
Definition: EquilibriumSolver.cpp:538
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:60
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto solve(ChemicalState &state, double T, double P, const Vector &be) -> EquilibriumResult
Solve an equilibrium problem with given molar amounts of the elements in the equilibrium partition...
Definition: EquilibriumSolver.cpp:572
A solver class for solving chemical equilibrium calculations.
Definition: EquilibriumSolver.hpp:39