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-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 <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 
105 
107  explicit ChemicalQuantity(const ChemicalSystem& system);
108 
110  explicit ChemicalQuantity(const ReactionSystem& reactions);
111 
113  explicit ChemicalQuantity(const ChemicalState& state);
114 
116  virtual ~ChemicalQuantity();
117 
119  auto system() const -> const ChemicalSystem&;
120 
122  auto reactions() const -> const ReactionSystem&;
123 
125  auto state() const -> const ChemicalState&;
126 
128  auto properties() const -> const ChemicalProperties&;
129 
131  auto rates() const -> const ChemicalVector&;
132 
134  auto tag() const -> double;
135 
137  auto update(const ChemicalState& state) -> ChemicalQuantity&;
138 
140  auto update(const ChemicalState& state, double t) -> ChemicalQuantity&;
141 
143  auto value(std::string str) const -> double;
144 
146  auto function(std::string str) const -> Function;
147 
149  auto operator()(std::string str) const -> double;
150 
151 private:
152  struct Impl;
153 
154  std::shared_ptr<Impl> pimpl;
155 };
156 
157 } // namespace Reaktoro
auto rates() const -> const ChemicalVector &
Return the reaction rates of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:293
auto tag() const -> double
Return the tag variable of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:298
A class for querying thermodynamic and chemical properties of a chemical system.
Definition: ChemicalProperties.hpp:36
virtual ~ChemicalQuantity()
Destroy this ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:270
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:47
ChemicalQuantity()
Construct a default ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:252
STL namespace.
auto system() const -> const ChemicalSystem &
Return the chemical system of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:273
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:41
auto reactions() const -> const ReactionSystem &
Return the chemical reactions of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:278
A class that provides a convenient way to retrieve chemical quantities.
Definition: ChemicalQuantity.hpp:97
Provides a computational representation of the state of a multiphase chemical system.
Definition: ChemicalState.hpp:60
auto function(std::string str) const -> Function
Return a created function that calculates the chemical quantity from a formatted string.
Definition: ChemicalQuantity.cpp:320
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto state() const -> const ChemicalState &
Return the chemical state of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:283
auto properties() const -> const ChemicalProperties &
Return the chemical properties of the ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:288
auto value(std::string str) const -> double
Return the value of the quantity given as a formatted string.
Definition: ChemicalQuantity.cpp:315
auto update(const ChemicalState &state) -> ChemicalQuantity &
Update the state of this ChemicalQuantity instance.
Definition: ChemicalQuantity.cpp:303
std::function< double()> Function
A type to describe a chemical quantity function.
Definition: ChemicalQuantity.hpp:101