Reaktoro
A unified framework for modeling chemically reactive systems
ChemicalEditor.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 
27 namespace Reaktoro {
28 
29 // Forward declarations
30 class AqueousPhase;
31 class ChemicalSystem;
32 class Database;
33 class GaseousPhase;
34 class MineralPhase;
35 class MineralReaction;
36 class ReactionSystem;
37 class StringList;
38 
80 {
81 public:
86 
88  explicit ChemicalEditor(const Database& database);
89 
91  ChemicalEditor(const ChemicalEditor& other);
92 
94  virtual ~ChemicalEditor();
95 
97  auto operator=(const ChemicalEditor& other) -> ChemicalEditor&;
98 
102  auto setTemperatures(std::vector<double> values, std::string units) -> void;
103 
107  auto setPressures(std::vector<double> values, std::string units) -> void;
108 
111  auto initializePhasesWithElements(const StringList& elements) -> void;
112 
119  auto addPhase(const AqueousPhase& phase) -> AqueousPhase&;
120 
127  auto addPhase(const GaseousPhase& phase) -> GaseousPhase&;
128 
134  auto addPhase(const MineralPhase& phase) -> MineralPhase&;
135 
139  auto addReaction(const MineralReaction& reaction) -> MineralReaction&;
140 
167  auto addAqueousPhase(const StringList& species) -> AqueousPhase&;
168 
188  auto addAqueousPhaseWithElements(const StringList& elements) -> AqueousPhase&;
189 
211  auto addAqueousPhaseWithElementsOf(const StringList& compounds)->AqueousPhase&;
212 
237  auto addGaseousPhase(const StringList& species) -> GaseousPhase&;
238 
255  auto addGaseousPhaseWithElements(const StringList& elements) -> GaseousPhase&;
256 
264  // These species will then be used to construct the GaseousPhase object.
275  auto addGaseousPhaseWithElementsOf(const StringList& compounds)->GaseousPhase&;
276 
309  auto addMineralPhase(const StringList& species) -> MineralPhase&;
310 
337  auto addMineralPhaseWithElements(const StringList& elements) -> MineralPhase&;
338 
364  auto addMineralPhaseWithElementsOf(const StringList& compounds) -> MineralPhase&;
365 
369  auto addMineralReaction(const MineralReaction& reaction) -> MineralReaction&;
370 
374  auto addMineralReaction(std::string mineral) -> MineralReaction&;
375 
377  auto aqueousPhase() const -> const AqueousPhase&;
378 
380  auto aqueousPhase() -> AqueousPhase&;
381 
383  auto gaseousPhase() const -> const GaseousPhase&;
384 
386  auto gaseousPhase() -> GaseousPhase&;
387 
389  auto mineralPhases() const -> const std::vector<MineralPhase>&;
390 
392  auto mineralPhases() -> std::vector<MineralPhase>&;
393 
395  auto createChemicalSystem() const -> ChemicalSystem;
396 
398  auto createReactionSystem() const -> ReactionSystem;
399 
401  operator ChemicalSystem() const;
402 
404  operator ReactionSystem() const;
405 
406 private:
407  struct Impl;
408 
409  std::unique_ptr<Impl> pimpl;
410 };
411 
412 } // namespace Reaktoro
auto addGaseousPhase(const StringList &species) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:511
auto operator=(const ChemicalEditor &other) -> ChemicalEditor &
Assign this ChemicalEditor instance with another.
Definition: ChemicalEditor.cpp:455
Definition: MineralReaction.hpp:37
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:37
auto setTemperatures(std::vector< double > values, std::string units) -> void
Set the temperatures for constructing interpolation tables of thermodynamic properties.
Definition: ChemicalEditor.cpp:461
auto addMineralPhaseWithElements(const StringList &elements) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:531
auto addMineralReaction(const MineralReaction &reaction) -> MineralReaction &
Add a mineral reaction in the chemical editor.
Definition: ChemicalEditor.cpp:541
Provides operations to retrive physical and thermodynamic data of chemical species.
Definition: Database.hpp:63
auto database(std::string name) -> std::string
Return the contents of a built-in database as a string.
Definition: DatabaseUtils.cpp:65
auto aqueousPhase() const -> const AqueousPhase &
Return the aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:551
auto addAqueousPhase(const StringList &species) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:496
Provides convenient operations to initialize ChemicalSystem and ReactionSystem instances.
Definition: ChemicalEditor.hpp:79
auto createReactionSystem() const -> ReactionSystem
Create a ReactionSystem instance with the current state of the chemical editor.
Definition: ChemicalEditor.cpp:586
A class for representing a list of strings with special constructors.
Definition: StringList.hpp:27
auto createChemicalSystem() const -> ChemicalSystem
Create a ChemicalSystem instance with the current state of the chemical editor.
Definition: ChemicalEditor.cpp:581
auto initializePhasesWithElements(const StringList &elements) -> void
Initialize all possible phases that can exist with given elements.
Definition: ChemicalEditor.cpp:471
virtual ~ChemicalEditor()
Destroy the ChemicalEditor instance.
Definition: ChemicalEditor.cpp:452
auto addMineralPhase(const StringList &species) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:526
auto setPressures(std::vector< double > values, std::string units) -> void
Set the pressures for constructing interpolation tables of thermodynamic properties.
Definition: ChemicalEditor.cpp:466
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:41
Class that defines a gaseous phase.
Definition: GaseousPhase.hpp:32
auto gaseousPhase() const -> const GaseousPhase &
Return the gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:561
auto mineralPhases() const -> const std::vector< MineralPhase > &
Return the mineral phases in the chemical editor.
Definition: ChemicalEditor.cpp:571
auto addReaction(const MineralReaction &reaction) -> MineralReaction &
Add a mineral reaction in the chemical editor.
Definition: ChemicalEditor.cpp:491
auto addPhase(const AqueousPhase &phase) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:476
auto addAqueousPhaseWithElements(const StringList &elements) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:501
Definition: Units.cpp:38
auto addAqueousPhaseWithElementsOf(const StringList &compounds) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:506
auto addGaseousPhaseWithElements(const StringList &elements) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:516
auto addGaseousPhaseWithElementsOf(const StringList &compounds) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:521
A type used to describe an aqueous phase.
Definition: AqueousPhase.hpp:36
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
Class that defines an mineral phase.
Definition: MineralPhase.hpp:33
auto addMineralPhaseWithElementsOf(const StringList &compounds) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:536
ChemicalEditor()
Construct a default ChemicalEditor instance.
Definition: ChemicalEditor.cpp:440
auto elements() -> std::vector< std::string >
Return a vector of all known 116 chemical elements.
Definition: ElementUtils.cpp:155