BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
cl_GM_EoS_Nitrogen.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, through
4 * 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_NITROGEN_HPP
13#define BELFEM_CL_GM_EOS_NITROGEN_HPP
14
15#include "en_Helmholtz.hpp"
16#include "cl_GM_Helmholtz.hpp"
17#include "cl_Vector.hpp"
18
19namespace belfem
20{
21 namespace gasmodels
22 {
23
27 class EoS_Nitrogen : public Helmholtz
28 {
29 const Vector< real > mA ;
30 const Vector< real > mN ;
31 const Vector< uint > mI ;
32 const Vector< real > mJ ;
33 const Vector< uint > mL ;
34 const Vector< real > mBeta ;
35 const Vector< real > mGamma ;
36 const Vector< real > mPhi ;
37
38 mutable Vector< real > mE ;
39 mutable Vector< real > mF ;
40 mutable Vector< real > mDeltaPowI ;
41 mutable Vector< real > mDeltaPowL ;
42 mutable Vector< real > mTauPowJ ;
43 mutable Vector< real > mSwap ;
44 mutable real mChi ; // <-- help parameter
45 public:
46
47 EoS_Nitrogen( Gas & aParent ) ;
48
50
51//----------------------------------------------------------------------------
52 protected:
53//----------------------------------------------------------------------------
54
55 real
56 compute_phi0() const override ;
57
58 real
59 compute_phi0_t() const override;
60
61
62 real
63 compute_phi0_tt() const override;
64
65
66 real
67 compute_phir() const override ;
68
69
70 real
71 compute_phir_d() const override ;
72
73 real
74 compute_phir_dd() const override ;
75
76 real
77 compute_phir_t() const override ;
78
79 real
80 compute_phir_tt() const override ;
81
82 real
83 compute_phir_dt() const override ;
84
85 private:
86
91 void
92 init_tables() ;
93
94 void
95 update_e() const;
96
97 void
98 update_f() const;
99
100 void
101 update_delta_pow_i() const;
102
103 void
104 update_tau_pow_j() const;
105
106 };
107
108 inline void
109 EoS_Nitrogen::update_e() const
110 {
111 if ( mE( 2 ) == mTau ) return ;
112
113 mChi = std::exp( -mA( 7 ) * mTau ) ;
114
115 mE( 0 ) = std::log( mTau );
116 mE( 1 ) = 1. ;
117 mE( 2 ) = mTau ;
118 mE( 3 ) = 1./mTau ;
119 mE( 4 ) = mE( 3 )*mE( 3 );
120 mE( 5 ) = mE( 3 )*mE( 4 );
121 mE( 6 ) = std::log( 1.- mChi );
122 mE( 7 ) = 0. ;
123 }
124
125 inline void
126 EoS_Nitrogen::update_f() const
127 {
128 this->update_delta_pow_i();
129 this->update_tau_pow_j();
130
131 bool tDelta = mF( 36 ) == mDelta ;
132 bool tTau = mF( 37 ) == mTau ;
133
134 if ( tDelta && tTau ) return ;
135
136 if ( ! tDelta )
137 {
138 for ( uint k=6; k<32; ++k )
139 {
140 uint n = mL( k );
141 mDeltaPowL( k ) = mDelta;
142 for ( uint l=1; l<n; ++l )
143 {
144 mDeltaPowL( k ) *= mDelta;
145 }
146 mF( k ) = std::exp( -mDeltaPowL( k ) );
147 }
148 }
149
150 uint k = 32 ;
151 real xi = mDelta - 1. ;
152 xi *= xi ;
153
154 for ( uint m=0; m<4; ++m, ++k )
155 {
156 real eta = mTau - mGamma( m );
157 mF( k ) = std::exp( -mPhi( m ) * xi - mBeta( m ) * eta * eta );
158 }
159
160 mF( 36 ) = mDelta;
161 mF( 37 ) = mTau;
162 }
163 inline void
164 EoS_Nitrogen::update_delta_pow_i() const
165 {
166 if ( mDelta != mDeltaPowI( 36 ) )
167 {
168
169 mDeltaPowI.fill( 1. );
170
171 for ( uint k=0; k<36; ++k )
172 {
173 uint n = mI( k );
174 BELFEM_ASSERT( n > 0, "Invalid exponent" );
175 mDeltaPowI( k ) = mDelta;
176 for ( uint i=1; i<n; ++i )
177 {
178 mDeltaPowI( k ) *= mDelta;
179 }
180 }
181 mDeltaPowI( 36 ) = mDelta;
182 }
183 }
184
185 inline void
186 EoS_Nitrogen::update_tau_pow_j() const
187 {
188 if ( mTau != mTauPowJ( 36 ) )
189 {
190 for ( uint k=0; k<36; ++k )
191 {
192 mTauPowJ( k ) = std::pow( mTau, mJ( k ) );
193 }
194 mTauPowJ( 36 ) = mTau;
195 }
196 }
197
198
199 }
200}
201
202#endif //BELFEM_CL_GM_EOS_NITROGEN_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_dd() const override
Definition cl_GM_EoS_Nitrogen.cpp:246
real compute_phir_dt() const override
Definition cl_GM_EoS_Nitrogen.cpp:338
real compute_phir_t() const override
Definition cl_GM_EoS_Nitrogen.cpp:276
EoS_Nitrogen(Gas &aParent)
Definition cl_GM_EoS_Nitrogen.cpp:19
real compute_phir_d() const override
Definition cl_GM_EoS_Nitrogen.cpp:212
real compute_phi0_tt() const override
Definition cl_GM_EoS_Nitrogen.cpp:169
real compute_phi0_t() const override
Definition cl_GM_EoS_Nitrogen.cpp:144
real compute_phir() const override
Definition cl_GM_EoS_Nitrogen.cpp:194
real compute_phi0() const override
Definition cl_GM_EoS_Nitrogen.cpp:136
real compute_phir_tt() const override
Definition cl_GM_EoS_Nitrogen.cpp:304
Helmholtz(Gas &aParent, const string &aLabel)
Definition cl_GM_Helmholtz.cpp:25
const real & mTau
Definition cl_GM_Helmholtz.hpp:115
const real & mDelta
Definition cl_GM_Helmholtz.hpp:116
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
n
Definition test_curve_frame.py:84
i
Definition main.py:48