Reaktoro
A unified framework for modeling chemically reactive systems
ReactionSystem.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 #include <vector>
23 
24 // Reaktoro includes
25 #include <Reaktoro/Common/ScalarTypes.hpp>
26 #include <Reaktoro/Core/Reaction.hpp>
27 
28 namespace Reaktoro {
29 
30 // Forward declarations
31 class ChemicalSystem;
32 class ChemicalProperties;
33 class Reaction;
34 
42 {
43 public:
46 
48  ReactionSystem(const ChemicalSystem& system, const std::vector<Reaction>& reactions);
49 
51  virtual ~ReactionSystem();
52 
54  auto numReactions() const -> unsigned;
55 
57  auto indexReaction(std::string name) const -> Index;
58 
61  auto indexReactionWithError(std::string name) const -> Index;
62 
64  auto reactions() const -> const std::vector<Reaction>&;
65 
68  auto reaction(Index index) const -> const Reaction&;
69 
72  auto reaction(std::string name) const -> const Reaction&;
73 
75  auto stoichiometricMatrix() const -> MatrixConstRef;
76 
78  auto system() const -> const ChemicalSystem&;
79 
82  auto lnEquilibriumConstants(const ChemicalProperties& properties) const -> ThermoVector;
83 
86  auto lnReactionQuotients(const ChemicalProperties& properties) const -> ChemicalVector;
87 
90  auto rates(const ChemicalProperties& properties) const -> ChemicalVector;
91 
92 private:
93  struct Impl;
94 
95  std::shared_ptr<Impl> pimpl;
96 };
97 
98 auto operator<<(std::ostream& out, const ReactionSystem& reactions) -> std::ostream&;
99 
100 
101 } // namespace Reaktoro
auto stoichiometricMatrix() const -> MatrixConstRef
Return the stoichiometric matrix of the reaction system.
Definition: ReactionSystem.cpp:125
auto lnReactionQuotients(const ChemicalProperties &properties) const -> ChemicalVector
Calculate the reaction quotients of the reactions.
Definition: ReactionSystem.cpp:144
auto indexReaction(std::string name) const -> Index
Return the index of the reaction with given name.
Definition: ReactionSystem.cpp:84
auto index(const T &value, const std::vector< T > &values) -> Index
Find the index of a value in a container of values.
Definition: SetUtils.hxx:21
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
auto reactions() const -> const std::vector< Reaction > &
Return the reactions in the reaction system.
Definition: ReactionSystem.cpp:98
auto lnEquilibriumConstants(const ChemicalProperties &properties) const -> ThermoVector
Calculate the equilibrium constants of the reactions.
Definition: ReactionSystem.cpp:135
ThermoVectorBase< Vector, Vector, Vector > ThermoVector
A type that defines a vector of thermodynamic properties.
Definition: ScalarTypes.hpp:41
auto reaction(Index index) const -> const Reaction &
Return the reaction in the reaction system with given index.
Definition: ReactionSystem.cpp:103
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
virtual ~ReactionSystem()
Destroy this ReactionSystem instance.
Definition: ReactionSystem.cpp:76
auto system() const -> const ChemicalSystem &
Return the chemical system instance.
Definition: ReactionSystem.cpp:130
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:33
auto indexReactionWithError(std::string name) const -> Index
Return the index of the reaction with given name.
Definition: ReactionSystem.cpp:89
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:42
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
ReactionSystem()
Construct a default ReactionSystem instances.
Definition: ReactionSystem.cpp:68
Provide a computational representation of a chemical reaction.
Definition: Reaction.hpp:60
auto rates(const ChemicalProperties &properties) const -> ChemicalVector
Calculate the kinetic rates of the reactions.
Definition: ReactionSystem.cpp:154
ChemicalVectorBase< Vector, Vector, Vector, Matrix > ChemicalVector
A type that represents a vector of chemical properties and their derivatives.
Definition: ChemicalVector.hpp:39
Eigen::Ref< const Eigen::MatrixXd > MatrixConstRef
Alias to Eigen type Ref<const MatrixXd>.
Definition: Matrix.hpp:44
auto numReactions() const -> unsigned
Return the number of reactions in the reaction system.
Definition: ReactionSystem.cpp:79