forked from cmkaul/SCAMPy
-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_paramlist.py
214 lines (154 loc) · 7.97 KB
/
generate_paramlist.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
import argparse
import json
import pprint
from sys import exit
import uuid
import ast
import copy
# See Table 1 of Tan et al, 2018
#paramlist['turbulence']['EDMF_PrognosticTKE']['tke_ed_coeff'] ==> c_k (scaling constant for eddy diffusivity/viscosity
#paramlist['turbulence']['EDMF_PrognosticTKE']['tke_diss_coeff'] == > c_e (scaling constant for tke dissipation)
#paramlist['turbulence']['EDMF_PrognosticTKE']['pressure_buoy_coeff'] ==> alpha_b (scaling constant for virtual mass term)
#paramlist['turbulence']['EDMF_PrognosticTKE']['pressure_drag_coeff'] ==> alpha_d (scaling constant for drag term)
# paramlist['turbulence']['EDMF_PrognosticTKE']['pressure_plume_spacing'] ==> r_d (horizontal length scale of plume spacing)
# Parameters below can be used to multiply any entrainment rate for quick tuning/experimentation
# (NOTE: these are not c_epsilon, c_delta,0 defined in Tan et al 2018)
# paramlist['turbulence']['EDMF_PrognosticTKE']['entrainment_factor'] = 0.1
# paramlist['turbulence']['EDMF_PrognosticTKE']['detrainment_factor'] = 1.0
#NB: except for Bomex and life_cycle_Tan2018 cases, the parameters listed have not been thoroughly tuned/tested
# and should be regarded as placeholders only. Optimal parameters may also depend on namelist options, such as
# entrainment/detrainment rate formulation, diagnostic vs. prognostic updrafts, and vertical resolution
def main():
parser = argparse.ArgumentParser(prog='Paramlist Generator')
parser.add_argument('case_name')
args = parser.parse_args()
case_name = args.case_name
paramlist_defaults = {}
paramlist_defaults['meta'] = {}
paramlist_defaults['turbulence'] = {}
paramlist_defaults['turbulence']['Ri_bulk_crit'] = 0.2
paramlist_defaults['turbulence']['prandtl_number_0'] = 0.74
paramlist_defaults['turbulence']['EDMF_PrognosticTKE'] = {}
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['surface_area'] = 0.1
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['tke_ed_coeff'] = 0.14
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['tke_diss_coeff'] = 0.22
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['static_stab_coeff'] = 0.4
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['lambda_stab'] = 0.9
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['max_area'] = 0.9
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['entrainment_factor'] = 0.13
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['detrainment_factor'] = 0.51
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['entrainment_massflux_div_factor'] = 0.4
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['turbulent_entrainment_factor'] = 0.015
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['entrainment_ed_mf_sigma'] = 50.0
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['entrainment_smin_tke_coeff'] = 0.3
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['updraft_mixing_frac'] = 0.25
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['entrainment_sigma'] = 10.0
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['entrainment_scale'] = 0.004
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['sorting_power'] = 2.0
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['aspect_ratio'] = 0.2
# This constant_plume_spacing corresponds to plume_spacing/alpha_d in the Tan et al paper,
#with values plume_spacing=500.0, alpha_d = 0.375
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['constant_plume_spacing'] = 1333.0
# TODO: merge the tan18 buoyancy forluma into normalmode formula -> simply set buoy_coeff1 as 1./3. and buoy_coeff2 as 0.
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_buoy_coeff'] = 1.0/3.0
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_buoy_coeff1'] = 0.12
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_buoy_coeff2'] = 0.0
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_adv_coeff'] = 0.1
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_drag_coeff'] = 10.0
if case_name == 'Soares':
paramlist = Soares(paramlist_defaults)
elif case_name == 'Nieuwstadt':
paramlist = Nieuwstadt(paramlist_defaults)
elif case_name == 'Bomex':
paramlist = Bomex(paramlist_defaults)
elif case_name == 'life_cycle_Tan2018':
paramlist = life_cycle_Tan2018(paramlist_defaults)
elif case_name == 'Rico':
paramlist = Rico(paramlist_defaults)
elif case_name == 'TRMM_LBA':
paramlist = TRMM_LBA(paramlist_defaults)
elif case_name == 'ARM_SGP':
paramlist = ARM_SGP(paramlist_defaults)
elif case_name == 'GATE_III':
paramlist = GATE_III(paramlist_defaults)
elif case_name == 'DYCOMS_RF01':
paramlist = DYCOMS_RF01(paramlist_defaults)
elif case_name == 'GABLS':
paramlist = GABLS(paramlist_defaults)
elif case_name == 'SP':
paramlist = SP(paramlist_defaults)
elif case_name == 'DryBubble':
paramlist = DryBubble(paramlist_defaults)
elif case_name == 'LES_driven_SCM':
paramlist = LES_driven_SCM(paramlist_defaults)
else:
print('Not a valid case name')
exit()
write_file(paramlist)
def Soares(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'Soares'
return paramlist
def Nieuwstadt(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'Nieuwstadt'
return paramlist
def Bomex(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'Bomex'
return paramlist
def life_cycle_Tan2018(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'life_cycle_Tan2018'
return paramlist
def Rico(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'Rico'
return paramlist
def TRMM_LBA(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'TRMM_LBA'
return paramlist
def ARM_SGP(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'ARM_SGP'
return paramlist
def GATE_III(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'GATE_III'
return paramlist
def DYCOMS_RF01(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'DYCOMS_RF01'
return paramlist
def GABLS(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'GABLS'
return paramlist
# Not fully implemented yet - Ignacio
def SP(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'SP'
return paramlist
def DryBubble(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'DryBubble'
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['surface_area'] = 0.0
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_buoy_coeff1'] = 0.12
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_adv_coeff'] = 0.25
paramlist_defaults['turbulence']['EDMF_PrognosticTKE']['pressure_normalmode_drag_coeff'] = 0.1
return paramlist
def LES_driven_SCM(paramlist_defaults):
paramlist = copy.deepcopy(paramlist_defaults)
paramlist['meta']['casename'] = 'LES_driven_SCM'
paramlist['forcing'] = {}
paramlist['forcing']['nudging_timescale'] = 6.0*3600.0
return paramlist
def write_file(paramlist):
fh = open('paramlist_'+paramlist['meta']['casename']+ '.in', 'w')
#pprint.pprint(paramlist)
json.dump(paramlist, fh, sort_keys=True, indent=4)
fh.close()
return
if __name__ == '__main__':
main()