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 // Forward declarations for ThermoFun
26 namespace ThermoFun {
27 
28 class Database;
29 
30 } // namespace ThermoFun
31 
32 namespace Reaktoro {
33 
34 // Forward declarations
35 class AqueousPhase;
36 class ChemicalSystem;
37 class Database;
38 class GaseousPhase;
39 class LiquidPhase;
40 class MineralPhase;
41 class MineralReaction;
42 class ReactionSystem;
43 class StringList;
44 
87 {
88 public:
93 
95  explicit ChemicalEditor(const Database& database);
96 
98  explicit ChemicalEditor(const ThermoFun::Database& database);
99 
101  ChemicalEditor(const ChemicalEditor& other);
102 
104  virtual ~ChemicalEditor();
105 
107  auto operator=(const ChemicalEditor& other) -> ChemicalEditor&;
108 
112  auto setTemperatures(std::vector<double> values, std::string units) -> void;
113 
117  auto setPressures(std::vector<double> values, std::string units) -> void;
118 
121  auto initializePhasesWithElements(const StringList& elements) -> void;
122 
129  auto addPhase(const AqueousPhase& phase) -> AqueousPhase&;
130 
137  auto addPhase(const GaseousPhase& phase) -> GaseousPhase&;
138 
145  auto addPhase(const LiquidPhase& phase) -> LiquidPhase&;
146 
152  auto addPhase(const MineralPhase& phase) -> MineralPhase&;
153 
157  auto addReaction(const MineralReaction& reaction) -> MineralReaction&;
158 
188  auto addAqueousPhase(const StringList& species) -> AqueousPhase&;
189 
212 
235  auto addAqueousPhaseWithElementsOf(const StringList& compounds)->AqueousPhase&;
236 
261  auto addGaseousPhase(const StringList& species) -> GaseousPhase&;
262 
282 
290  // These species will then be used to construct the GaseousPhase object.
302  auto addGaseousPhaseWithElementsOf(const StringList& compounds) -> GaseousPhase&;
303 
328  auto addLiquidPhase(const StringList& species) -> LiquidPhase&;
329 
349 
357  // These species will then be used to construct the LiquidPhase object.
369  auto addLiquidPhaseWithElementsOf(const StringList& compounds) -> LiquidPhase&;
370 
403  auto addMineralPhase(const StringList& species) -> MineralPhase&;
404 
432 
458  auto addMineralPhaseWithElementsOf(const StringList& compounds) -> MineralPhase&;
459 
463  auto addMineralReaction(const MineralReaction& reaction) -> MineralReaction&;
464 
468  auto addMineralReaction(std::string mineral) -> MineralReaction&;
469 
471  auto aqueousPhase() const -> const AqueousPhase&;
472 
474  auto aqueousPhase() -> AqueousPhase&;
475 
477  auto gaseousPhase() const -> const GaseousPhase&;
478 
480  auto gaseousPhase() ->GaseousPhase&;
481 
483  auto liquidPhase() const -> const LiquidPhase&;
484 
486  auto liquidPhase() ->LiquidPhase&;
487 
489  auto mineralPhases() const -> const std::vector<MineralPhase>&;
490 
492  auto mineralPhases() -> std::vector<MineralPhase>&;
493 
495  auto createChemicalSystem() const -> ChemicalSystem;
496 
498  auto createReactionSystem() const -> ReactionSystem;
499 
501  operator ChemicalSystem() const;
502 
504  operator ReactionSystem() const;
505 
506 private:
507  struct Impl;
508 
509  std::unique_ptr<Impl> pimpl;
510 };
511 
512 } // namespace Reaktoro
A class for representing a list of strings with special constructors.
Definition: StringList.hpp:28
Provides operations to retrieve physical and thermodynamic data of chemical species.
Definition: Database.hpp:78
auto mineralPhases() const -> const std::vector< MineralPhase > &
Return the mineral phases in the chemical editor.
Definition: ChemicalEditor.cpp:683
Definition: MineralReaction.hpp:38
auto addLiquidPhaseWithElements(const StringList &elements) -> LiquidPhase &
Add a liquid phase in the chemical editor.
Definition: ChemicalEditor.cpp:618
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:38
auto addPhase(const AqueousPhase &phase) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:558
auto gaseousPhase() const -> const GaseousPhase &
Return the gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:663
auto addMineralPhase(const StringList &species) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:628
Provides convenient operations to initialize ChemicalSystem and ReactionSystem instances.
Definition: ChemicalEditor.hpp:87
auto database(std::string name) -> std::string
Return the contents of a built-in database as a string.
Definition: DatabaseUtils.cpp:65
A type used to describe an aqueous phase.
Definition: AqueousPhase.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:543
ChemicalEditor()
Construct a default ChemicalEditor instance.
Definition: ChemicalEditor.cpp:518
auto addAqueousPhase(const StringList &species) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:583
auto addAqueousPhaseWithElementsOf(const StringList &compounds) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:593
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto addMineralPhaseWithElementsOf(const StringList &compounds) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:638
auto elements() -> std::vector< std::string >
Return a vector of all known 116 chemical elements.
Definition: ElementUtils.cpp:155
auto addReaction(const MineralReaction &reaction) -> MineralReaction &
Add a mineral reaction in the chemical editor.
Definition: ChemicalEditor.cpp:578
auto addMineralPhaseWithElements(const StringList &elements) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:633
virtual ~ChemicalEditor()
Destroy the ChemicalEditor instance.
Definition: ChemicalEditor.cpp:534
Class that defines a mineral phase.
Definition: MineralPhase.hpp:34
auto createChemicalSystem() const -> ChemicalSystem
Create a ChemicalSystem instance with the current state of the chemical editor.
Definition: ChemicalEditor.cpp:693
Definition: GaseousPhase.hpp:32
auto liquidPhase() const -> const LiquidPhase &
Return the liquid phase in the chemical editor.
Definition: ChemicalEditor.cpp:673
auto addGaseousPhase(const StringList &species) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:598
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:42
auto addMineralReaction(const MineralReaction &reaction) -> MineralReaction &
Add a mineral reaction in the chemical editor.
Definition: ChemicalEditor.cpp:643
Definition: LiquidPhase.hpp:32
auto addAqueousPhaseWithElements(const StringList &elements) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:588
auto createReactionSystem() const -> ReactionSystem
Create a ReactionSystem instance with the current state of the chemical editor.
Definition: ChemicalEditor.cpp:698
auto addGaseousPhaseWithElementsOf(const StringList &compounds) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:608
auto operator=(const ChemicalEditor &other) -> ChemicalEditor &
Assign this ChemicalEditor instance with another.
Definition: ChemicalEditor.cpp:537
auto setPressures(std::vector< double > values, std::string units) -> void
Set the pressures for constructing interpolation tables of thermodynamic properties.
Definition: ChemicalEditor.cpp:548
auto initializePhasesWithElements(const StringList &elements) -> void
Initialize all possible phases that can exist with given elements.
Definition: ChemicalEditor.cpp:553
auto addGaseousPhaseWithElements(const StringList &elements) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:603
auto addLiquidPhase(const StringList &species) -> LiquidPhase &
Add a liquid phase in the chemical editor.
Definition: ChemicalEditor.cpp:613
auto aqueousPhase() const -> const AqueousPhase &
Return the aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:653
auto addLiquidPhaseWithElementsOf(const StringList &compounds) -> LiquidPhase &
Add a liquid phase in the chemical editor.
Definition: ChemicalEditor.cpp:623