Reaktoro 
A unified framework for modeling chemically reactive systems
EquilibriumProblem.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 ChemicalState;
30 class ChemicalSystem;
31 class Partition;
32 
35 {
36 public:
38  explicit EquilibriumProblem(const ChemicalSystem& system);
39 
42 
44  virtual ~EquilibriumProblem();
45 
48 
52 
56  auto setTemperature(double val) -> EquilibriumProblem&;
57 
62  auto setTemperature(double val, std::string units) -> EquilibriumProblem&;
63 
67  auto setPressure(double val) -> EquilibriumProblem&;
68 
73  auto setPressure(double val, std::string units) -> EquilibriumProblem&;
74 
77  auto setElementAmounts(const Vector& b) -> EquilibriumProblem&;
78 
82 
86  auto setElementAmount(Index ielement, double amount) -> EquilibriumProblem&;
87 
91  auto setElementAmount(std::string element, double amount) -> EquilibriumProblem&;
92 
95  auto setElectricalCharge(double amount) -> EquilibriumProblem&;
96 
103  auto add(std::string name, double amount, std::string units) -> EquilibriumProblem&;
104 
112  auto add(const ChemicalState& state) -> EquilibriumProblem&;
113 
119  auto addCompound(std::string name, double amount, std::string unit) -> EquilibriumProblem&;
120 
126  auto addSpecies(std::string name, double amount, std::string unit) -> EquilibriumProblem&;
127 
135  auto addState(const ChemicalState& state) -> EquilibriumProblem&;
136 
138  auto system() const -> const ChemicalSystem&;
139 
141  auto partition() const -> const Partition&;
142 
144  auto temperature() const -> double;
145 
147  auto pressure() const -> double;
148 
150  auto elementAmounts() const -> const Vector&;
151 
152 private:
153  struct Impl;
154 
155  std::unique_ptr<Impl> pimpl;
156 };
157 
158 } // namespace Reaktoro
auto amount(double value, Index size, Index index) -> ChemicalScalarBase< double, decltype(unit(size, index))>
Return a ChemicalScalar representation of a mole amount of a species.
Definition: ChemicalScalar.hpp:208
auto pressure() const -> double
Return the pressure for the equilibrium calculation (in units of Pa)
Definition: EquilibriumProblem.cpp:267
virtual ~EquilibriumProblem()
Destroy this EquilibriumProblem instance.
Definition: EquilibriumProblem.cpp:91
auto elementAmounts() const -> const Vector &
Return the amounts of the elements for the equilibrium calculation (in units of mol) ...
Definition: EquilibriumProblem.cpp:272
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:47
auto add(std::string name, double amount, std::string units) -> EquilibriumProblem &
Add a given amount of a compound or species to the equilibrium recipe.
Definition: EquilibriumProblem.cpp:171
auto setElementAmount(Index ielement, double amount) -> EquilibriumProblem &
Set the mole amount of an element for the equilibrium calculation (in units of mol) ...
Definition: EquilibriumProblem.cpp:147
auto addSpecies(std::string name, double amount, std::string unit) -> EquilibriumProblem &
Add a given amount of a species to the equilibrium recipe The species must be present in the chemical...
Definition: EquilibriumProblem.cpp:216
EquilibriumProblem(const ChemicalSystem &system)
Construct an EquilibriumProblem instance.
Definition: EquilibriumProblem.cpp:83
auto temperature() const -> double
Return the temperature for the equilibrium calculation (in units of K)
Definition: EquilibriumProblem.cpp:262
auto setElementAmounts(const Vector &b) -> EquilibriumProblem &
Set the mole amounts of each element for the equilibrium calculation.
Definition: EquilibriumProblem.cpp:132
auto partition() const -> const Partition &
Return a reference to the Partition instance used to create this EquilibriumProblem instance...
Definition: EquilibriumProblem.cpp:257
Eigen::VectorXd Vector
Define an alias to the vector type of the Eigen library.
Definition: Matrix.hpp:384
auto addCompound(std::string name, double amount, std::string unit) -> EquilibriumProblem &
Add a given amount of a compound to the equilibrium recipe.
Definition: EquilibriumProblem.cpp:183
A type that defines an equilibrium problem.
Definition: EquilibriumProblem.hpp:34
auto setPartition(const Partition &partition) -> EquilibriumProblem &
Set the partition of the chemical system.
Definition: EquilibriumProblem.cpp:100
Provide a computational representation of the Partition of a chemical system.
Definition: Partition.hpp:55
auto system() const -> const ChemicalSystem &
Return a reference to the ChemicalSystem instance used to create this EquilibriumProblem instance...
Definition: EquilibriumProblem.cpp:252
auto unit(Index rows, Index i) -> decltype(Vector::Unit(rows, i))
Return an expression of a unit vector.
Definition: Matrix.hxx:47
auto addState(const ChemicalState &state) -> EquilibriumProblem &
Add the mole amounts of the equilibrium species in a ChemicalState instance to the equilibrium recipe...
Definition: EquilibriumProblem.cpp:245
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
Definition: Units.cpp:38
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:60
auto setTemperature(double val) -> EquilibriumProblem &
Set the temperature for the equilibrium calculation.
Definition: EquilibriumProblem.cpp:106
auto operator=(EquilibriumProblem other) -> EquilibriumProblem &
Assign an EquilibriumProblem instance to this.
Definition: EquilibriumProblem.cpp:94
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto setElectricalCharge(double amount) -> EquilibriumProblem &
Set the mole amount of electrical charge.
Definition: EquilibriumProblem.cpp:166
auto setPressure(double val) -> EquilibriumProblem &
Set the pressure for the equilibrium calculation.
Definition: EquilibriumProblem.cpp:119