Skip to content

Commit 2426151

Browse files
committed
documentation and comments
1 parent d3dcce1 commit 2426151

3 files changed

Lines changed: 22 additions & 41 deletions

File tree

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,21 @@ and the DALES model within OMUSE. See the
1818
* Activate the OMUSE virtual environment
1919

2020
```
21-
python simple-sp.py # run simulations, 10 minutes on 4-core desktop
21+
python simple-SP.py # run simulations, 10 minutes on 4-core desktop
2222
python plot-lwp.py # plot result
2323
```
2424

25+
(Instructions tested on Ubuntu 21.04, with OMUSE 2021.6.2.dev14+gf2bbc23).
26+
27+
The script is set up to perform three simulations with a moist bubble perturbation in the initial state:
28+
29+
* a single, wide LES
30+
31+
* a traditional superparameterization with four LES domains
32+
33+
* a modified superparameterization with four LES domains, where the moisture variability is coupled
34+
35+
2536
## References
2637

2738
DALES model description article: Formulation of the Dutch Atmospheric Large-Eddy Simulation (DALES) and overview of its applications, T. Heus et al, [Geosci. Model Dev., 3, 415-444, 2010](https://doi.org/10.5194/gmd-3-415-2010)

plot-lwp.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
# plot results from simple-SP
14-
# assuming each Dales was run with one process - no merging implemented in this script yet
14+
# assuming each DALES was run with one process - no merging implemented in this script yet
1515
# Each row is one time point, columns show different DALES.
1616

1717
mplparams = {"figure.figsize" : [3.47, 3.8], # figure size in inches
@@ -26,15 +26,8 @@
2626
}
2727
plt.rcParams.update(mplparams)
2828

29-
30-
# wishes
31-
# isolines instead of pixels
32-
3329
C,R = 4,4 # number of columns and rows in plot
3430

35-
field="lwp"
36-
#field="twp"
37-
3831
vmin={'lwp' : 0,
3932
'twp' : 35}
4033
vmax={'lwp' : .2,
@@ -97,17 +90,6 @@ def makeplot(dirname, field, t_start, dtRow, vmin, vmax, colorbar=False):
9790
dirname = expname+extension
9891
colorbar = (extension == '-coupled-var-T')
9992
makeplot(dirname, field, t_start, dtRow, vmin[field], vmax[field], colorbar)
100-
101-
# measuring average LWP over time
102-
#for extension in E:
103-
# dirname = expname+extension
104-
# print (dirname)
105-
# for ti in range(0,10):
106-
# print('%2d: '%ti, end='')
107-
# for i in range(0,C):
108-
# print('%5.3f'%lwp_avg[(dirname, i, ti, field)], end=' ')
109-
# print()
110-
# print()
11193

11294

11395
# Plotting the single wide LES run
@@ -144,13 +126,11 @@ def makeplot(dirname, field, t_start, dtRow, vmin, vmax, colorbar=False):
144126
lwp=dales_crossxz["qtxz"][ti]
145127
im_v=axes[j,i].imshow(lwp, origin='lower', vmin=0,vmax=0.02)
146128

147-
#cax = fig.add_axes([0.48, 0.05, 0.03, 0.3]) #verttical, when showing qt also
148-
#cax = fig.add_axes([0.85, 0.05, 0.03, 0.3]) #vertical colorbar
149129
cax = fig.add_axes([0.2, 0.05, 0.3, 0.03]) #horizontal colorbar
150130
cbar = fig.colorbar(im, cax=cax, orientation='horizontal')
151131
tick_locator = ticker.MaxNLocator(nbins=4)
152132
cbar.locator = tick_locator
153-
#cbar.ax.yaxis.set_major_locator(ticker.AutoLocator())
133+
154134
cbar.update_ticks()
155135
cbar.set_label('kg/m$^2$')
156136
plt.subplots_adjust(left=.01, top=.99, bottom=.1, right=.99, wspace=.01, hspace=.01)

simple-SP.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Simple SP demonstration.
44
# A grid of LES models coupled to a global model consisting only of large-scale advection
5-
# Fredrik Jansson, CWI, 2019-2020
5+
# Fredrik Jansson, CWI and TU Delft, 2019-2021
66
#
77

88

@@ -101,10 +101,6 @@ def evolve(grid, time):
101101
# upwind advection of quantity q, with velocity u
102102
# assuming velocity is positive and constant in x, y
103103
def advect(q, u, dx, dt):
104-
# boundaries are NOT periodic, and probably inconsistent. the leftmost value does not change.
105-
#dq = (q[:,:-1, :] - q[:, 1:, :]) * u * dt / dx
106-
#q[:, 1:, :] += dq
107-
108104
# periodic boundaries:
109105
qm = numpy.roll(q.number, 1, axis=1) | q.unit # qm(j,i,k) = q(j,i-1,k), periodic
110106
dq = (qm - q) * u * dt / dx
@@ -139,9 +135,10 @@ def make_bubble(grid, r, center, gaussian=False):# r, center are quantities, i.e
139135
else:
140136
return numpy.where (rr < r*r, 1, 0)
141137

138+
# Adjust the moisture varibility in an LES domain, so that the specific liquid water
139+
# profile ql matches the provided ql_ref.
140+
# This cannot be used before the LES has been stepped - otherwise qsat and ql are not defined.
142141
def variability_nudge(les, ql_ref, DT, constantT=False):
143-
# this cannot be used before the LES has been stepped - otherwise qsat and ql are not defined.
144-
145142
itot, jtot = les.get_itot(), les.get_jtot()
146143

147144
# random field to be used for additive noise when variability is very small
@@ -267,14 +264,14 @@ def get_ql_diff_additive(a):
267264

268265
#qt_std = qt.std(axis=(0, 1))
269266

270-
267+
268+
# Performs a superparameterized simulation, where the large-scale model performs only advection using an upwind scheme.
271269
def run(steps=60, DT=60 | units.s, spinup = 0 | units.s, nx=4, ny=1, n=25, qt_delta=0|units.g/units.kg, name='dales',
272270
couple=False, bubble=False, bubbleA=1|units.g/units.kg, nudge=None, constantT=False):
273271

274272
dx=100 | units.m # small-scale grid size
275273
DX=n*dx # large-scale grid size = horizontal size of the LES
276-
277-
# note CFL on the large scale: need U * DT < DX. U ~= 10 m/s
274+
# note CFL on the large scale: need U * DT < DX. U ~= 10 m/s
278275

279276
grid = [[initBomex(i,j,dirname=name,itot=n,jtot=n,dx=dx,nudge=nudge) for i in range(nx)] for j in range(ny)]
280277

@@ -337,9 +334,6 @@ def run(steps=60, DT=60 | units.s, spinup = 0 | units.s, nx=4, ny=1, n=25, qt_de
337334
print ('QL target profile 2')
338335
print (QL[0,2,:])
339336

340-
341-
342-
343337
print ('Evolving to ', DT*ti + spinup)
344338
evolve(grid, DT*ti + spinup)
345339

@@ -354,9 +348,6 @@ def run(steps=60, DT=60 | units.s, spinup = 0 | units.s, nx=4, ny=1, n=25, qt_de
354348
('z', units.m)):
355349
state[(ti,i,j,var)] = getattr(grid[j][i].profiles, var).value_in(unit)
356350
state['time'].append((DT*ti).value_in(units.s))
357-
358-
359-
360351

361352
filename='result%s.pickle'%('-coupled' if couple else '')
362353
with open(filename, 'wb') as f:
@@ -421,9 +412,8 @@ def run_single(steps=60, DT=60 | units.s, n=25, nx=4, ny=1, qt_delta=0|units.g/u
421412

422413
# SP with variance nudging at constant thl
423414
# run (steps=30, DT=60 | units.s, nx=4, ny=1, couple=True, name='bubble-coupled-var', bubble=True, bubbleA=A, nudge='variance')
424-
# with variance nudging at constant T
425415

426-
# SP with variance nudging at constant thl
416+
# SP with variance nudging at constant T
427417
run (steps=30, DT=60 | units.s, nx=4, ny=1, couple=True, name='bubble-coupled-var-T', bubble=True, bubbleA=A, nudge='variance', constantT=True)
428418

429419

0 commit comments

Comments
 (0)