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 <string>
22 #include <vector>
23 #include <memory>
24 
25 // Reaktoro includes
26 
27 namespace Reaktoro {
28 
29 // Forward declarations
30 class Database;
31 class AqueousPhase;
32 class GaseousPhase;
33 class MineralPhase;
34 class ChemicalSystem;
35 class ReactionSystem;
36 class MineralReaction;
37 
79 {
80 public:
85 
87  explicit ChemicalEditor(const Database& database);
88 
90  ChemicalEditor(const ChemicalEditor& other);
91 
93  virtual ~ChemicalEditor();
94 
96  auto operator=(const ChemicalEditor& other) -> ChemicalEditor&;
97 
101  auto setTemperatures(std::vector<double> values, std::string units) -> void;
102 
106  auto setPressures(std::vector<double> values, std::string units) -> void;
107 
110  auto initializePhasesWithElements(std::vector<std::string> elements) -> void;
111 
118  auto addPhase(const AqueousPhase& phase) -> AqueousPhase&;
119 
126  auto addPhase(const GaseousPhase& phase) -> GaseousPhase&;
127 
133  auto addPhase(const MineralPhase& phase) -> MineralPhase&;
134 
138  auto addReaction(const MineralReaction& reaction) -> MineralReaction&;
139 
161  auto addAqueousPhase(std::vector<std::string> species) -> AqueousPhase&;
162 
164  auto addAqueousPhase(std::initializer_list<std::string> species) -> AqueousPhase&;
165 
201  auto addAqueousPhase(std::string compounds) -> AqueousPhase&;
202 
224  auto addGaseousPhase(std::vector<std::string> species) -> GaseousPhase&;
225 
227  auto addGaseousPhase(std::initializer_list<std::string> species) -> GaseousPhase&;
228 
262  auto addGaseousPhase(std::string compounds) -> GaseousPhase&;
263 
296  auto addMineralPhase(std::vector<std::string> species) -> MineralPhase&;
297 
299  auto addMineralPhase(std::initializer_list<std::string> species) -> MineralPhase&;
300 
333  auto addMineralPhase(std::string compounds) -> MineralPhase&;
334 
338  auto addMineralReaction(const MineralReaction& reaction) -> MineralReaction&;
339 
343  auto addMineralReaction(std::string mineral) -> MineralReaction&;
344 
346  auto aqueousPhase() const -> const AqueousPhase&;
347 
349  auto aqueousPhase() -> AqueousPhase&;
350 
352  auto gaseousPhase() const -> const GaseousPhase&;
353 
355  auto gaseousPhase() -> GaseousPhase&;
356 
358  auto mineralPhases() const -> const std::vector<MineralPhase>&;
359 
361  auto mineralPhases() -> std::vector<MineralPhase>&;
362 
364  auto createChemicalSystem() const -> ChemicalSystem;
365 
367  auto createReactionSystem() const -> ReactionSystem;
368 
370  operator ChemicalSystem() const;
371 
373  operator ReactionSystem() const;
374 
375 private:
376  struct Impl;
377 
378  std::unique_ptr<Impl> pimpl;
379 };
380 
381 } // namespace Reaktoro
Provides operations to retrive physical and thermodynamic data of chemical species.
Definition: Database.hpp:63
auto mineralPhases() const -> const std::vector< MineralPhase > &
Return the mineral phases in the chemical editor.
Definition: ChemicalEditor.cpp:605
Definition: MineralReaction.hpp:37
auto addMineralPhase(std::vector< std::string > species) -> MineralPhase &
Add a mineral phase in the chemical editor.
Definition: ChemicalEditor.cpp:560
A class to represent a system and its attributes and properties.
Definition: ChemicalSystem.hpp:37
auto addPhase(const AqueousPhase &phase) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:510
auto gaseousPhase() const -> const GaseousPhase &
Return the gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:595
Provides convenient operations to initialize ChemicalSystem and ReactionSystem instances.
Definition: ChemicalEditor.hpp:78
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:36
auto setTemperatures(std::vector< double > values, std::string units) -> void
Set the temperatures for constructing interpolation tables of thermodynamic properties.
Definition: ChemicalEditor.cpp:495
ChemicalEditor()
Construct a default ChemicalEditor instance.
Definition: ChemicalEditor.cpp:474
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
auto addGaseousPhase(std::vector< std::string > species) -> GaseousPhase &
Add a gaseous phase in the chemical editor.
Definition: ChemicalEditor.cpp:545
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:525
virtual ~ChemicalEditor()
Destroy the ChemicalEditor instance.
Definition: ChemicalEditor.cpp:486
Class that defines an mineral phase.
Definition: MineralPhase.hpp:33
auto createChemicalSystem() const -> ChemicalSystem
Create a ChemicalSystem instance with the current state of the chemical editor.
Definition: ChemicalEditor.cpp:615
Class that defines a gaseous phase.
Definition: GaseousPhase.hpp:32
auto addAqueousPhase(std::vector< std::string > species) -> AqueousPhase &
Add an aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:530
A class that represents a system of chemical reactions.
Definition: ReactionSystem.hpp:41
auto addMineralReaction(const MineralReaction &reaction) -> MineralReaction &
Add a mineral reaction in the chemical editor.
Definition: ChemicalEditor.cpp:575
auto initializePhasesWithElements(std::vector< std::string > elements) -> void
Initialize all possible phases that can exist with given elements.
Definition: ChemicalEditor.cpp:505
auto createReactionSystem() const -> ReactionSystem
Create a ReactionSystem instance with the current state of the chemical editor.
Definition: ChemicalEditor.cpp:620
auto operator=(const ChemicalEditor &other) -> ChemicalEditor &
Assign this ChemicalEditor instance with another.
Definition: ChemicalEditor.cpp:489
auto setPressures(std::vector< double > values, std::string units) -> void
Set the pressures for constructing interpolation tables of thermodynamic properties.
Definition: ChemicalEditor.cpp:500
auto aqueousPhase() const -> const AqueousPhase &
Return the aqueous phase in the chemical editor.
Definition: ChemicalEditor.cpp:585