Reaktoro  v2.11.0
A unified framework for modeling chemically reactive systems
CriticalProps.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/Real.hpp>
22 #include <Reaktoro/Common/StringList.hpp>
23 #include <Reaktoro/Common/Types.hpp>
24 
25 namespace Reaktoro {
26 
29 {
32 
35 
38 };
39 
42 {
43 public:
46 
54 
56  auto setTemperature(real value, String unit) -> void;
57 
59  auto setPressure(real value, String unit) -> void;
60 
62  auto setAcentricFactor(real value) -> void;
63 
65  auto names() const -> Strings const&;
66 
68  auto temperature() const -> real;
69 
71  auto pressure() const -> real;
72 
74  auto acentricFactor() const -> real;
75 
77  auto data() const -> SubstanceCriticalPropsData const&;
78 
80  operator SubstanceCriticalPropsData() const;
81 
82 private:
85 
87  Strings m_names;
88 };
89 
92 {
93 public:
95  CriticalProps(CriticalProps const&) = delete;
96 
98  auto operator=(CriticalProps const&) -> CriticalProps& = delete;
99 
101  static auto instance() -> CriticalProps&;
102 
104  static auto data() -> Deque<SubstanceCriticalProps> const&;
105 
108 
110  static auto append(SubstanceCriticalProps crprops) -> void;
111 
113  static auto overwrite(SubstanceCriticalProps crprops) -> void;
114 
116  static auto setMissingAs(String const& substance) -> void;
117 
119  static auto size() -> Index;
120 
122  static auto find(String const& substance) -> Index;
123 
125  static auto get(String const& substance) -> Optional<SubstanceCriticalProps>;
126 
128  static auto get(StringList const& substances) -> Optional<SubstanceCriticalProps>;
129 
131  auto begin() const { return data().begin(); }
132 
134  auto begin() { return data().begin(); }
135 
137  auto end() const { return data().end(); }
138 
140  auto end() { return data().end(); }
141 
142 private:
145 
147  Optional<SubstanceCriticalProps> m_default_crprops;
148 
149 private:
151  CriticalProps();
152 
154  ~CriticalProps();
155 };
156 
157 } // namespace Reaktoro
A type used store a collection of substances and their critical properties.
Definition: CriticalProps.hpp:92
static auto size() -> Index
Return the number of substances in the database.
static auto get(String const &substance) -> Optional< SubstanceCriticalProps >
Return the substance and its critical properties with given name (e.g. "WATER", "CARBON-DIOXIDE",...
static auto instance() -> CriticalProps &
Return the single CriticalProps object.
static auto append(SubstanceCriticalProps crprops) -> void
Append critical properties for a substance in the database.
static auto data() -> Deque< SubstanceCriticalProps > const &
Return the critical properties data in the database.
static auto find(String const &substance) -> Index
Return the index of a substance in the database or number of substances if not found.
static auto defaultCriticalProps() -> Optional< SubstanceCriticalProps > const &
Return the default critical properties used for missing substances in the database.
static auto setMissingAs(String const &substance) -> void
Set a given existing substance in the database as the default choice for missing substances when usin...
auto end()
Return end iterator of this ChemicalProps instance.
Definition: CriticalProps.hpp:140
static auto overwrite(SubstanceCriticalProps crprops) -> void
Append critical properties for a substance in the database or overwrite if data already exists for th...
static auto get(StringList const &substances) -> Optional< SubstanceCriticalProps >
Return the substance and its critical properties with given alternative names.
CriticalProps(CriticalProps const &)=delete
Construct a copy of a CriticalProps object [deleted].
auto begin() const
Return begin const iterator of this ChemicalProps instance.
Definition: CriticalProps.hpp:131
auto begin()
Return begin iterator of this ChemicalProps instance.
Definition: CriticalProps.hpp:134
auto end() const
Return end const iterator of this ChemicalProps instance.
Definition: CriticalProps.hpp:137
auto operator=(CriticalProps const &) -> CriticalProps &=delete
Assign a CriticalProps object to this [deleted].
A class for representing a list of strings with special constructors.
Definition: StringList.hpp:28
A type used to represent a substance and its critical properties.
Definition: CriticalProps.hpp:42
auto temperature() const -> real
Return the critical temperature of the substance (in K)
auto pressure() const -> real
Return the critical pressure of the substance (in Pa)
auto setAcentricFactor(real value) -> void
Set the acentric factor of the substance.
auto acentricFactor() const -> real
Return the acentric factor of the substance.
auto data() const -> SubstanceCriticalPropsData const &
Return the critical properties data of the substance.
auto names() const -> Strings const &
Return the names that uniquely identify the substance.
auto setTemperature(real value, String unit) -> void
Set the critical temperature of the substance with given unit.
SubstanceCriticalProps(StringList const &names)
Construct a SubstanceCriticalProps instance.
SubstanceCriticalProps(SubstanceCriticalPropsData const &data, StringList const &names)
Construct a SubstanceCriticalProps instance with given data.
auto setPressure(real value, String unit) -> void
Set the critical pressure of the substance with given unit.
The namespace containing all components of the Reaktoro library.
Definition: Algorithms.hpp:29
auto unit(Index rows, Index i) -> decltype(VectorXd::Unit(rows, i))
Return an expression of a unit vector.
Definition: Matrix.hpp:546
std::string String
Convenient alias for std::string.
Definition: Types.hpp:52
std::size_t Index
Define a type that represents an index.
Definition: Index.hpp:26
autodiff::real real
The number type used throughout the library.
Definition: Real.hpp:26
std::vector< std::string > Strings
Convenient alias for std::vector<String>.
Definition: Types.hpp:55
std::deque< T > Deque
Convenient alias for std::deque<T>.
Definition: Types.hpp:70
std::optional< T > Optional
Convenient alias for std::optional<T>.
Definition: Types.hpp:114
A type used to represent the critical properties of a substance.
Definition: CriticalProps.hpp:29
real omega
The acentric factor of the substance.
Definition: CriticalProps.hpp:37
real Tcr
The critical temperature of the substance (in K).
Definition: CriticalProps.hpp:31
real Pcr
The critical pressure of the substance (in Pa).
Definition: CriticalProps.hpp:34