|
7 | 7 | """ |
8 | 8 | import os |
9 | 9 | import matplotlib.pyplot as plt |
| 10 | +import numpy as np |
10 | 11 |
|
11 | 12 | from pySDC.playgrounds.dedalus.timestepper import SDCIMEX |
12 | 13 | from pySDC.playgrounds.dedalus.problems.rbc import RBCProblem3D, OutputFiles |
13 | 14 |
|
| 15 | +tEnd = 10 |
14 | 16 |
|
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] |
18 | 26 |
|
19 | 27 | Rayleigh = 1.5e5 |
20 | 28 | timeScheme = "SDC" |
|
23 | 31 |
|
24 | 32 | SDCIMEX.setParameters( |
25 | 33 | 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", |
27 | 35 | ) |
28 | 36 |
|
29 | 37 | os.makedirs(stabDir, exist_ok=True) |
30 | 38 |
|
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" |
33 | 40 |
|
34 | 41 | 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) |
38 | 45 |
|
39 | 46 | 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, |
42 | 49 | aspectRatio=4, meshRatio=1, resFactor=1, |
43 | 50 | Rayleigh=Rayleigh, Prandtl=0.7, |
44 | 51 | ) |
|
49 | 56 | output = OutputFiles(runDir) |
50 | 57 | spectrum = output.getSpectrum(which="all", start=1) |
51 | 58 |
|
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)) |
53 | 62 |
|
54 | | -# plt.legend() |
| 63 | +plt.legend() |
0 commit comments