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-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 #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 -> const Matrix&;
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
Eigen::MatrixXd Matrix
Define an alias to the matrix type of the Eigen library.
Definition: Matrix.hpp:387
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 thermo property.
Definition: ScalarTypes.hpp:41
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:36
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:47
auto reactions() const -> const std::vector< Reaction > &
Return the reactions in the reaction system.
Definition: ReactionSystem.cpp:98
auto numReactions() const -> unsigned
Return the number of reactions in the reaction system.
Definition: ReactionSystem.cpp:79
auto indexReactionWithError(std::string name) const -> Index
Return the index of the reaction with given name.
Definition: ReactionSystem.cpp:89
auto reaction(Index index) const -> const Reaction &
Return the reaction in the reaction system with given index.
Definition: ReactionSystem.cpp:103
ReactionSystem()
Construct a default ReactionSystem instances.
Definition: ReactionSystem.cpp:68
Provide a computational representation of a chemical reaction.
Definition: Reaction.hpp:59
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:41
auto stoichiometricMatrix() const -> const Matrix &
Return the stoichiometric matrix of the reaction system.
Definition: ReactionSystem.cpp:125
auto indexReaction(std::string name) const -> Index
Return the index of the reaction with given name.
Definition: ReactionSystem.cpp:84
ChemicalVectorBase< Vector, Vector, Vector, Matrix > ChemicalVector
A type that represents a vector of chemical scalars and their derivatives.
Definition: ChemicalVector.hpp:39
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
auto rates(const ChemicalProperties &properties) const -> ChemicalVector
Calculate the kinetic rates of the reactions.
Definition: ReactionSystem.cpp:154
auto lnReactionQuotients(const ChemicalProperties &properties) const -> ChemicalVector
Calculate the reaction quotients of the reactions.
Definition: ReactionSystem.cpp:144
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto system() const -> const ChemicalSystem &
Return the chemical system instance.
Definition: ReactionSystem.cpp:130
virtual ~ReactionSystem()
Destroy this ReactionSystem instance.
Definition: ReactionSystem.cpp:76