Reaktoro
A unified framework for modeling chemically reactive systems
Partition.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 #include <vector>
24 
25 // Reaktoro includes
26 #include <Reaktoro/Common/Index.hpp>
27 #include <Reaktoro/Math/Matrix.hpp>
28 
29 namespace Reaktoro {
30 
31 // Forward declarations
32 class ChemicalSystem;
33 
55 class Partition
56 {
57 public:
59  Partition();
60 
65 
67  auto setEquilibriumSpecies(const Indices& ispecies) -> void;
68 
70  auto setEquilibriumSpecies(const std::vector<std::string>& species) -> void;
71 
73  auto setEquilibriumPhases(const Indices& iphases) -> void;
74 
76  auto setEquilibriumPhases(const std::vector<std::string>& phases) -> void;
77 
79  auto setKineticSpecies(const Indices& species) -> void;
80 
82  auto setKineticSpecies(const std::vector<std::string>& species) -> void;
83 
85  auto setKineticPhases(const Indices& iphases) -> void;
86 
88  auto setKineticPhases(const std::vector<std::string>& phases) -> void;
89 
91  auto setInertSpecies(const Indices& species) -> void;
92 
94  auto setInertSpecies(const std::vector<std::string>& species) -> void;
95 
97  auto setInertPhases(const Indices& iphases) -> void;
98 
100  auto setInertPhases(const std::vector<std::string>& phases) -> void;
101 
103  auto setFluidPhases(const Indices& indices) -> void;
104 
106  auto setFluidPhases(const std::vector<std::string>& names) -> void;
107 
109  auto setSolidPhases(const Indices& indices) -> void;
110 
112  auto setSolidPhases(const std::vector<std::string>& names) -> void;
113 
115  auto system() const -> const ChemicalSystem&;
116 
118  auto numFluidPhases() const -> unsigned;
119 
121  auto numFluidSpecies() const -> unsigned;
122 
124  auto numSolidPhases() const -> unsigned;
125 
127  auto numSolidSpecies() const -> unsigned;
128 
130  auto numEquilibriumSpecies() const -> unsigned;
131 
133  auto numEquilibriumFluidSpecies() const -> unsigned;
134 
136  auto numEquilibriumSolidSpecies() const -> unsigned;
137 
139  auto numKineticSpecies() const -> unsigned;
140 
142  auto numKineticFluidSpecies() const -> unsigned;
143 
145  auto numKineticSolidSpecies() const -> unsigned;
146 
148  auto numInertSpecies() const -> unsigned;
149 
151  auto numInertFluidSpecies() const -> unsigned;
152 
154  auto numInertSolidSpecies() const -> unsigned;
155 
157  auto numEquilibriumElements() const -> unsigned;
158 
160  auto numEquilibriumFluidElements() const -> unsigned;
161 
163  auto numEquilibriumSolidElements() const -> unsigned;
164 
166  auto numKineticElements() const -> unsigned;
167 
169  auto numKineticFluidElements() const -> unsigned;
170 
172  auto numKineticSolidElements() const -> unsigned;
173 
175  auto numInertElements() const -> unsigned;
176 
178  auto numInertFluidElements() const -> unsigned;
179 
181  auto numInertSolidElements() const -> unsigned;
182 
184  auto indicesFluidPhases() const -> const Indices&;
185 
187  auto indicesFluidSpecies() const -> const Indices&;
188 
190  auto indicesSolidPhases() const -> const Indices&;
191 
193  auto indicesSolidSpecies() const -> const Indices&;
194 
196  auto indicesEquilibriumSpecies() const -> const Indices&;
197 
199  auto indicesEquilibriumFluidSpecies() const -> const Indices&;
200 
202  auto indicesEquilibriumSolidSpecies() const -> const Indices&;
203 
205  auto indicesKineticSpecies() const -> const Indices&;
206 
208  auto indicesKineticFluidSpecies() const -> const Indices&;
209 
211  auto indicesKineticSolidSpecies() const -> const Indices&;
212 
214  auto indicesInertSpecies() const -> const Indices&;
215 
217  auto indicesInertFluidSpecies() const -> const Indices&;
218 
220  auto indicesInertSolidSpecies() const -> const Indices&;
221 
223  auto indicesEquilibriumElements() const -> const Indices&;
224 
226  auto indicesEquilibriumFluidElements() const -> const Indices&;
227 
229  auto indicesEquilibriumSolidElements() const -> const Indices&;
230 
232  auto indicesKineticElements() const -> const Indices&;
233 
235  auto indicesKineticFluidElements() const -> const Indices&;
236 
238  auto indicesKineticSolidElements() const -> const Indices&;
239 
241  auto indicesInertElements() const -> const Indices&;
242 
244  auto indicesInertFluidElements() const -> const Indices&;
245 
247  auto indicesInertSolidElements() const -> const Indices&;
248 
251 
254 
257 
260 
263 
266 
269 
272 
275 
276 private:
277  struct Impl;
278 
279  std::shared_ptr<Impl> pimpl;
280 };
281 
282 } // namespace Reaktoro
auto indicesKineticElements() const -> const Indices &
Return the indices of the elements in the kinetic partition.
Definition: Partition.cpp:540
auto numInertSpecies() const -> unsigned
Return the number of species in the inert partition.
Definition: Partition.cpp:400
auto numEquilibriumFluidSpecies() const -> unsigned
Return the number of species in the equilibrium-fluid partition.
Definition: Partition.cpp:375
auto numKineticSolidSpecies() const -> unsigned
Return the number of species in the kinetic-solid partition.
Definition: Partition.cpp:395
auto formulaMatrixKineticSolidPartition() const -> MatrixConstRef
Return the formula matrix of the kinetic-solid partition.
Definition: Partition.cpp:595
auto indicesInertSpecies() const -> const Indices &
Return the indices of the species in the inert partition.
Definition: Partition.cpp:510
auto numInertFluidElements() const -> unsigned
Return the number of elements in the inert-fluid partition.
Definition: Partition.cpp:450
auto setInertSpecies(const Indices &species) -> void
Set the inert species of the chemical system.
Definition: Partition.cpp:305
auto indicesKineticSolidSpecies() const -> const Indices &
Return the indices of the species in the kinetic-solid partition.
Definition: Partition.cpp:505
auto indices(const std::vector< std::string > &names, const NamedValues &values) -> Indices
Return the indices of some entries in a container.
Definition: SetUtils.hxx:59
auto names(const NamedValues &values) -> std::vector< std::string >
Return the names of the entries in a container.
Definition: Utils.hxx:22
auto indicesEquilibriumFluidElements() const -> const Indices &
Return the indices of the elements in the equilibrium-fluid partition.
Definition: Partition.cpp:530
auto indicesKineticSolidElements() const -> const Indices &
Return the indices of the elements in the kinetic-solid partition.
Definition: Partition.cpp:550
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
auto formulaMatrixInertPartition() const -> MatrixConstRef
Return the formula matrix of the inert partition.
Definition: Partition.cpp:600
auto setKineticSpecies(const Indices &species) -> void
Set the kinetic species of the chemical system.
Definition: Partition.cpp:285
auto setFluidPhases(const Indices &indices) -> void
Set the fluid phases of the chemical system.
Definition: Partition.cpp:325
auto numInertFluidSpecies() const -> unsigned
Return the number of species in the inert-fluid partition.
Definition: Partition.cpp:405
auto numKineticSolidElements() const -> unsigned
Return the number of elements in the kinetic-solid partition.
Definition: Partition.cpp:440
auto indicesEquilibriumSolidSpecies() const -> const Indices &
Return the indices of the species in the equilibrium-solid partition.
Definition: Partition.cpp:490
auto indicesEquilibriumSolidElements() const -> const Indices &
Return the indices of the elements in the equilibrium-solid partition.
Definition: Partition.cpp:535
auto numInertSolidSpecies() const -> unsigned
Return the number of species in the inert-solid partition.
Definition: Partition.cpp:410
auto numEquilibriumElements() const -> unsigned
Return the number of elements in the equilibrium partition.
Definition: Partition.cpp:415
auto numSolidPhases() const -> unsigned
Return the number of phases in the solid partition.
Definition: Partition.cpp:360
auto indicesInertFluidSpecies() const -> const Indices &
Return the indices of the species in the inert-fluid partition.
Definition: Partition.cpp:515
auto indicesEquilibriumSpecies() const -> const Indices &
Return the indices of the species in the equilibrium partition.
Definition: Partition.cpp:480
auto indicesInertFluidElements() const -> const Indices &
Return the indices of the elements in the inert-fluid partition.
Definition: Partition.cpp:560
auto formulaMatrixEquilibriumPartition() const -> MatrixConstRef
Return the formula matrix of the equilibrium partition.
Definition: Partition.cpp:570
auto indicesEquilibriumElements() const -> const Indices &
Return the indices of the elements in the equilibrium partition.
Definition: Partition.cpp:525
auto indicesInertSolidElements() const -> const Indices &
Return the indices of the elements in the inert-solid partition.
Definition: Partition.cpp:565
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto numKineticElements() const -> unsigned
Return the number of elements in the kinetic partition.
Definition: Partition.cpp:430
auto formulaMatrixKineticPartition() const -> MatrixConstRef
Return the formula matrix of the kinetic partition.
Definition: Partition.cpp:585
auto numInertElements() const -> unsigned
Return the number of elements in the inert partition.
Definition: Partition.cpp:445
auto formulaMatrixInertFluidPartition() const -> MatrixConstRef
Return the formula matrix of the inert-fluid partition.
Definition: Partition.cpp:605
auto numKineticSpecies() const -> unsigned
Return the number of species in the kinetic partition.
Definition: Partition.cpp:385
auto numKineticFluidElements() const -> unsigned
Return the number of elements in the kinetic-fluid partition.
Definition: Partition.cpp:435
auto setEquilibriumPhases(const Indices &iphases) -> void
Set the equilibrium species of the chemical system as the species in given phases.
Definition: Partition.cpp:275
auto numEquilibriumSolidElements() const -> unsigned
Return the number of elements in the equilibrium-solid partition.
Definition: Partition.cpp:425
auto numFluidSpecies() const -> unsigned
Return the number of species in the fluid partition.
Definition: Partition.cpp:355
auto indicesEquilibriumFluidSpecies() const -> const Indices &
Return the indices of the species in the equilibrium-fluid partition.
Definition: Partition.cpp:485
auto formulaMatrixKineticFluidPartition() const -> MatrixConstRef
Return the formula matrix of the kinetic-fluid partition.
Definition: Partition.cpp:590
auto indicesKineticSpecies() const -> const Indices &
Return the indices of the species in the kinetic partition.
Definition: Partition.cpp:495
auto numKineticFluidSpecies() const -> unsigned
Return the number of species in the kinetic-fluid partition.
Definition: Partition.cpp:390
auto setEquilibriumSpecies(const Indices &ispecies) -> void
Set the equilibrium species of the chemical system.
Definition: Partition.cpp:265
auto indicesFluidSpecies() const -> const Indices &
Return the indices of the species in the fluid partition.
Definition: Partition.cpp:465
auto numFluidPhases() const -> unsigned
Return the number of phases in the fluid partition.
Definition: Partition.cpp:350
auto indicesSolidPhases() const -> const Indices &
Return the indices of the phases in the solid partition.
Definition: Partition.cpp:470
Partition()
Construct a default Partition instance.
Definition: Partition.cpp:257
auto numSolidSpecies() const -> unsigned
Return the number of species in the solid partition.
Definition: Partition.cpp:365
auto numInertSolidElements() const -> unsigned
Return the number of elements in the inert-solid partition.
Definition: Partition.cpp:455
std::vector< Index > Indices
Define a type that represents a collection of indices.
Definition: Index.hpp:29
Provide a computational representation of the Partition of a chemical system.
Definition: Partition.hpp:56
auto formulaMatrixEquilibriumSolidPartition() const -> MatrixConstRef
Return the formula matrix of the equilibrium-solid partition.
Definition: Partition.cpp:580
auto numEquilibriumSolidSpecies() const -> unsigned
Return the number of species in the equilibrium-solid partition.
Definition: Partition.cpp:380
auto indicesKineticFluidSpecies() const -> const Indices &
Return the indices of the species in the kinetic-fluid partition.
Definition: Partition.cpp:500
auto numEquilibriumSpecies() const -> unsigned
Return the number of species in the equilibrium partition.
Definition: Partition.cpp:370
auto indicesFluidPhases() const -> const Indices &
Return the indices of the phases in the fluid partition.
Definition: Partition.cpp:460
Eigen::Ref< const Eigen::MatrixXd > MatrixConstRef
Alias to Eigen type Ref<const MatrixXd>.
Definition: Matrix.hpp:44
auto formulaMatrixInertSolidPartition() const -> MatrixConstRef
Return the formula matrix of the inert-solid partition.
Definition: Partition.cpp:610
auto setSolidPhases(const Indices &indices) -> void
Set the solid phases of the chemical system.
Definition: Partition.cpp:335
auto numEquilibriumFluidElements() const -> unsigned
Return the number of elements in the equilibrium-fluid partition.
Definition: Partition.cpp:420
auto system() const -> const ChemicalSystem &
Return the chemical system.
Definition: Partition.cpp:345
auto indicesKineticFluidElements() const -> const Indices &
Return the indices of the elements in the kinetic-fluid partition.
Definition: Partition.cpp:545
auto indicesSolidSpecies() const -> const Indices &
Return the indices of the species in the solid partition.
Definition: Partition.cpp:475
auto formulaMatrixEquilibriumFluidPartition() const -> MatrixConstRef
Return the formula matrix of the equilibrium-fluid partition.
Definition: Partition.cpp:575
auto setInertPhases(const Indices &iphases) -> void
Set the inert species of the chemical system as the species in given phases.
Definition: Partition.cpp:315
auto indicesInertElements() const -> const Indices &
Return the indices of the elements in the inert partition.
Definition: Partition.cpp:555
auto setKineticPhases(const Indices &iphases) -> void
Set the kinetic species of the chemical system as the species in given phases.
Definition: Partition.cpp:295
auto indicesInertSolidSpecies() const -> const Indices &
Return the indices of the species in the inert-solid partition.
Definition: Partition.cpp:520