BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_GM_EoS_Oxygen.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California,
4 * through Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_CL_GM_EOS_OXYGEN_VAPOR_HPP
13#define BELFEM_CL_GM_EOS_OXYGEN_VAPOR_HPP
14
15#include "en_Helmholtz.hpp"
16#include "cl_GM_Helmholtz.hpp"
17#include "cl_Vector.hpp"
18#include "constants.hpp"
19
20namespace belfem
21{
22 namespace gasmodels
23 {
27 class EoS_Oxygen : public Helmholtz
28 {
29
30 // reference conditions for enthalpy and entropy
31 const real mT0 = BELFEM_TREF ;
32 const real mP0 = BELFEM_PREF ;
33 real mDelta0 = 0.0 ;
34
35 // coefficient for ideal gas contribution
37
38 // coefficients for real gas contribution
43 Vector< real > mT ; // actually s in paper
44
45 // container with evaluated values for real gas contribution
46 mutable Vector< real > mDeltaPowD ;
47 mutable Vector< real > mTauPowT ;
48
49 // help function for idgas contribution
50 mutable Vector< real > mE ;
51
52 // residual terms N_k delta^d_k tau^t_k, entries 32 and 33 are the delta and tau stamps
53 mutable Vector< real > mF ;
54
55 // exp( -delta^2 ) and exp( -delta^4 ), entry 2 is the delta stamp
56 mutable Vector< real > mG ;
57
58//----------------------------------------------------------------------------
59 public:
60//----------------------------------------------------------------------------
61
62 EoS_Oxygen( Gas & aParent ) ;
63
65
66//----------------------------------------------------------------------------
67 protected:
68//----------------------------------------------------------------------------
69
70 real
71 pi_vap( const real T ) const;
72
73//----------------------------------------------------------------------------
74
75 real
76 psi_vap( const real T ) const;
77
78//----------------------------------------------------------------------------
79 private:
80//----------------------------------------------------------------------------
81
82 void
83 init_tables() ;
84
85 void
86 update_delta_pow_a() const ;
87
88 void
89 update_tau_pow_b() const ;
90
91 void
92 update_e() const ;
93
94 void
95 update_f() const ;
96
97 void
98 update_g() const ;
99
100//----------------------------------------------------------------------------
101 protected:
102//----------------------------------------------------------------------------
103
104 real
105 compute_phi0() const ;
106
107//----------------------------------------------------------------------------
108
109 real
110 compute_phi0_t() const ;
111
112//----------------------------------------------------------------------------
113
114 real
115 compute_phi0_tt() const ;
116
117//----------------------------------------------------------------------------
118
119 real
120 compute_phir() const ;
121
122//----------------------------------------------------------------------------
123
124 real
125 compute_phir_d() const ;
126
127//----------------------------------------------------------------------------
128
129 real
130 compute_phir_dd() const ;
131
132//----------------------------------------------------------------------------
133
134 real
135 compute_phir_t() const ;
136
137//----------------------------------------------------------------------------
138
139 real
140 compute_phir_tt() const ;
141
142//----------------------------------------------------------------------------
143
144 real
145 compute_phir_dt() const ;
146
147//----------------------------------------------------------------------------
148
149 };
150
151//----------------------------------------------------------------------------
152
153 inline real
154 EoS_Oxygen::pi_vap( const real T ) const
155 {
156 real tTheta = 1.0 - T / mTcrit ;
157
158 return ( ( mNvap( 0 ) * tTheta
159 + mNvap( 1 ) ) * tTheta
160 + mNvap( 2 ) ) * tTheta * mTcrit / T ;
161 }
162
163//----------------------------------------------------------------------------
164
165 inline real
167 {
168 real tTheta = 1.0 - T / mTcrit ;
169
170 return ( 3.0 * mNvap( 0 ) * tTheta
171 + 2.0 * mNvap( 1 ) ) * tTheta
172 + mNvap( 2 ) ;
173 }
174
175//----------------------------------------------------------------------------
176
177 inline void
178 EoS_Oxygen::update_delta_pow_a() const
179 {
180 if( mDelta != mDeltaPowD( 32 ) )
181 {
182 // integer exponents: repeated multiplication instead of std::pow
183 for( uint k=0; k<32; ++k )
184 {
185 real tPow = 1.0 ;
186
187 for( uint i=0; i<mD( k ); ++i )
188 {
189 tPow *= mDelta ;
190 }
191
192 mDeltaPowD( k ) = tPow ;
193 }
194 mDeltaPowD( 32 ) = mDelta ;
195 }
196 }
197
198//----------------------------------------------------------------------------
199
200 inline void
201 EoS_Oxygen::update_tau_pow_b() const
202 {
203 if( mTau != mTauPowT( 32 ) )
204 {
205 /* every tabulated tau exponent is a multiple of one half, so
206 * 2*mT is an integer and hpow() replaces std::pow. The doubled
207 * exponent is derived from mT rather than tabulated a second
208 * time, so the two can never disagree. */
209 const real tSqrtTau = std::sqrt( mTau ) ;
210
211 for( uint k=0; k<32; ++k )
212 {
213 const int tN = static_cast< int >( std::lround( 2.0 * mT( k ) ) );
214
215 BELFEM_ASSERT( std::abs( 2.0 * mT( k ) - tN ) < 1e-9,
216 "tau exponent %f of term %u is not a multiple of one half",
217 ( float ) mT( k ), ( unsigned int ) k );
218
219 mTauPowT( k ) = hpow( mTau, tSqrtTau, tN );
220 }
221 mTauPowT( 32 ) = mTau ;
222 }
223 }
224
225//----------------------------------------------------------------------------
226
227 inline void
228 EoS_Oxygen::update_e() const
229 {
230 // mE( 3 ) is the stamp; mE( 0-2 ) hold values
231 if( mTau != mE( 3 ) )
232 {
233
234 mE( 0 ) = std::sqrt( mTau );
235 mE( 1 ) = std::exp( mK( 6 ) * mTau );
236 mE( 2 ) = 2./3. * std::exp( -mK( 7 ) * mTau );
237 mE( 3 ) = mTau ;
238 }
239 }
240
241//----------------------------------------------------------------------------
242
243 inline void
244 EoS_Oxygen::update_f() const
245 {
246 this->update_delta_pow_a() ;
247 this->update_tau_pow_b() ;
248
249 if( mDelta != mF( 32 ) || mTau != mF( 33 ) )
250 {
251 for( uint k=0; k<32; ++k )
252 {
253 mF( k ) = mN( k ) * mDeltaPowD( k ) * mTauPowT( k );
254 }
255 mF( 32 ) = mDelta ;
256 mF( 33 ) = mTau ;
257 }
258 }
259
260//----------------------------------------------------------------------------
261
262 inline void
263 EoS_Oxygen::update_g() const
264 {
265 if( mDelta != mG( 2 ) )
266 {
267 mG( 0 ) = std::exp( -mDelta * mDelta );
268 mG( 1 ) = std::exp( -mDelta * mDelta * mDelta * mDelta );
269 mG( 2 ) = mDelta ;
270 }
271 }
272
273//----------------------------------------------------------------------------
274 }
275}
276#endif //BELFEM_CL_GM_EOS_OXYGEN_VAPOR_HPP
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
The gas class that provides the fluid model.
Definition cl_Gas.hpp:81
real compute_phir_dt() const
Definition cl_GM_EoS_Oxygen.cpp:323
real compute_phir_t() const
Definition cl_GM_EoS_Oxygen.cpp:261
real compute_phir_tt() const
Definition cl_GM_EoS_Oxygen.cpp:292
real psi_vap(const real T) const
Definition cl_GM_EoS_Oxygen.hpp:166
real pi_vap(const real T) const
Definition cl_GM_EoS_Oxygen.hpp:154
real compute_phir_d() const
Definition cl_GM_EoS_Oxygen.cpp:193
real compute_phi0_t() const
Definition cl_GM_EoS_Oxygen.cpp:133
real compute_phir_dd() const
Definition cl_GM_EoS_Oxygen.cpp:226
real compute_phi0() const
Definition cl_GM_EoS_Oxygen.cpp:114
real compute_phi0_tt() const
Definition cl_GM_EoS_Oxygen.cpp:148
real compute_phir() const
Definition cl_GM_EoS_Oxygen.cpp:163
EoS_Oxygen(Gas &aParent)
Definition cl_GM_EoS_Oxygen.cpp:22
Helmholtz(Gas &aParent, const string &aLabel)
Definition cl_GM_Helmholtz.cpp:25
real T(const real p, const real v) const
temperature in K
Definition cl_GM_Helmholtz.cpp:300
const real & mTau
Definition cl_GM_Helmholtz.hpp:115
Vector< real > mNvap
Definition cl_GM_Helmholtz.hpp:76
real mTcrit
critical temperature in K
Definition cl_GM_Helmholtz.hpp:119
static real hpow(const real x, const real sqrt_x, const int n)
x^( n / 2 ) for a signed half integer exponent given as n = 2j.
Definition cl_GM_Helmholtz.hpp:538
const real & mDelta
Definition cl_GM_Helmholtz.hpp:116
#define BELFEM_PREF
Definition constants.hpp:28
#define BELFEM_TREF
Definition constants.hpp:27
Definition cl_Gas.hpp:42
USER GUIDES:
Definition cl_Capacitor.cpp:16
unsigned int uint
Definition typedefs.hpp:30
double real
Definition typedefs.hpp:36