From eb4002b5c81846dc7827633880a5bc917b9cf391 Mon Sep 17 00:00:00 2001 From: ali-ramadhan Date: Fri, 11 Sep 2020 22:34:31 -0400 Subject: [PATCH] Automate everything --- .../lid_driven_cavity/lid_driven_cavity.jl | 20 ++++++------- .../plot_lid_driven_cavity.py | 29 +++++++++---------- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/verification/lid_driven_cavity/lid_driven_cavity.jl b/verification/lid_driven_cavity/lid_driven_cavity.jl index ec0efa6e68..beda690e08 100644 --- a/verification/lid_driven_cavity/lid_driven_cavity.jl +++ b/verification/lid_driven_cavity/lid_driven_cavity.jl @@ -5,12 +5,10 @@ using Oceananigans.Diagnostics using Oceananigans.OutputWriters using Oceananigans.AbstractOperations -function simulate_lid_driven_cavity(; Re, end_time) - Ny = Nz = 128 - +function simulate_lid_driven_cavity(; Re, N, end_time) topology = (Flat, Bounded, Bounded) domain = (x=(0, 1), y=(0, 1), z=(0, 1)) - grid = RegularCartesianGrid(topology=topology, size=(1, Ny, Nz); domain...) + grid = RegularCartesianGrid(topology=topology, size=(1, N, N); domain...) v_bcs = VVelocityBoundaryConditions(grid, top = ValueBoundaryCondition(1.0), @@ -85,11 +83,11 @@ function print_progress(simulation) return nothing end - simulate_lid_driven_cavity(Re=100, end_time=15) - simulate_lid_driven_cavity(Re=400, end_time=20) - simulate_lid_driven_cavity(Re=1000, end_time=25) - simulate_lid_driven_cavity(Re=3200, end_time=50) - simulate_lid_driven_cavity(Re=5000, end_time=50) - simulate_lid_driven_cavity(Re=7500, end_time=75) - simulate_lid_driven_cavity(Re=10000, end_time=100) + simulate_lid_driven_cavity(Re=100, N=128, end_time=15) + simulate_lid_driven_cavity(Re=400, N=128, end_time=20) + simulate_lid_driven_cavity(Re=1000, N=128, end_time=25) + simulate_lid_driven_cavity(Re=3200, N=128, end_time=50) + simulate_lid_driven_cavity(Re=5000, N=256, end_time=50) + simulate_lid_driven_cavity(Re=7500, N=256, end_time=75) + simulate_lid_driven_cavity(Re=10000, N=256, end_time=100) diff --git a/verification/lid_driven_cavity/plot_lid_driven_cavity.py b/verification/lid_driven_cavity/plot_lid_driven_cavity.py index ea6fd8db61..4256b25d69 100644 --- a/verification/lid_driven_cavity/plot_lid_driven_cavity.py +++ b/verification/lid_driven_cavity/plot_lid_driven_cavity.py @@ -121,19 +121,18 @@ def plot_lid_driven_cavity_frame(Re, n): plt.savefig(f"lid_driven_cavity_Re{Re}_{n:05d}.png") plt.close("all") -Re = 100 -ds = xr.open_dataset(f"lid_driven_cavity_Re{Re}.nc") - -joblib.Parallel(n_jobs=-1)( - joblib.delayed(plot_lid_driven_cavity_frame)(Re, n) - for n in range(ds.time.size) -) - -( - ffmpeg - .input(f"lid_driven_cavity_Re{Re}_%05d.png", framerate=30) - .output(f"lid_driven_cavity_Re{Re}.mp4", crf=15, pix_fmt='yuv420p') - .overwrite_output() - .run() -) +for Re in [100, 400, 1000, 3200, 5000, 7500, 10000]: + ds = xr.open_dataset(f"lid_driven_cavity_Re{Re}.nc") + joblib.Parallel(n_jobs=-1)( + joblib.delayed(plot_lid_driven_cavity_frame)(Re, n) + for n in range(ds.time.size) + ) + + ( + ffmpeg + .input(f"lid_driven_cavity_Re{Re}_%05d.png", framerate=30) + .output(f"lid_driven_cavity_Re{Re}.mp4", crf=15, pix_fmt='yuv420p') + .overwrite_output() + .run() + )