Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
ReactionEquation.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 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 // Reaktoro includes
21 #include <Reaktoro/Common/Types.hpp>
22 #include <Reaktoro/Core/Species.hpp>
23 #include <Reaktoro/Core/SpeciesList.hpp>
24 
25 namespace Reaktoro {
26 
37 {
38 public:
41 
44 
56  ReactionEquation(String const& equation);
57  ReactionEquation(Chars equation);
59 
63  ReactionEquation(String const& equation, SpeciesList const& species);
64 
66  auto empty() const -> bool;
67 
69  auto size() const -> Index;
70 
72  auto species() const -> Vec<Species>;
73 
75  auto coefficients() const -> Vec<double>;
76 
78  auto coefficient(const String& name) const -> double;
79 
81  operator String() const;
82 
83 private:
85  Pairs<Species, double> m_species;
86 
87 public:
89  inline auto begin() const { return m_species.begin(); }
90 
92  inline auto begin() { return m_species.begin(); }
93 
95  inline auto end() const { return m_species.end(); }
96 
98  inline auto end() { return m_species.end(); }
99 };
100 
102 auto operator<(const ReactionEquation& lhs, const ReactionEquation& rhs) -> bool;
103 
105 auto operator==(const ReactionEquation& lhs, const ReactionEquation& rhs) -> bool;
106 
108 auto operator<<(std::ostream& out, const ReactionEquation& equation) -> std::ostream&;
109 
110 } // namespace Reaktoro
111 
A type used to represent the equation of a reaction.
Definition: ReactionEquation.hpp:37
auto coefficient(const String &name) const -> double
Return the stoichiometric coefficient of a species in the reaction equation.
ReactionEquation(String const &equation)
Construct a ReactionEquation object by parsing a formatted string.
auto empty() const -> bool
Return true if the rection equation is empty.
auto end()
Return end iterator of this ReactionEquation object (for STL compatibility reasons).
Definition: ReactionEquation.hpp:98
ReactionEquation()
Construct a default ReactionEquation object.
auto species() const -> Vec< Species >
Return the species in the reaction equation.
ReactionEquation(String const &equation, SpeciesList const &species)
Construct a ReactionEquation object by parsing a formatted string.
auto coefficients() const -> Vec< double >
Return the stoichiometric coefficients of the species in the reaction equation.
auto begin() const
Return begin const iterator of this ReactionEquation object (for STL compatibility reasons).
Definition: ReactionEquation.hpp:89
auto begin()
Return begin iterator of this ReactionEquation object (for STL compatibility reasons).
Definition: ReactionEquation.hpp:92
auto end() const
Return end const iterator of this ReactionEquation object (for STL compatibility reasons).
Definition: ReactionEquation.hpp:95
auto size() const -> Index
Return the number of species in the reaction equation.
ReactionEquation(Pairs< Species, double > const &species)
Construct an ReactionEquation object with given species and respective stoichiometric coefficients.
A type used as a collection of species.
Definition: SpeciesList.hpp:29
A type used to represent a chemical species and its attributes.
Definition: Species.hpp:35
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
Vec< Pair< T, U > > Pairs
Convenient alias for std::vector<std::pair<T, U>>.
Definition: Types.hpp:90
auto operator<(const ChemicalFormula &lhs, const ChemicalFormula &rhs) -> bool
Compare two ChemicalFormula objects for less than.
std::vector< T > Vec
Convenient alias for std::vector<T>.
Definition: Types.hpp:66
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
const char * Chars
Convenient alias for const char*.
Definition: Types.hpp:49
auto operator==(const ChemicalFormula &lhs, const ChemicalFormula &rhs) -> bool
Compare two ChemicalFormula objects for equality.
auto operator<<(std::ostream &out, AggregateState option) -> std::ostream &
Output an AggregateState value.