Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
EquilibriumRestrictions.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/ChemicalSystem.hpp>
23 
24 namespace Reaktoro {
25 
28 {
29 public:
32 
33  //=================================================================================================
34  //
35  // METHODS THAT INTRODUCE RESTRICTIONS ON HOW MUCH SPECIES CAN REACT
36  //
37  //=================================================================================================
38 
41  auto cannotReact(Index ispecies) -> void;
42 
45  auto cannotReact(String species) -> void;
46 
49  auto cannotIncrease(Index ispecies) -> void;
50 
53  auto cannotIncrease(String species) -> void;
54 
59  auto cannotIncreaseAbove(Index ispecies, double value, Chars unit="mol") -> void;
60 
65  auto cannotIncreaseAbove(String species, double value, Chars unit="mol") -> void;
66 
69  auto cannotDecrease(Index ispecies) -> void;
70 
73  auto cannotDecrease(String species) -> void;
74 
79  auto cannotDecreaseBelow(Index ispecies, double value, Chars unit="mol") -> void;
80 
85  auto cannotDecreaseBelow(String species, double value, Chars unit="mol") -> void;
86 
87  //=================================================================================================
88  //
89  // METHODS THAT REMOVE EXISTING REACTIVITY RESTRICTIONS ON SPECIES
90  //
91  //=================================================================================================
92 
95  auto canReactFreely(Index ispecies) -> void;
96 
99  auto canReactFreely(String species) -> void;
100 
103  auto canIncreaseFreely(Index ispecies) -> void;
104 
107  auto canIncreaseFreely(String species) -> void;
108 
111  auto canDecreaseFreely(Index ispecies) -> void;
112 
115  auto canDecreaseFreely(String species) -> void;
116 
117  //=================================================================================================
118  //
119  // MISCELLANEOUS METHODS
120  //
121  //=================================================================================================
122 
124  auto system() const -> ChemicalSystem const&;
125 
127  auto speciesCannotIncrease() const -> Set<Index> const&;
128 
130  auto speciesCannotDecrease() const -> Set<Index> const&;
131 
133  auto speciesCannotIncreaseAbove() const -> Map<Index, double> const&;
134 
136  auto speciesCannotDecreaseBelow() const -> Map<Index, double> const&;
137 
138 private:
140  ChemicalSystem msystem;
141 
143  Set<Index> species_cannot_increase;
144 
146  Set<Index> species_cannot_decrease;
147 
149  Map<Index, double> species_cannot_increase_above;
150 
152  Map<Index, double> species_cannot_decrease_below;
153 };
154 
155 } // namespace Reaktoro
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
The class used to define reactivity restrictions in a chemical equilibrium calculation.
Definition: EquilibriumRestrictions.hpp:28
EquilibriumRestrictions(ChemicalSystem const &system)
Construct an EquilibriumRestrictions object.
auto canIncreaseFreely(String species) -> void
Remove any previously set increase restriction on the amount of a species.
auto cannotDecrease(String species) -> void
Prevent the amount of a species from decreasing during the chemical equilibrium calculation.
auto canDecreaseFreely(String species) -> void
Remove any previously set decrease restriction on the amount of a species.
auto cannotReact(Index ispecies) -> void
Prevent the amount of a species from changing during the chemical equilibrium calculation.
auto speciesCannotDecreaseBelow() const -> Map< Index, double > const &
Return the indices of the species whose amounts cannot decrease below a given value.
auto speciesCannotDecrease() const -> Set< Index > const &
Return the indices of the species whose amounts cannot decrease.
auto cannotDecreaseBelow(Index ispecies, double value, Chars unit="mol") -> void
Prevent the amount/mass of a species from decreasing below a value during the chemical equilibrium ca...
auto canIncreaseFreely(Index ispecies) -> void
Remove any previously set increase restriction on the amount of a species.
auto cannotDecrease(Index ispecies) -> void
Prevent the amount of a species from decreasing during the chemical equilibrium calculation.
auto canReactFreely(String species) -> void
Remove any previously set increase/decrease restriction on the amount of a species.
auto canDecreaseFreely(Index ispecies) -> void
Remove any previously set decrease restriction on the amount of a species.
auto cannotIncreaseAbove(String species, double value, Chars unit="mol") -> void
Prevent the amount/mass of a species from increasing above a value during the chemical equilibrium ca...
auto system() const -> ChemicalSystem const &
Return the chemical system associated with the equilibrium conditions.
auto cannotReact(String species) -> void
Prevent the amount of a species from changing during the chemical equilibrium calculation.
auto cannotDecreaseBelow(String species, double value, Chars unit="mol") -> void
Prevent the amount/mass of a species from decreasing below a value during the chemical equilibrium ca...
auto cannotIncreaseAbove(Index ispecies, double value, Chars unit="mol") -> void
Prevent the amount/mass of a species from increasing above a value during the chemical equilibrium ca...
auto cannotIncrease(Index ispecies) -> void
Prevent the amount of a species from increasing during the chemical equilibrium calculation.
auto speciesCannotIncrease() const -> Set< Index > const &
Return the indices of the species whose amounts cannot increase.
auto canReactFreely(Index ispecies) -> void
Remove any previously set increase/decrease restriction on the amount of a species.
auto speciesCannotIncreaseAbove() const -> Map< Index, double > const &
Return the indices of the species whose amounts cannot increase above a given value.
auto cannotIncrease(String species) -> void
Prevent the amount of a species from increasing during the chemical equilibrium calculation.
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
auto unit(Index rows, Index i) -> decltype(VectorXd::Unit(rows, i))
Return an expression of a unit vector.
Definition: Matrix.hpp:546
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
std::unordered_map< Key, T > Map
Convenient alias for std::unordered_map<Key, T>.
Definition: Types.hpp:74