Reaktoro
A unified framework for modeling chemically reactive systems
ChemicalQuantity.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 <string>
23 
24 // Reaktoro includes
25 #include <Reaktoro/Common/Index.hpp>
26 #include <Reaktoro/Common/ChemicalVector.hpp>
27 
28 namespace Reaktoro {
29 
30 // Forward declarations
31 class ChemicalProperties;
32 class ChemicalState;
33 class ChemicalSystem;
34 class ReactionSystem;
35 
98 {
99 public:
101  using Function = std::function<double()>;
102 
106  ChemicalQuantity() = delete;
107 
109  explicit ChemicalQuantity(const ChemicalSystem& system);
110 
112  explicit ChemicalQuantity(const ReactionSystem& reactions);
113 
115  explicit ChemicalQuantity(const ChemicalState& state);
116 
118  virtual ~ChemicalQuantity() = default;
119 
121  auto system() const -> const ChemicalSystem&;
122 
124  auto reactions() const -> const ReactionSystem&;
125 
127  auto state() const -> const ChemicalState&;
128 
130  auto properties() const -> const ChemicalProperties&;
131 
133  auto rates() const -> const ChemicalVector&;
134 
136  auto tag() const -> double;
137 
139  auto update(const ChemicalState& state) -> ChemicalQuantity&;
140 
142  auto update(const ChemicalState& state, double t) -> ChemicalQuantity&;
143 
145  auto value(std::string str) const -> double;
146 
148  auto function(std::string str) const -> Function;
149 
151  auto operator()(std::string str) const -> double;
152 
153 private:
154  struct Impl;
155 
156  std::shared_ptr<Impl> pimpl;
157 };
158 
159 } // namespace Reaktoro
auto state() const -> const ChemicalState &
Return the chemical state of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:273
auto tag() const -> double
Return the tag variable of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:288
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
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
std::function< double()> Function
A type to describe a chemical quantity function.
Definition: ChemicalQuantity.hpp:101
auto update(const ChemicalState &state) -> ChemicalQuantity &
Update the state of this ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:293
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:33
auto properties() const -> const ChemicalProperties &
Return the chemical properties of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:278
auto reactions() const -> const ReactionSystem &
Return the chemical reactions of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:268
virtual ~ChemicalQuantity()=default
Destroy this ChemicalQuantity instance.
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:42
auto value(std::string str) const -> double
Return the value of the quantity given as a formatted string.
Definition: ChemicalQuantity.cpp:305
auto rates() const -> const ChemicalVector &
Return the reaction rates of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:283
A class that provides a convenient way to retrieve chemical quantities.
Definition: ChemicalQuantity.hpp:98
auto function(std::string str) const -> Function
Return a created function that calculates the chemical quantity from a formatted string.
Definition: ChemicalQuantity.cpp:310
auto system() const -> const ChemicalSystem &
Return the chemical system of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:263
ChemicalQuantity()=delete
Disable the default ChemicalQuantity constructor.