Skip to content

Commit 06fd239

Browse files
committed
TL: script update
1 parent dc8558f commit 06fd239

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
postData

pySDC/playgrounds/dedalus/scripts/checkDNS.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
66
@author: cpf5546
77
"""
8+
import json
89
import pandas as pd
910
import matplotlib.pyplot as plt
1011

11-
from pySDC.playgrounds.dedalus.problems.rbc import OutputFiles, checkDNS
12-
13-
OutputFiles.VERBOSE = True
12+
from pySDC.playgrounds.dedalus.problems.rbc import checkDNS
1413

1514
simDirs = [
1615
"run_3D_A4_M0.5_R1_Ra5e3",
@@ -29,30 +28,33 @@
2928
"run_3D_A4_M1_R1_Ra1e6",
3029
]
3130

32-
simDirs = [
31+
runs = [
3332
"run_3D_A4_M1_R2_Ra1.5e5",
33+
"run_3D_A4_M1_R2_Ra3e5",
34+
"run_3D_A4_M1_R2_Ra5e5",
35+
"run_3D_A4_M1_R2_Ra8e5",
36+
"run_3D_A4_M1_R2_Ra9.5e5",
3437
"run_3D_A4_M1_R2_Ra1e6",
38+
"run_3D_A4_M1_R2_Ra2e6"
39+
]
40+
41+
runs = [
42+
"run_3D_A4_M1_R4_Ra2e6",
43+
"run_3D_A4_M1_R4_Ra5e6",
3544
]
3645

3746
df = pd.DataFrame(
3847
columns=["Ra", "c_2[u]", "c_2[uv]", "c_2[uh]", "c_2[b]", "c_2[p]"])
3948

40-
for i, dirName in enumerate(simDirs):
49+
for i, run in enumerate(runs):
4150

42-
output = OutputFiles(dirName)
43-
df.loc[i, "Ra"] = float(dirName.split("_Ra")[-1])
51+
with open(f"postData/{run}.json", "r") as f:
52+
data = json.load(f)
4453

45-
# assert len(output.times) == 61, f"not 61 fields for {dirName}"
46-
# if len(output.times) == 61:
47-
# start = 20
48-
# else:
49-
# start = 60
50-
start = 20
54+
df.loc[i, "Ra"] = data["infos"]["Ra"]
5155

52-
spectrum = output.getSpectrum(
53-
which="all", zVal="all",
54-
start=start, batchSize=None)
55-
kappa = output.kappa
56+
spectrum = data["spectrum"]
57+
kappa = data["spectrum"]["kappa"]
5658

5759
for name in ["u", "uv", "uh", "b", "p"]:
5860
check = checkDNS(spectrum[name], kappa)
@@ -70,4 +72,5 @@
7072
plt.ylabel("quadratic coefficient $c_2$")
7173
plt.tight_layout()
7274

73-
# df.columns = ["$"+label+"$" for label in df.columns]
75+
df.columns = ["$"+label+"$" for label in df.columns]
76+
print(df.to_markdown(index=False))
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
"""
4+
Created on Tue Oct 21 14:26:58 2025
5+
6+
@author: cpf5546
7+
"""
8+
import json
9+
import numpy as np
10+
import matplotlib.pyplot as plt
11+
12+
13+
data = [
14+
("run_3D_A4_M1_R4_Ra2e6", "$Ra=2e6$"),
15+
("run_3D_A4_M1_R4_Ra5e6", "$Ra=5e6$"),
16+
]
17+
18+
plt.figure("spectrum")
19+
for run, label in data:
20+
21+
with open(f"postData/{run}.json", "r") as f:
22+
data = json.load(f)
23+
24+
spectrum = data["spectrum"]
25+
kappa = np.array(spectrum["kappa"])
26+
27+
var = "uh"
28+
plt.loglog(kappa[1:], spectrum[var][1:], label=f"$E({var})$ ({label})")
29+
30+
plt.loglog(kappa[1:], kappa[1:]**(-5/3), '--k')
31+
plt.text(10, 0.1, r"$\kappa^{-5/3}$", fontsize=16)
32+
plt.legend(); plt.grid(True)
33+
plt.ylabel("spectrum"); plt.xlabel(r"wavenumber $\kappa$")
34+
plt.tight_layout()

0 commit comments

Comments
 (0)