|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | # -*- coding: utf-8 -*- |
3 | 3 | import argparse |
| 4 | +import json |
4 | 5 |
|
5 | | -from pySDC.playgrounds.dedalus.problems.rbc import RBCProblem2D, RBCProblem3D |
6 | 6 |
|
7 | 7 | parser = argparse.ArgumentParser( |
8 | 8 | description='Run RBC simulation using Dedalus', |
9 | 9 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) |
10 | 10 |
|
11 | 11 | parser.add_argument( |
12 | 12 | "runDir", help="name of the simulation directory") |
| 13 | +parser.add_argument( |
| 14 | + "--baseDt", "-dt", help="time-step used with resFactor=1", |
| 15 | + default=1e-2/2, type=float) |
| 16 | +parser.add_argument( |
| 17 | + "--tEnd", "-t", help="end simulation time (tBeg=0)", |
| 18 | + default=100, type=float) |
13 | 19 |
|
14 | 20 | parser.add_argument( |
15 | 21 | "--dim", "-d", help="dimension for the simulation", |
16 | 22 | default=2, type=int, choices=[2, 3]) |
17 | 23 | parser.add_argument( |
18 | | - "--aspectRatio", "-ar", help="geometric aspect ratio, Lx = Ly = ar*Lz", |
| 24 | + "--aspectRatio", "-ar", help="geometric aspect ratio A, Lx = Ly = A*Lz", |
19 | 25 | default=4, type=float) |
20 | 26 | parser.add_argument( |
21 | | - "--meshRatio", "-mr", help="mesh point ratio, Nx/Lx = Ny/Ly = mr*Nz/Lz", |
| 27 | + "--meshRatio", "-mr", help="mesh point ratio M, Nx/Lx = Ny/Ly = M*Nz/Lz", |
22 | 28 | default=1, type=float) |
23 | 29 | parser.add_argument( |
24 | | - "--resFactor", "-rf", help="resolution factor, Nz = 64*rf (2D) or 32*rf (3D)", |
| 30 | + "--resFactor", "-rf", help="resolution factor R, Nz = 64*R (2D) or 32*R (3D)", |
25 | 31 | default=1, type=float) |
26 | 32 | parser.add_argument( |
27 | | - "--Rayleigh", "-Ra", help="Rayleigh number", |
| 33 | + "--Rayleigh", "-Ra", help="Rayleigh number Ra", |
28 | 34 | default=1e7, type=float) |
29 | 35 | parser.add_argument( |
30 | | - "--Prandtl", "-Pr", help="Prandtl number", |
| 36 | + "--Prandtl", "-Pr", help="Prandtl number Pr", |
31 | 37 | default=1, type=float) |
32 | 38 | parser.add_argument( |
33 | 39 | "--initField", "-if", help="path for the initial field", |
34 | 40 | default=None) |
35 | 41 |
|
36 | | -parser.add_argument( |
37 | | - "--baseDt", "-dt", help="time-step used with resFactor=1", |
38 | | - default=1e-2/2, type=float) |
39 | | -parser.add_argument( |
40 | | - "--tEnd", "-t", help="end simulation time (tBeg=0)", |
41 | | - default=100, type=float) |
42 | 42 | parser.add_argument( |
43 | 43 | "--dtWrite", "-dtw", help="time-step for writing solution output", |
44 | 44 | default=1, type=float) |
45 | 45 | parser.add_argument( |
46 | 46 | "--logEvery", "-l", help="log every [...] time-steps", |
47 | 47 | default=100, type=int) |
48 | 48 |
|
| 49 | +parser.add_argument( |
| 50 | + "--timeScheme", help="time integration method to be used", |
| 51 | + choices=["RK111", "RK222", "RK443", "SDC"]) |
| 52 | +parser.add_argument( |
| 53 | + "--timeParallel", help="which time-parallelization to use with SDC", |
| 54 | + choices=["MPI", "MPI2"], default=False) |
| 55 | +parser.add_argument( |
| 56 | + "--groupTimeProcs", help="wether or not grouping the time processes", |
| 57 | + action="store_true") |
| 58 | + |
| 59 | +parser.add_argument( |
| 60 | + "--nNodesSDC", help="number of time nodes per step for SDC", |
| 61 | + default=4, type=int) |
| 62 | +parser.add_argument( |
| 63 | + "--nNodesSDC", help="number of time nodes per step for SDC", |
| 64 | + default=4, type=int) |
| 65 | +parser.add_argument( |
| 66 | + "--nSweepSDC", help="number of sweep per step for SDC", |
| 67 | + default=4, type=int) |
| 68 | +parser.add_argument( |
| 69 | + "--implSweepSDC", help="implicit sweep type for SDC", |
| 70 | + default="MIN-SR-S") |
| 71 | +parser.add_argument( |
| 72 | + "--explSweepSDC", help="explicit sweep type for SDC", |
| 73 | + default="PIC") |
| 74 | + |
49 | 75 | args = parser.parse_args() |
| 76 | + |
| 77 | +# imports library after parsing args (do not import with --help) |
| 78 | +from pySDC.playgrounds.dedalus.timestepper import SDCIMEX, MPI |
| 79 | +from pySDC.playgrounds.dedalus.problems.rbc import RBCProblem2D, RBCProblem3D |
| 80 | + |
50 | 81 | params = args.__dict__ |
51 | 82 |
|
52 | 83 | dim = params.pop("dim") |
53 | 84 | ProblemClass = RBCProblem2D if dim == 2 else RBCProblem3D |
| 85 | +SDCIMEX.setParameters( |
| 86 | + nNodes=params.pop("nNodesSDC"), |
| 87 | + nodeType="LEGENDRE", quadType="RADAU-RIGHT", |
| 88 | + nSweeps=params.pop("nSweepSDC"), |
| 89 | + initSweep="COPY", |
| 90 | + implSweep=params.pop("implSweepSDC"), explSweep=params.pop("explSweepSDC"), |
| 91 | +) |
54 | 92 |
|
55 | 93 |
|
56 | | -ProblemClass.runSimulation(**params) |
| 94 | +prob = ProblemClass.runSimulation(**params) |
| 95 | +if MPI.COMM_WORLD.Get_rank() == 0: |
| 96 | + with open(f"{args.runDir}/infos.json", "w") as f: |
| 97 | + json.dump(prob.infos, f) |
0 commit comments