Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
IonExchangeProps.hpp
1 // Reaktoro is a unified framework for modeling chemically reactive systems.
2 //
3 // Copyright © 2014-2024 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 // Reaktoro includes
21 #include <Reaktoro/Common/Types.hpp>
22 #include <Reaktoro/Common/Matrix.hpp>
23 
24 namespace Reaktoro {
25 
26 // Forward declarations
27 class ChemicalProps;
28 class ChemicalState;
29 class ChemicalSystem;
30 class Phase;
31 
34 {
35 public:
37  explicit IonExchangeProps(const ChemicalSystem& system);
38 
40  explicit IonExchangeProps(const ChemicalState& state);
41 
43  explicit IonExchangeProps(const ChemicalProps& props);
44 
47 
49  virtual ~IonExchangeProps();
50 
53 
55  auto update(const ChemicalState& state) -> void;
56 
58  auto update(const ChemicalProps& props) -> void;
59 
61  auto elementAmount(const StringOrIndex& symbol) const -> real;
62 
64  auto elementAmounts() const -> ArrayXr;
65 
67  auto speciesAmounts() const -> ArrayXr;
68 
70  auto speciesAmount(const StringOrIndex& name) const -> real;
71 
73  auto speciesEquivalents() const -> ArrayXr;
74 
76  auto speciesEquivalent(const StringOrIndex& name) const -> real;
77 
80 
82  auto speciesEquivalentFraction(const StringOrIndex& name) const -> real;
83 
86 
88  auto speciesActivityCoefficientLg(const StringOrIndex& name) const -> real;
89 
91  auto phase() const -> const Phase&;
92 
94  auto output(std::ostream& out) const -> void;
95 
97  auto output(const String& filename) const -> void;
98 
99 private:
100  struct Impl;
101 
102  Ptr<Impl> pimpl;
103 };
104 
106 auto operator<<(std::ostream& out, const IonExchangeProps& state) -> std::ostream&;
107 
108 } // namespace Reaktoro
The class that computes chemical properties of a chemical system.
Definition: ChemicalProps.hpp:34
The chemical state of a chemical system.
Definition: ChemicalState.hpp:41
The class used to represent a chemical system and its attributes and properties.
Definition: ChemicalSystem.hpp:70
The chemical properties of an aqueous phase.
Definition: IonExchangeProps.hpp:34
auto speciesAmounts() const -> ArrayXr
Return the amounts of the species on the ion exchange surface (in moles).
IonExchangeProps(const ChemicalProps &props)
Construct an IonExchangeProps object with given chemical properties of the system.
auto speciesActivityCoefficientsLg() const -> ArrayXr
Return the logarithms of the activity coefficients of the species on the ion exchange surface (in mol...
IonExchangeProps(const ChemicalState &state)
Construct an IonExchangeProps object with given chemical state of the system.
auto elementAmounts() const -> ArrayXr
Return the amounts of the elements (in moles).
auto operator=(IonExchangeProps other) -> IonExchangeProps &
Assign a IonExchangeProps object to this object.
auto phase() const -> const Phase &
Return the underlying Phase object for the ion exchange phase.
auto output(std::ostream &out) const -> void
Output the properties of the exchange phase to a stream.
auto update(const ChemicalState &state) -> void
Update the ion exchange properties with given chemical state of the system.
auto speciesEquivalentFraction(const StringOrIndex &name) const -> real
Return the equivalent fraction of an ion exchange species.
IonExchangeProps(const ChemicalSystem &system)
Construct an uninitialized IonExchangeProps object with given chemical system.
auto speciesEquivalentFractions() const -> ArrayXr
Return the equivalent fractions of the species on the ion exchange surface (in moles) if the molar fr...
auto speciesEquivalent(const StringOrIndex &name) const -> real
Return the equivalent of an ion exchange species (in eq).
IonExchangeProps(const IonExchangeProps &other)
Construct a copy of a IonExchangeProps object.
auto speciesActivityCoefficientLg(const StringOrIndex &name) const -> real
Return the base-10 logarithm of the activity coefficients of an ion exchange species.
auto elementAmount(const StringOrIndex &symbol) const -> real
Return the amount of an element (in moles).
auto speciesAmount(const StringOrIndex &name) const -> real
Return the amounts of an ion exchange species (in moles).
auto speciesEquivalents() const -> ArrayXr
Return the equivalents of the species on the ion exchange composition (in eq).
auto update(const ChemicalProps &props) -> void
Update the ion exchange properties with given chemical properties of the system.
virtual ~IonExchangeProps()
Destroy this IonExchangeProps object.
A type used to define a phase and its attributes.
Definition: Phase.hpp:33
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
std::unique_ptr< T > Ptr
Convenient alias for std::unique_ptr<T>.
Definition: Types.hpp:102
std::variant< Index, int, std::string > StringOrIndex
The type used to accept either a name or an index.
Definition: Types.hpp:58
autodiff::ArrayXreal ArrayXr
Convenient alias to Eigen type.
Definition: Matrix.hpp:87