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-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 #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 
250  auto formulaMatrixEquilibriumPartition() const -> const Matrix&;
251 
253  auto formulaMatrixEquilibriumFluidPartition() const -> const Matrix&;
254 
256  auto formulaMatrixEquilibriumSolidPartition() const -> const Matrix&;
257 
259  auto formulaMatrixKineticPartition() const -> const Matrix&;
260 
262  auto formulaMatrixKineticFluidPartition() const -> const Matrix&;
263 
265  auto formulaMatrixKineticSolidPartition() const -> const Matrix&;
266 
268  auto formulaMatrixInertPartition() const -> const Matrix&;
269 
271  auto formulaMatrixInertFluidPartition() const -> const Matrix&;
272 
274  auto formulaMatrixInertSolidPartition() const -> const Matrix&;
275 
276 private:
277  struct Impl;
278 
279  std::shared_ptr<Impl> pimpl;
280 };
281 
282 } // namespace Reaktoro
Eigen::MatrixXd Matrix
Define an alias to the matrix type of the Eigen library.
Definition: Matrix.hpp:387
auto indicesSolidPhases() const -> const Indices &
Return the indices of the phases in the solid partition.
Definition: Partition.cpp:470
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 setInertPhases(const Indices &iphases) -> void
Set the inert species of the chemical system as the species in given phases.
Definition: Partition.cpp:315
auto formulaMatrixEquilibriumPartition() const -> const Matrix &
Return the formula matrix of the equilibrium partition.
Definition: Partition.cpp:570
auto indicesEquilibriumSolidElements() const -> const Indices &
Return the indices of the elements in the equilibrium-solid partition.
Definition: Partition.cpp:535
auto formulaMatrixEquilibriumSolidPartition() const -> const Matrix &
Return the formula matrix of the equilibrium-solid partition.
Definition: Partition.cpp:580
auto indicesKineticElements() const -> const Indices &
Return the indices of the elements in the kinetic partition.
Definition: Partition.cpp:540
auto formulaMatrixInertFluidPartition() const -> const Matrix &
Return the formula matrix of the inert-fluid partition.
Definition: Partition.cpp:605
auto indicesFluidSpecies() const -> const Indices &
Return the indices of the species in the fluid partition.
Definition: Partition.cpp:465
std::vector< Index > Indices
Define a type that represents a collection of indices.
Definition: Index.hpp:29
auto numEquilibriumFluidElements() const -> unsigned
Return the number of elements in the equilibrium-fluid partition.
Definition: Partition.cpp:420
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:47
auto names(const NamedValues &values) -> std::vector< std::string >
Return the names of the entries in a container.
Definition: Utils.hxx:22
auto formulaMatrixKineticFluidPartition() const -> const Matrix &
Return the formula matrix of the kinetic-fluid partition.
Definition: Partition.cpp:590
Partition()
Construct a default Partition instance.
Definition: Partition.cpp:257
auto numKineticFluidSpecies() const -> unsigned
Return the number of species in the kinetic-fluid partition.
Definition: Partition.cpp:390
auto indicesEquilibriumSolidSpecies() const -> const Indices &
Return the indices of the species in the equilibrium-solid partition.
Definition: Partition.cpp:490
auto indicesInertFluidElements() const -> const Indices &
Return the indices of the elements in the inert-fluid partition.
Definition: Partition.cpp:560
auto numInertSolidSpecies() const -> unsigned
Return the number of species in the inert-solid partition.
Definition: Partition.cpp:410
auto setEquilibriumSpecies(const Indices &ispecies) -> void
Set the equilibrium species of the chemical system.
Definition: Partition.cpp:265
auto numKineticSolidSpecies() const -> unsigned
Return the number of species in the kinetic-solid partition.
Definition: Partition.cpp:395
auto indicesInertElements() const -> const Indices &
Return the indices of the elements in the inert partition.
Definition: Partition.cpp:555
auto indicesSolidSpecies() const -> const Indices &
Return the indices of the species in the solid partition.
Definition: Partition.cpp:475
auto indicesEquilibriumFluidElements() const -> const Indices &
Return the indices of the elements in the equilibrium-fluid partition.
Definition: Partition.cpp:530
auto indicesInertFluidSpecies() const -> const Indices &
Return the indices of the species in the inert-fluid partition.
Definition: Partition.cpp:515
auto formulaMatrixInertSolidPartition() const -> const Matrix &
Return the formula matrix of the inert-solid partition.
Definition: Partition.cpp:610
auto formulaMatrixKineticSolidPartition() const -> const Matrix &
Return the formula matrix of the kinetic-solid partition.
Definition: Partition.cpp:595
auto setKineticSpecies(const Indices &species) -> void
Set the kinetic species of the chemical system.
Definition: Partition.cpp:285
auto indicesKineticFluidSpecies() const -> const Indices &
Return the indices of the species in the kinetic-fluid partition.
Definition: Partition.cpp:500
auto numEquilibriumFluidSpecies() const -> unsigned
Return the number of species in the equilibrium-fluid partition.
Definition: Partition.cpp:375
auto numFluidSpecies() const -> unsigned
Return the number of species in the fluid partition.
Definition: Partition.cpp:355
auto indicesEquilibriumSpecies() const -> const Indices &
Return the indices of the species in the equilibrium partition.
Definition: Partition.cpp:480
auto numKineticFluidElements() const -> unsigned
Return the number of elements in the kinetic-fluid partition.
Definition: Partition.cpp:435
auto indicesInertSolidSpecies() const -> const Indices &
Return the indices of the species in the inert-solid partition.
Definition: Partition.cpp:520
auto numInertSolidElements() const -> unsigned
Return the number of elements in the inert-solid partition.
Definition: Partition.cpp:455
auto indicesFluidPhases() const -> const Indices &
Return the indices of the phases in the fluid partition.
Definition: Partition.cpp:460
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 indicesKineticFluidElements() const -> const Indices &
Return the indices of the elements in the kinetic-fluid partition.
Definition: Partition.cpp:545
auto formulaMatrixInertPartition() const -> const Matrix &
Return the formula matrix of the inert partition.
Definition: Partition.cpp:600
auto numKineticSpecies() const -> unsigned
Return the number of species in the kinetic partition.
Definition: Partition.cpp:385
auto numEquilibriumSolidSpecies() const -> unsigned
Return the number of species in the equilibrium-solid partition.
Definition: Partition.cpp:380
auto setInertSpecies(const Indices &species) -> void
Set the inert species of the chemical system.
Definition: Partition.cpp:305
auto formulaMatrixKineticPartition() const -> const Matrix &
Return the formula matrix of the kinetic partition.
Definition: Partition.cpp:585
auto numInertSpecies() const -> unsigned
Return the number of species in the inert partition.
Definition: Partition.cpp:400
Provide a computational representation of the Partition of a chemical system.
Definition: Partition.hpp:55
auto indicesKineticSolidSpecies() const -> const Indices &
Return the indices of the species in the kinetic-solid partition.
Definition: Partition.cpp:505
auto numFluidPhases() const -> unsigned
Return the number of phases in the fluid partition.
Definition: Partition.cpp:350
auto formulaMatrixEquilibriumFluidPartition() const -> const Matrix &
Return the formula matrix of the equilibrium-fluid partition.
Definition: Partition.cpp:575
auto setSolidPhases(const Indices &indices) -> void
Set the solid phases of the chemical system.
Definition: Partition.cpp:335
auto system() const -> const ChemicalSystem &
Return the chemical system.
Definition: Partition.cpp:345
auto indicesEquilibriumElements() const -> const Indices &
Return the indices of the elements in the equilibrium partition.
Definition: Partition.cpp:525
auto numInertFluidSpecies() const -> unsigned
Return the number of species in the inert-fluid partition.
Definition: Partition.cpp:405
auto indicesKineticSpecies() const -> const Indices &
Return the indices of the species in the kinetic partition.
Definition: Partition.cpp:495
auto numEquilibriumElements() const -> unsigned
Return the number of elements in the equilibrium partition.
Definition: Partition.cpp:415
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 indicesInertSpecies() const -> const Indices &
Return the indices of the species in the inert partition.
Definition: Partition.cpp:510
auto numSolidPhases() const -> unsigned
Return the number of phases in the solid partition.
Definition: Partition.cpp:360
auto numInertElements() const -> unsigned
Return the number of elements in the inert partition.
Definition: Partition.cpp:445
auto indicesKineticSolidElements() const -> const Indices &
Return the indices of the elements in the kinetic-solid partition.
Definition: Partition.cpp:550
auto setFluidPhases(const Indices &indices) -> void
Set the fluid phases of the chemical system.
Definition: Partition.cpp:325
auto numInertFluidElements() const -> unsigned
Return the number of elements in the inert-fluid partition.
Definition: Partition.cpp:450
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto indicesEquilibriumFluidSpecies() const -> const Indices &
Return the indices of the species in the equilibrium-fluid partition.
Definition: Partition.cpp:485
auto numKineticSolidElements() const -> unsigned
Return the number of elements in the kinetic-solid partition.
Definition: Partition.cpp:440
auto numKineticElements() const -> unsigned
Return the number of elements in the kinetic partition.
Definition: Partition.cpp:430
auto numEquilibriumSpecies() const -> unsigned
Return the number of species in the equilibrium partition.
Definition: Partition.cpp:370
auto numSolidSpecies() const -> unsigned
Return the number of species in the solid partition.
Definition: Partition.cpp:365
auto numEquilibriumSolidElements() const -> unsigned
Return the number of elements in the equilibrium-solid partition.
Definition: Partition.cpp:425
auto indicesInertSolidElements() const -> const Indices &
Return the indices of the elements in the inert-solid partition.
Definition: Partition.cpp:565