Skip to content

Commit 831f138

Browse files
committed
TL: script update
1 parent 01c7e09 commit 831f138

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

pySDC/playgrounds/dedalus/scripts/stab_rbc.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@
77
"""
88
import os
99
import matplotlib.pyplot as plt
10+
import numpy as np
1011

1112
from pySDC.playgrounds.dedalus.timestepper import SDCIMEX
1213
from pySDC.playgrounds.dedalus.problems.rbc import RBCProblem3D, OutputFiles
1314

15+
tEnd = 10
1416

15-
dtBase = 2.50e-03
16-
nSteps = 10
17-
nCycles = 2
17+
nStepsMax = 50
18+
nStepsMin = 8
19+
nVals = 19
20+
21+
dtVals = 1/np.arange(nStepsMax, nStepsMin-1, -1)
22+
intervals = np.linspace(dtVals.min(), dtVals.max(), num=nVals)
23+
dtVals = np.unique([dtVals[max(np.argwhere(dtVals <= dt))] for dt in intervals])
24+
25+
nStepsVals = [int(n) for n in 1/dtVals]
1826

1927
Rayleigh = 1.5e5
2028
timeScheme = "SDC"
@@ -23,22 +31,21 @@
2331

2432
SDCIMEX.setParameters(
2533
nNodes=4, nodeType="LEGENDRE", quadType="RADAU-RIGHT",
26-
nSweeps=4, initSweep="COPY", explSweep="PIC", implSweep="MIN-SR-FLEX",
34+
nSweeps=4, initSweep="COPY", explSweep="PIC", implSweep="MIN-SR-S",
2735
)
2836

2937
os.makedirs(stabDir, exist_ok=True)
3038

31-
dtFactors = [f*10**e for e in range(nCycles) for f in [1, 2, 5]]
32-
fmtSuffix = f":0{nCycles}d"
39+
fmtSuffix = f":0{len(str(nStepsMax))}d"
3340

3441
plt.figure("spectrum")
35-
for fac in dtFactors:
36-
dtRun = dtBase*fac
37-
runDir = f"{stabDir}/dt_f" + ("{"+fmtSuffix+"}").format(fac)
42+
for nSteps in nStepsVals:
43+
dtRun = 1/nSteps
44+
runDir = f"{stabDir}/dt_N" + ("{"+fmtSuffix+"}").format(nSteps)
3845

3946
prob = RBCProblem3D.runSimulation(
40-
runDir, dtRun*nSteps, dtRun, timeScheme=timeScheme,
41-
dtWrite=dtRun*nSteps, initField=initSol,
47+
runDir, tEnd, dtRun, timeScheme=timeScheme,
48+
dtWrite=tEnd, initField=initSol,
4249
aspectRatio=4, meshRatio=1, resFactor=1,
4350
Rayleigh=Rayleigh, Prandtl=0.7,
4451
)
@@ -49,6 +56,8 @@
4956
output = OutputFiles(runDir)
5057
spectrum = output.getSpectrum(which="all", start=1)
5158

52-
# plt.loglog(spectrum["kappa"], spectrum["p"], label="f"+("{"+fmtSuffix+"}").format(fac))
59+
if np.any(np.isnan(spectrum["u"])):
60+
break
61+
plt.loglog(spectrum["kappa"], spectrum["u"], label="N"+("{"+fmtSuffix+"}").format(nSteps))
5362

54-
# plt.legend()
63+
plt.legend()

0 commit comments

Comments
 (0)