Skip to content

Commit

Permalink
Debugs 2D RBC plotting scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
evanhanders committed Aug 23, 2024
1 parent 5a0e522 commit a7220a7
Showing 8 changed files with 90 additions and 19 deletions.
71 changes: 71 additions & 0 deletions examples/d3/ivp_box_2d_rayleigh_benard/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 2D Rayleigh Benard Convection

This example problem is lifted directly from the dedalus repository. The types of plots you can make with plotpal are shown below:

# 2D slices

Plotpal can plot movies of 2D slices including multiple frames, using e.g.,

```sh
python3 plot_all_slices.py
```

Producing images like this one:

![Lots of slices](./example_figs/frames_000190.png)

Plotpal can also just do a movie of a single field if you want something less cluttered:

```sh
python3 plot_b_slices.py
```

Producing images like this one:

![A buoyancy slice](./example_figs/b_frames_000190.png)

# 1D Profiles

Plotpal can plot instantaneous 1D profiles from dedalus simulations:

```sh
python3 plot_instantaneous_profiles.py
```

Producing images like this one:

![A profile from a single Dedalus output](./example_figs/instantaneous_profiles_000190.png)

Plotpal can also plot a rolling average of profiles:

```sh
python3 plot_rolled_profiles.py
```

Producing less jittery images like this one:

![A profile averaged over multiple outputs](./example_figs/rolled_profiles_000190.png)

# PDFs

Plotpal can plot the PDFs of 2D flow fields:

```sh
python3 plot_b_pdf.py
```

Producing an image like this one:

![a PDF of the buoyancy field](./example_figs/b_pdf.png)

# Scalar Traces

Plotpal can plot the evolution over time of scalar outputs:

```sh
python3 plot_scalar_traces.py
```

Producing images like the one below:

![A trace of Nu and Re](./plot_scalar_traces.py)
6 changes: 3 additions & 3 deletions examples/d3/ivp_box_2d_rayleigh_benard/plot_all_slices.py
Original file line number Diff line number Diff line change
@@ -36,11 +36,11 @@

# Create Plotter object, tell it which fields to plot
plotter = SlicePlotter(
root_dir,
file_dir=data_dir,
run_dir=root_dir,
sub_dir=data_dir,
out_name=out_name,
start_file=start_file,
n_files=n_files,
num_files=n_files,
)
plotter_kwargs = {
"col_inch": float(args["--col_inch"]),
6 changes: 3 additions & 3 deletions examples/d3/ivp_box_2d_rayleigh_benard/plot_b_pdf.py
Original file line number Diff line number Diff line change
@@ -47,11 +47,11 @@
"b",
]
plotter = PdfPlotter(
root_dir,
file_dir=data_dir,
run_dir=root_dir,
sub_dir=data_dir,
out_name=out_name,
start_file=start_file,
n_files=n_files,
num_files=n_files,
)
plotter.calculate_pdfs(
pdfs_to_plot, bins=bins, threeD=threeD, bases=bases, uneven_basis="z"
Original file line number Diff line number Diff line change
@@ -33,11 +33,11 @@

# Create Plotter object, tell it which fields to plot
plotter = RolledProfilePlotter(
root_dir,
file_dir=data_dir,
run_dir=root_dir,
sub_dir=data_dir,
out_name=subdir_name,
start_file=start_file,
n_files=n_files,
num_files=n_files,
)
plotter.setup_grid(
num_rows=2,
Original file line number Diff line number Diff line change
@@ -37,12 +37,12 @@

# Create Plotter object, tell it which fields to plot
plotter = RolledProfilePlotter(
root_dir,
file_dir=data_dir,
run_dir=root_dir,
sub_dir=data_dir,
out_name=subdir_name,
roll_writes=roll_writes,
start_file=start_file,
n_files=n_files,
num_files=n_files,
)
plotter.setup_grid(
num_rows=2,
10 changes: 5 additions & 5 deletions examples/d3/ivp_box_2d_rayleigh_benard/plot_scalar_traces.py
Original file line number Diff line number Diff line change
@@ -36,17 +36,17 @@

# Nu vs time
fig1 = ScalarFigure(num_rows=2, num_cols=1, col_inch=6, fig_name="fundamentals")
fig1.add_field(0, "Re", color="orange")
fig1.add_field(1, "Nu", color="indigo")
fig1.add_field(0, "Re", extra_kwargs={"color": "orange"})
fig1.add_field(1, "Nu", extra_kwargs={"color": "indigo"})
figs.append(fig1)

# Load in figures and make plots
plotter = ScalarPlotter(
root_dir,
file_dir=data_dir,
run_dir=root_dir,
sub_dir=data_dir,
out_name=out_name,
start_file=start_file,
n_files=n_files,
num_files=n_files,
roll_writes=roll_writes,
)
plotter.load_figures(figs)
2 changes: 1 addition & 1 deletion plotpal/profiles.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@


def save_dim_scale(
dim: h5py._hl.dims.DimensionProxy,
dim: h5py.AttributeManager,
scale_group: h5py.Group,
task_name: str,
scale_name: str,
2 changes: 1 addition & 1 deletion plotpal/scalars.py
Original file line number Diff line number Diff line change
@@ -214,7 +214,7 @@ def plot_figures(self, dpi: int = 200, fig_name: str = "output") -> None:
fig_name : default name of the output figure (if not specified in the ScalarFigure object)
"""
with self.my_sync:
if self.trace_data is None:
if len(self.trace_data.keys()) == 0:
self._read_fields()
self._clear_figures()
if self.idle:

0 comments on commit a7220a7

Please sign in to comment.