Skip to content

Commit ce1bc33

Browse files
committed
latest stand of the code before starting on the revision
the instability structure after an hour resembles the analytical solution, and the initial oscillation in the energy is reduced significantly.
1 parent fa14393 commit ce1bc33

File tree

7 files changed

+2720
-286
lines changed

7 files changed

+2720
-286
lines changed

RKLM_Python/inputs/boundary.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -433,14 +433,18 @@ def get_bottom_tau_y(ud, elem, node, alpha, cutoff=0.5):
433433
tauc_y = dd * tauc_y / np.abs(tauc_y).max()
434434
taun_y = dd * taun_y / np.abs(taun_y).max()
435435

436+
# tauc_y = tauc_y[2:-2]
437+
# taun_y = taun_y[2:-2]
438+
436439
return tauc_y, taun_y
437440

438441

439442

440-
def rayleigh_damping(Sol, mpv, ud, forcing=None):
441-
u = Sol.rhou / Sol.rho
442-
v = Sol.rhov / Sol.rho
443-
Y = Sol.rhoY / Sol.rho
443+
def rayleigh_damping(Sol, mpv, ud, elem, node, forcing=None):
444+
u = (Sol.rhou / Sol.rho)#[elem.i2]
445+
v = (Sol.rhov / Sol.rho)#[elem.i2]
446+
Y = (Sol.rhoY / Sol.rho)#[elem.i2]
447+
rho = Sol.rho#[elem.i2]
444448

445449
if ud.bdry_type[1] == BdryType.RAYLEIGH:
446450
tcy, tny = ud.tcy, ud.tny
@@ -479,11 +483,13 @@ def rayleigh_damping(Sol, mpv, ud, forcing=None):
479483
# assuming 2D vertical slice - not dimension agnostic
480484
u += tcy * (u - ud.u_wind_speed) + c_f * (tcy_f * (u - ud.u_wind_speed) + np.abs(tcy_f) * mfac * u_f)
481485
v += tcy * (v - ud.v_wind_speed) + c_f * (tcy_f * (v - ud.v_wind_speed) + np.abs(tcy_f) * mfac * v_f)
482-
Y += tcy * (Y - mpv.HydroState.Y0.reshape(1,-1)) + c_f * (tcy_f * (Y - mpv.HydroState.Y0.reshape(1,-1)) + np.abs(tcy_f) * mfac * Y_f)
483486

484-
Sol.rhou[...] = Sol.rho * u
485-
Sol.rhov[...] = Sol.rho * v
486-
Sol.rhoY[...] = Sol.rho * Y
487+
Ybar = mpv.HydroState.Y0.reshape(1,-1)
488+
Y += tcy * (Y - Ybar) + c_f * (tcy_f * (Y - Ybar) + np.abs(tcy_f) * mfac * Y_f)
489+
490+
Sol.rhou[...] = rho * u
491+
Sol.rhov[...] = rho * v
492+
Sol.rhoY[...] = rho * Y
487493

488494

489495

RKLM_Python/inputs/lamb_wave_perturb.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def __init__(self):
123123

124124

125125
self.tout = [36.0]
126-
# self.tout = np.arange(0,36.1,0.1)
126+
# self.tout = np.arange(0,361,1.0)
127127
# self.tout = np.append(self.tout, [720.0])
128-
self.stepmax = 10000
128+
self.stepmax = 31
129129
self.output_timesteps = True
130130

131131
self.output_base_name = "_mark_wave"
@@ -138,7 +138,7 @@ def __init__(self):
138138
self.init_forcing = self.forcing
139139

140140
self.rayleigh_forcing = True
141-
self.rayleigh_forcing_type = 'file' # func or file
141+
self.rayleigh_forcing_type = 'func' # func or file
142142
self.rayleigh_forcing_fn = 'output_mark_wave_ensemble=1_601_240_bottom_forcing_S16.h5'
143143
self.rayleigh_forcing_path = './output_mark_wave'
144144

@@ -218,12 +218,12 @@ def eigenfunction(self, t, s, grid='c'):
218218
eigval, eigvec = np.linalg.eig( self.T_matrix )
219219

220220
# Find index of eigenvalue
221-
# with greatest real part aka the insrtability growth rate
221+
# with greatest real part aka the instability growth rate
222222
ind = np.argmax( np.real( eigval ) )
223223

224224
# construct solution according to eq. 2.27 and 2.19
225225
exponentials = np.exp( 1j * self.k * x + self.mu * z
226-
+ ( eigval[ind] ) * t )
226+
+ ( eigval[ind] ) * (t) + 1j * s * t )
227227
chi_u = self.ampl * np.real( eigvec[0,ind] * exponentials )
228228
chi_w = self.ampl * np.real( eigvec[1,ind] * exponentials )
229229
chi_th = self.ampl * np.real( eigvec[2,ind] * exponentials )
@@ -252,7 +252,8 @@ def dehatter(self, th, grid='c'):
252252
def sol_init(Sol, mpv, elem, node, th, ud, seeds=None):
253253

254254
if hasattr(ud, 'rayleigh_bdry_switch'):
255-
ud.bdry_type[1] = BdryType.RAYLEIGH
255+
if ud.rayleigh_bdry_switch:
256+
ud.bdry_type[1] = BdryType.RAYLEIGH
256257

257258
if ud.bdry_type[1] == BdryType.RAYLEIGH:
258259
ud.tcy, ud.tny = get_tau_y(ud, elem, node, 0.5)
@@ -264,7 +265,7 @@ def sol_init(Sol, mpv, elem, node, th, ud, seeds=None):
264265

265266
A0 = 1.0e-3
266267
Msq = ud.Msq
267-
g = ud.gravity_strength[1]
268+
g = ud.gravity_strength[1] * ud.Rg
268269

269270
x = elem.x.reshape(-1,1)
270271
y = elem.y.reshape(1,-1)
@@ -299,7 +300,11 @@ def sol_init(Sol, mpv, elem, node, th, ud, seeds=None):
299300
ud.Cs = Cs
300301
ud.Ns = N
301302
# dimensionless Coriolis strength
302-
F = ud.coriolis_strength[2] #+ 1e-30
303+
if ud.coriolis_strength[2] == 0.0:
304+
ud.coriolis_strength[2] += 1e-15
305+
F = ud.coriolis_strength[2]
306+
# if F == 0.0:
307+
# F += 1e-15
303308

304309
G = np.sqrt( 9. / 40. )
305310
Gamma = G * N / Cs
@@ -342,6 +347,7 @@ def sol_init(Sol, mpv, elem, node, th, ud, seeds=None):
342347
set_explicit_boundary_data(Sol,elem,ud,th,mpv)
343348

344349
if hasattr(ud, 'mixed_run'):
345-
ud.coriolis_strength[2] = 2.0 * 7.292 * 1e-5 * ud.t_ref
350+
if ud.mixed_run:
351+
ud.coriolis_strength[2] = 2.0 * 7.292 * 1e-5 * ud.t_ref
346352

347353
return Sol

RKLM_Python/management/data.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def time_update(Sol,flux,mpv,t,tout,ud,elem,node,steps,th,bld=None,writer=None,d
184184

185185
if ud.bdry_type[1] == BdryType.RAYLEIGH:
186186
# top rayleight damping
187-
boundary.rayleigh_damping(Sol, mpv, ud)
187+
boundary.rayleigh_damping(Sol, mpv, ud, elem, node)
188188

189189
# bottom rayleigh forcing
190190
if hasattr(ud, 'rayleigh_forcing'):
@@ -210,14 +210,16 @@ def time_update(Sol,flux,mpv,t,tout,ud,elem,node,steps,th,bld=None,writer=None,d
210210
boundary.rayleigh_damping(Sol, mpv, ud, [up, vp, Yp, pi, t+0.5*dt])
211211

212212
elif ud.rayleigh_forcing_type == 'func':
213-
boundary.set_explicit_boundary_data(Sol, elem, ud, th, mpv)
214-
ud.rf_bot.eigenfunction((t+0.5*dt), 1)
213+
# boundary.set_explicit_boundary_data(Sol, elem, ud, th, mpv)
214+
215+
s = 5.0e-3+1e-4+0e-5
216+
ud.rf_bot.eigenfunction((t+0.5*dt), s)
215217
up, vp, Yp, pi = ud.rf_bot.dehatter(th)
216218

217-
ud.rf_bot.eigenfunction((t+0.5*dt), 1, grid='n')
219+
ud.rf_bot.eigenfunction((t+0.5*dt), s, grid='n')
218220
_, _, _, pi_n = ud.rf_bot.dehatter(th, grid='n')
219221

220-
boundary.rayleigh_damping(Sol, mpv, ud, [up, vp, Yp, pi_n, t+0.5*dt])
222+
boundary.rayleigh_damping(Sol, mpv, ud, elem, node, [up, vp, Yp, pi_n, t+0.5*dt])
221223
boundary.set_explicit_boundary_data(Sol, elem, ud, th, mpv)
222224

223225

@@ -325,7 +327,7 @@ def time_update(Sol,flux,mpv,t,tout,ud,elem,node,steps,th,bld=None,writer=None,d
325327

326328
if ud.bdry_type[1] == BdryType.RAYLEIGH:
327329
# top rayleight damping
328-
boundary.rayleigh_damping(Sol, mpv, ud)
330+
boundary.rayleigh_damping(Sol, mpv, ud, elem, node)
329331

330332
# bottom rayleigh forcing
331333
if hasattr(ud, 'rayleigh_forcing'):
@@ -350,16 +352,15 @@ def time_update(Sol,flux,mpv,t,tout,ud,elem,node,steps,th,bld=None,writer=None,d
350352
boundary.rayleigh_damping(Sol, mpv, ud, [up, vp, Yp, pi, t+dt])
351353

352354
elif ud.rayleigh_forcing_type == 'func':
353-
ud.rf_bot.eigenfunction((t+dt), 1)
355+
356+
s = 5.0e-3+1e-4+0e-5
357+
ud.rf_bot.eigenfunction((t+dt), s)
354358
up, vp, Yp, pi = ud.rf_bot.dehatter(th)
355359

356-
ud.rf_bot.eigenfunction((t+dt), 1, grid='n')
360+
ud.rf_bot.eigenfunction((t+dt), s, grid='n')
357361
_, _, _, pi_n = ud.rf_bot.dehatter(th, grid='n')
358-
# kernel = np.ones([2]*mpv.p2_nodes.ndim)
359-
# pi_n = np.zeros_like(mpv.p2_nodes)
360-
# pi_n[node.i1] = signal.fftconvolve(pi, kernel, mode='valid') / kernel.sum()
361362

362-
boundary.rayleigh_damping(Sol, mpv, ud, [up, vp, Yp, pi_n, t+dt])
363+
boundary.rayleigh_damping(Sol, mpv, ud, elem, node, [up, vp, Yp, pi_n, t+dt])
363364
boundary.set_explicit_boundary_data(Sol, elem, ud, th, mpv)
364365

365366

RKLM_Python/queue_run_lamb_forcing.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
resol_x = [301]
2020
resol_y = [120]
2121
resol_t = [1,2,4,8,10,12,14,16]
22-
resol_t = [1]
22+
resol_t = [10.0]
2323
# resol_t = [10,12,14,16.0]
2424
# omegas = [0.0, 2.0 * omega * t_ref]
2525
# omegas = [2.0 * omega * t_ref]
2626
omegas = [0.0]
2727

2828
tsteps = [1800, 900, 450, 360, 300, 258, 225]
29-
tsteps = [3600, 300, 258, 225]
29+
tsteps = [360, 300, 258, 225]
30+
# tsteps = [21]
3031

3132
ud = {}
3233
dap = {

RKLM_Python/queue_run_lamb_mixed.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99

1010
rp.N = 1
1111

12-
# rp.tc = 'lw_p'
13-
rp.tc = 'mark'
12+
rp.tc = 'lw_p'
13+
# rp.tc = 'mark'
1414

1515
t_ref = 100.0
1616
omega = 7.292 * 1e-5
1717
# resol_x = [151,301,601,1201]
1818
# resol_y = [15,30,60,120]
19-
resol_x = [151]
20-
resol_y = [60]
19+
resol_x = [301]
20+
resol_y = [120]
2121
resol_t = [1,2,4,8,10,12,14,16]
2222
# resol_t = [200,400,600,800]
23-
resol_t = [1.0]
23+
resol_t = [10.0]
2424
# omegas = [0.0, 2.0 * omega * t_ref]
2525
# omegas = [2.0 * omega * t_ref]
2626
omegas = [0.0]
@@ -37,9 +37,9 @@
3737

3838
ud['ymax'] = 8.0
3939
ud['rayleigh_forcing'] = False
40-
ud['mixed_run'] = False
41-
ud['do_advection'] = False
42-
# ud['output_timesteps'] = False
40+
ud['mixed_run'] = True
41+
# ud['do_advection'] = False
42+
ud['output_timesteps'] = False
4343

4444

4545
for t in resol_t:
@@ -49,12 +49,12 @@
4949
ud['rayleigh_forcing_fn'] = 'output_mark_wave_ensemble=1_%i_%i_36.000000_bottom_forcing_S%i.h5' %(x,int(4*y),t)
5050
ud['rayleigh_forcing_type'] = 'func'
5151

52-
for om in omegas:
52+
for om in omegas:
5353
ud['coriolis_strength'] = [0.0, 0.0, om]
5454
if om > 0:
5555
ud['aux'] = 'test_run_S%i_a05' %t
5656
else:
57-
ud['aux'] = 'test_run_S%i' %t
57+
ud['aux'] = 'test_run_S%i_mix' %t
5858

5959
print(ud)
6060
# run simulation

RKLM_Python/queue_run_lamb_unstable.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@
2020
resol_y = [30]
2121
# resol_t = [10,12,14,16]
2222
# resol_t = [200,400,600,800,1000,1200,1400,1600]
23-
resol_t = [1,2,4,8]
24-
# resol_t = [10.0]
23+
# resol_t = [1,2,4,8]
24+
resol_t = [10.0]
2525
# omegas = [0.0, 2.0 * omega * t_ref]
2626
omegas = [2.0 * omega * t_ref]
2727
# omegas = [0.0]
2828

2929

3030
# tsteps = [3600, 1800, 900, 450, 360, 300, 258, 225]
31-
tsteps = [3600, 1800, 900, 450]
32-
# tsteps = [361]
31+
# tsteps = [3600, 1800, 900, 450]
32+
tsteps = [360]
3333

3434
ud = {}
3535
dap = {
@@ -40,6 +40,8 @@
4040
ud['inx'] = x+1
4141
ud['iny'] = y+1
4242
ud['rayleigh_bdry_switch'] = True
43+
ud['rayleigh_forcing'] = True
44+
ud['do_advection'] = True
4345

4446
for t_idx, t in enumerate(resol_t):
4547
ud['dtfixed0'] = t / t_ref

0 commit comments

Comments
 (0)