Reaktoro
A unified framework for modeling chemically reactive systems
SmartEquilibriumSolver.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 
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 class EquilibriumProblem;
35 struct EquilibriumResult;
36 
39 {
40 public:
43 
45  explicit SmartEquilibriumSolver(const ChemicalSystem& system);
46 
49 
52 
54  virtual ~SmartEquilibriumSolver();
55 
57  auto setOptions(const EquilibriumOptions& options) -> void;
58 
60  auto setPartition(const Partition& partition) -> void;
61 
63  auto learn(ChemicalState& state, double T, double P, VectorConstRef be) -> EquilibriumResult;
64 
66  auto learn(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
67 
69  auto estimate(ChemicalState& state, double T, double P, VectorConstRef be) -> EquilibriumResult;
70 
72  auto estimate(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
73 
75  auto solve(ChemicalState& state, double T, double P, VectorConstRef be) -> EquilibriumResult;
76 
80  auto solve(ChemicalState& state, const EquilibriumProblem& problem) -> EquilibriumResult;
81 
83  auto properties() const -> const ChemicalProperties&;
84 
85 private:
86  struct Impl;
87 
88  std::unique_ptr<Impl> pimpl;
89 };
90 
91 } // namespace Reaktoro
A class used to perform equilibrium calculations using machine learning scheme.
Definition: SmartEquilibriumSolver.hpp:39
auto estimate(ChemicalState &state, double T, double P, VectorConstRef be) -> EquilibriumResult
Estimate the equilibrium state using sensitivity derivatives.
Definition: SmartEquilibriumSolver.cpp:250
auto operator=(SmartEquilibriumSolver other) -> SmartEquilibriumSolver &
Assign an SmartEquilibriumSolver instance to this.
Definition: SmartEquilibriumSolver.cpp:221
The options for the equilibrium calculations.
Definition: EquilibriumOptions.hpp:55
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 setOptions(const EquilibriumOptions &options) -> void
Set the options for the equilibrium calculation.
Definition: SmartEquilibriumSolver.cpp:230
auto properties() const -> const ChemicalProperties &
Return the chemical properties of the calculated equilibrium state.
Definition: SmartEquilibriumSolver.cpp:270
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
virtual ~SmartEquilibriumSolver()
Destroy this SmartEquilibriumSolver instance.
Definition: SmartEquilibriumSolver.cpp:227
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:33
auto setPartition(const Partition &partition) -> void
Set the partition of the chemical system.
Definition: SmartEquilibriumSolver.cpp:235
SmartEquilibriumSolver()
Construct a default SmartEquilibriumSolver instance.
Definition: SmartEquilibriumSolver.cpp:209
auto learn(ChemicalState &state, double T, double P, VectorConstRef be) -> EquilibriumResult
Learn how to perform a full equilibrium calculation.
Definition: SmartEquilibriumSolver.cpp:240
Provide a computational representation of the Partition of a chemical system.
Definition: Partition.hpp:56
auto solve(ChemicalState &state, double T, double P, VectorConstRef be) -> EquilibriumResult
Solve an equilibrium calculation either by.
Definition: SmartEquilibriumSolver.cpp:260
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