Reaktoro
A unified framework for modeling chemically reactive systems
CubicEOS.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 <functional>
22 #include <memory>
23 #include <string>
24 #include <tuple>
25 #include <vector>
26 
27 // Reaktoro includes
28 #include <Reaktoro/Common/ChemicalScalar.hpp>
29 #include <Reaktoro/Common/ChemicalVector.hpp>
30 #include <Reaktoro/Common/Index.hpp>
31 #include <Reaktoro/Common/TableUtils.hpp>
32 #include <Reaktoro/Common/ThermoScalar.hpp>
33 #include <Reaktoro/Common/ThermoVector.hpp>
34 #include <Reaktoro/Math/Matrix.hpp>
35 #include <Reaktoro/Thermodynamics/EOS/PhaseIdentification.hpp>
36 
37 namespace Reaktoro {
38 
40 class CubicEOS
41 {
42 public:
44  enum Model
45  {
46  VanDerWaals, RedlichKwong, SoaveRedlichKwong, PengRobinson,
47  };
48 
52  {
55 
58 
61  };
62 
65  std::function<InteractionParamsResult(const double&)>;
66 
68  struct Params
69  {
70  Model model = PengRobinson;
71 
75  PhaseIdentificationMethod phase_identification_method = PhaseIdentificationMethod::None;
76 
82  };
83 
84  struct Result
85  {
87  Result();
88 
91  explicit Result(unsigned nspecies);
92 
95 
98 
101 
104 
107 
110 
113 
116 
119  };
120 
123  explicit CubicEOS(unsigned nspecies, Params params);
124 
126  CubicEOS(const CubicEOS& other);
127 
129  virtual ~CubicEOS();
130 
132  auto operator=(CubicEOS other) -> CubicEOS&;
133 
135  auto numSpecies() const -> unsigned;
136 
139  auto setModel(Model model) -> void;
140 
142  auto setPhaseAsLiquid() -> void;
143 
145  auto setPhaseAsVapor() -> void;
146 
148  auto setCriticalTemperatures(const std::vector<double>& values) -> void;
149 
151  auto setCriticalPressures(const std::vector<double>& values) -> void;
152 
154  auto setAcentricFactors(const std::vector<double>& values) -> void;
155 
161 
166  auto operator()(const ThermoScalar& T, const ThermoScalar& P, const ChemicalVector& x) -> Result;
167 
168 private:
169  struct Impl;
170 
171  std::unique_ptr<Impl> pimpl;
172 };
173 
174 } // namespace Reaktoro
auto setPhaseAsLiquid() -> void
Set the equation of state to compute properties for a liquid phase.
Definition: CubicEOS.cpp:600
Parameters to be passed to the Cubic Equation of State.
Definition: CubicEOS.hpp:69
ChemicalScalar molar_volume
The molar volume of the phase (in units of m3/mol).
Definition: CubicEOS.hpp:94
Class to define or store Binary Interaction Parameters (BIPs) from a calculation or input.
Definition: CubicEOS.hpp:52
virtual ~CubicEOS()
Destroy this CubicEOS instance.
Definition: CubicEOS.cpp:581
ChemicalVector ln_fugacity_coefficients
The fugacity coefficients of the species in the phase.
Definition: CubicEOS.hpp:118
ChemicalScalar residual_molar_heat_capacity_cv
The residual molar heat capacity at constant volume of the phase (in units of J/(mol*K)).
Definition: CubicEOS.hpp:106
auto setPhaseAsVapor() -> void
Set the equation of state to compute properties for a vapor phase.
Definition: CubicEOS.cpp:605
auto setModel(Model model) -> void
Set the type of the cubic equation of state (default: PengRobinson).
Definition: CubicEOS.cpp:595
auto setCriticalTemperatures(const std::vector< double > &values) -> void
Set the critical temperatures of the species (in units of K).
Definition: CubicEOS.cpp:610
Eigen::MatrixXd MatrixXd
Alias to Eigen type Eigen::MatrixXd.
Definition: Matrix.hpp:69
auto numSpecies() const -> unsigned
Return the number of species in the phase.
Definition: CubicEOS.cpp:590
CubicEOS(unsigned nspecies, Params params)
Construct a CubicEOS instance with given number of species.
Definition: CubicEOS.cpp:566
MatrixXd kTT
The derivative of each kT entry w.r.t T.
Definition: CubicEOS.hpp:60
InteractionParamsFunction binary_interaction_values
Wrapper function to calculate binary interaction parameters for mixture rules using a Cubic EOS.
Definition: CubicEOS.hpp:81
The namespace containing all components of the Reaktoro library.
Definition: ChemicalScalar.hpp:24
ChemicalScalar residual_molar_gibbs_energy
The residual molar Gibbs energy of the phase (in units of J/mol).
Definition: CubicEOS.hpp:97
ChemicalScalar residual_molar_enthalpy
The residual molar enthalpy of the phase (in units of J/mol).
Definition: CubicEOS.hpp:100
Result()
Construct a default Result instance.
Definition: CubicEOS.cpp:480
ChemicalVector residual_partial_molar_enthalpies
The residual partial molar enthalpies of the species in the phase (in units of J/mol).
Definition: CubicEOS.hpp:115
auto setAcentricFactors(const std::vector< double > &values) -> void
Set the acentric factors of the species.
Definition: CubicEOS.cpp:638
ChemicalVector residual_partial_molar_gibbs_energies
The residual partial molar Gibbs energies of the species in the phase (in units of J/mol).
Definition: CubicEOS.hpp:112
Defines a cubic equation of state and calculates thermodynamic properties of a fluid phase.
Definition: CubicEOS.hpp:41
PhaseIdentificationMethod
Defines the enumeration of available phase identification methods.
Definition: PhaseIdentification.hpp:30
auto operator=(CubicEOS other) -> CubicEOS &
Assign a CubicEOS instance to this.
Definition: CubicEOS.cpp:584
MatrixXd k
The BIPs matrix. The size must be (n, n), where n is the number of species.
Definition: CubicEOS.hpp:54
Model
Defines the enumeration of available cubic EOS models.
Definition: CubicEOS.hpp:45
std::function< InteractionParamsResult(const double &)> InteractionParamsFunction
Function wrapper to calculate (temperature-dependent) binary interaction parameters.
Definition: CubicEOS.hpp:65
auto setCriticalPressures(const std::vector< double > &values) -> void
Set the critical pressures of the species (in units of Pa).
Definition: CubicEOS.cpp:624
ChemicalVector partial_molar_volumes
The partial molar volumes of the species in the phase (in units of m3/mol).
Definition: CubicEOS.hpp:109
auto setInteractionParamsFunction(const InteractionParamsFunction &func) -> void
Set the function that calculates the interaction parameters kij (k) and its temperature derivatives (...
Definition: CubicEOS.cpp:648
PhaseIdentificationMethod phase_identification_method
If both Gaseous and Liquid phases are in the system, it is recommended to configure a robust phase id...
Definition: CubicEOS.hpp:75
MatrixXd kT
The derivative of each k entry w.r.t T.
Definition: CubicEOS.hpp:57
Definition: CubicEOS.hpp:85
ChemicalScalar residual_molar_heat_capacity_cp
The residual molar heat capacity at constant pressure of the phase (in units of J/(mol*K)).
Definition: CubicEOS.hpp:103