-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathequations.py
108 lines (86 loc) · 3.66 KB
/
equations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# =============================================================================
# 2D euler equations - ideal gas
# =============================================================================
# number of dimensions
dim = 2
# coefficients ////////////////////////////////////////////////////////////////
coefficients = {
'delta' : 1
}
# unknowns to march in time ///////////////////////////////////////////////////
varname = {'rho' : 1,
'u' : 2,
'v' : 3,
'et' : 4,
}
varsolved = ['rho','u','v','et']
# of which
consvar = [2,3,4] # are conservative variables
# derived local variables /////////////////////////////////////////////////////
varloc = { 'e' : '(et - 0.5_wp*(u*u + v*v) )',
'p' : 'delta*rho* ( e )',
'c' : ' ( ( 1.0_wp + delta ) * p / rho )**0.5_wp ',
}
# -- Same stored var for both
varstored = {
'ksi' : {'symb': "ksi",
'ind':1 ,
'static': True}, # metric terms
'eta' : {'symb': "eta",
'ind':2 ,
'static': True}, # metric terms
'dksidx' : {'symb': ' [ksi]_1x ',
'ind':3 ,
'static': True}, # metric derivative
'dksidy' : {'symb': ' [ksi]_1y ',
'ind':4 ,
'static': True}, # metric derivative
'detadx' : {'symb': ' [eta]_1x ',
'ind':5 ,
'static': True}, # metric derivative
'detady' : {'symb': ' [eta]_1y ',
'ind':6 ,
'static': True}, # metric derivative
'Jm1' : {'symb': '1.0_wp / ( dksidx * detady - detadx * dksidy )',
'ind':7,
'static': True}, # coordinate transformation jacobian
'omg' : {'symb': ' Jm1 * ( detady * [v]_1x - detadx * [v]_1y + dksidy * [u]_1x - dksidx * [u]_1y ) ',
'ind':8,
'static': False}, # vorticity in curvilinear coordinates
}
# names to give to the constructor ////////////////////////////////////////////
# .. for comments in the Fortran file
rhsname = {'rho' : 'd(rho)/dt',
'u' : 'd(rho u)/dt',
'v' : 'd(rho v)/dt',
'et' : 'd(rho et)/dt'}
# .. name tags to use for intermediate variables created by the constructor
vnamesrc_divFx = {'rho' : 'FluRx',
'u' : 'FluXx',
'v' : 'FluYx',
'et' : 'FluEx'}
vnamesrc_divFy = {'rho' : 'FluRy',
'u' : 'FluXy',
'v' : 'FluYy',
'et' : 'FluEy'}
# RHS terms ///////////////////////////////////////////////////////////////////
Vel = {
'U' : ' (detady * u - dksidy * v ) ',
'V' : ' (-detadx *u + dksidx * v ) ',
}
divFx = {
'rho' : ' Jm1 * ( [ rho * '+Vel['U']+' ]_1x )',
'u' : ' Jm1 * ( [ rho * u * '+Vel['U']+' + detady*p ]_1x )',
'v' : ' Jm1 * ( [ rho * v * '+Vel['U']+' - dksidy*p ]_1x )',
'et' : ' Jm1 * ( [ (rho * et + p ) * '+Vel['U']+' ]_1x )',
}
divFy = {
'rho' : ' Jm1 * ( [ rho * '+Vel['V']+' ]_1y )',
'u' : ' Jm1 * ( [ rho * u * '+Vel['V']+' - detadx*p ]_1y )',
'v' : ' Jm1 * ( [ rho * v * '+Vel['V']+' + dksidx*p ]_1y )',
'et' : ' Jm1 * ( [ (rho * et + p ) * '+Vel['V']+' ]_1y )',
}
# -- Assemble both directions
divF = {}
for key in divFx.keys():
divF[key] = divFx[key] + ' + ' + divFy[key]