{ "cells": [ { "cell_type": "markdown", "id": "a6ea5dab-edc6-4254-9bf6-a1751b8455e9", "metadata": {}, "source": [ "# Part 1. Running the simulations\n", "\n", "It is common for a study to have to run few similar simulations with different values of some parameters. With Fluidsim, we usually do that with a Python script with arguments." ] }, { "cell_type": "code", "execution_count": 1, "id": "950ceee7-079c-4707-bf19-6453009311cf", "metadata": {}, "outputs": [], "source": [ "import shutil\n", "import subprocess\n", "from pathlib import Path\n", "\n", "from IPython.display import Markdown as md" ] }, { "cell_type": "code", "execution_count": 2, "id": "4a2bf064-24f9-4fd6-8b47-8cfe94d93af3", "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pyplot as plt\n", "\n", "plt.rc(\"figure\", dpi=80)" ] }, { "cell_type": "code", "execution_count": 3, "id": "109efe6b-7ed6-4447-a6fb-a21d469ce0e9", "metadata": {}, "outputs": [], "source": [ "import ipynbname\n", "\n", "nb_path = ipynbname.path()\n", "path_this_dir = nb_path.parent\n", "script_run_simul = path_this_dir / \"run_simul.py\"\n", "assert script_run_simul.exists()\n", "script_submit_simul = path_this_dir / \"submit_simul.py\"\n", "assert script_submit_simul.exists()" ] }, { "cell_type": "markdown", "id": "e42386e5-ccf9-4c04-b369-eb4778e819b9", "metadata": {}, "source": [ "## One simulation script using argparse for the input parameters\n", "\n", "It is convenient to write one script with input parameters. The simplest solution is to use the standard library module `argparse`.\n", "\n", "We can also in this script handle the restart of simulations. However, here we keep it simple and do not care about restarting.\n", "\n", "So here is our script \"run_simul.py\", which is a slightly simplified version of a script used for a real study." ] }, { "cell_type": "code", "execution_count": 4, "id": "5acc669d-5242-4520-89ea-6446e336be9a", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "```Python\n", "from math import pi\n", "import argparse\n", "\n", "from fluiddyn.util import mpi\n", "\n", "from fluidsim.solvers.ns3d.strat.solver import Simul\n", "from fluidsim.base.forcing.milestone import PeriodicUniform\n", "\n", "from fluidsim.extend_simul.spatial_means_regions_milestone import (\n", " SpatialMeansRegions,\n", ")\n", "from fluidsim.extend_simul import extend_simul_class\n", "\n", "Simul = extend_simul_class(Simul, SpatialMeansRegions)\n", "\n", "parser = argparse.ArgumentParser()\n", "parser.add_argument(\"-N\", type=float, default=0.5, help=\"Brunt–Väisälä frequency\")\n", "\n", "parser.add_argument(\n", " \"-D\", \"--diameter\", type=float, default=0.25, help=\"Diameter of the cylinders\"\n", ")\n", "\n", "parser.add_argument(\n", " \"-s\",\n", " \"--speed\",\n", " type=float,\n", " default=0.1,\n", " help=\"Maximum speed of the cylinders\",\n", ")\n", "\n", "parser.add_argument(\n", " \"-nc\", \"--number_cylinders\", type=int, default=3, help=\"Number of cylinders\"\n", ")\n", "\n", "parser.add_argument(\n", " \"-nypc\",\n", " \"--ny_per_cylinder\",\n", " type=int,\n", " default=60,\n", " help=\"Number of numerical points for one cylinder\",\n", ")\n", "\n", "parser.add_argument(\n", " \"-np\",\n", " \"--n_periods\",\n", " type=float,\n", " default=5,\n", " help=\"Number of periods\",\n", ")\n", "\n", "parser.add_argument(\n", " \"-oi\",\n", " \"--only_init\",\n", " action=\"store_true\",\n", " help=\"Only run initialization phase\",\n", ")\n", "\n", "parser.add_argument(\n", " \"-wbl\",\n", " \"--width_boundary_layers\",\n", " type=float,\n", " default=0.02,\n", " help=\"width boundary layers\",\n", ")\n", "\n", "\n", "def main(args):\n", "\n", " params = Simul.create_default_params()\n", "\n", " diameter = args.diameter # m\n", " speed = args.speed # m/s\n", " params.N = args.N # rad/s\n", "\n", " mesh = 3 * diameter\n", " number_cylinders = args.number_cylinders\n", "\n", " ly = params.oper.Ly = mesh * number_cylinders\n", " lx = params.oper.Lx = 1.5 * 3\n", " ny = params.oper.ny = args.ny_per_cylinder * number_cylinders\n", "\n", " nx_float = ny * lx / ly\n", " nx = params.oper.nx = round(nx_float)\n", " assert nx == nx_float\n", "\n", " dx = lx / nx\n", " mpi.printby0(f\"{dx = }\")\n", "\n", " lz = params.oper.Lz = mesh\n", " params.oper.nz = round(lz / dx)\n", "\n", " params.oper.coef_dealiasing = 0.8\n", " params.oper.NO_SHEAR_MODES = True\n", " params.no_vz_kz0 = True\n", "\n", " params.forcing.enable = True\n", " params.forcing.type = \"milestone\"\n", " params.forcing.milestone.nx_max = min(\n", " nx, round(16 * number_cylinders * nx / ny)\n", " )\n", " mpi.printby0(f\"{params.forcing.milestone.nx_max = }\")\n", "\n", " objects = params.forcing.milestone.objects\n", "\n", " objects.number = number_cylinders\n", " objects.diameter = diameter\n", " objects.width_boundary_layers = args.width_boundary_layers\n", " assert objects.width_boundary_layers < diameter / 4\n", "\n", " movement = params.forcing.milestone.movement\n", "\n", " movement.type = \"periodic_uniform\"\n", " movement.periodic_uniform.length = lx - 2 * diameter\n", " movement.periodic_uniform.length_acc = 0.25\n", " movement.periodic_uniform.speed = speed\n", "\n", " params.init_fields.type = \"noise\"\n", " params.init_fields.noise.velo_max = 5e-3\n", "\n", " movement = PeriodicUniform(\n", " speed,\n", " movement.periodic_uniform.length,\n", " movement.periodic_uniform.length_acc,\n", " lx,\n", " )\n", "\n", " params.time_stepping.t_end = movement.period * args.n_periods\n", " params.time_stepping.deltat_max = 0.04 * diameter / speed\n", " mpi.printby0(f\"{params.time_stepping.deltat_max = }\")\n", "\n", " params.nu_2 = 1e-6\n", "\n", " epsilon_eval = 0.02 * speed ** 3 / mesh\n", " eta_elav = (params.nu_2 ** 3 / epsilon_eval) ** (1 / 4)\n", "\n", " kmax = params.oper.coef_dealiasing * pi / dx\n", " eta_kmax = 2 * pi / kmax\n", " nu_2_needed = (epsilon_eval * eta_kmax ** 4) ** (1 / 3)\n", "\n", " mpi.printby0(\"eta_elav * kmax:\", eta_elav * kmax)\n", "\n", " freq_nu4 = 0.5 * (nu_2_needed - params.nu_2) * kmax ** 2\n", "\n", " mpi.printby0(\"freq_nu4\", freq_nu4)\n", " mpi.printby0(\"freq_nu4 / freq_nu2\", freq_nu4 / (params.nu_2 * kmax ** 2))\n", "\n", " params.nu_4 = freq_nu4 / kmax ** 4\n", "\n", " params.output.sub_directory = \"tutorial_parametric_study\"\n", " if nx > 500:\n", " params.output.periods_print.print_stdout = movement.period / 50.0\n", " else:\n", " params.output.periods_print.print_stdout = movement.period / 20.0\n", "\n", " periods_save = params.output.periods_save\n", " periods_save.phys_fields = movement.period / 10.0\n", " periods_save.spatial_means = movement.period / 1000.0\n", " periods_save.spatial_means_regions = movement.period / 1000.0\n", " periods_save.spect_energy_budg = movement.period / 50.0\n", " periods_save.spectra = movement.period / 100.0\n", " periods_save.spatiotemporal_spectra = 2 * pi / params.N / 4\n", "\n", " params.output.spatial_means_regions.xmin = [0, 0.1, 0.4, 0.7]\n", " params.output.spatial_means_regions.xmax = [1, 0.3, 0.6, 0.9]\n", "\n", " spatiotemporal_spectra = params.output.spatiotemporal_spectra\n", " spatiotemporal_spectra.file_max_size = 20.0\n", " spatiotemporal_spectra.probes_region = (10 * lx / ly, 10, 10)\n", "\n", " params.output.spectra.kzkh_periodicity = 2\n", "\n", " sim = Simul(params)\n", "\n", " if not args.only_init:\n", " sim.time_stepping.start()\n", "\n", " return params, sim\n", "\n", "\n", "if __name__ == \"__main__\":\n", " args = parser.parse_args()\n", " mpi.printby0(args)\n", "\n", " params, sim = main(args)\n", "```" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with open(script_run_simul) as file:\n", " code = file.read()\n", "\n", "md(\"```Python\\n\" + code + \"```\")" ] }, { "cell_type": "markdown", "id": "0b079ab4-3071-4763-8f9f-106a72d761e6", "metadata": {}, "source": [ "## One script to submit jobs on a cluster\n", "\n", "Usually for parametric studies, we need to launch several simulations with different parameters. There are great tools to automate such scientific workflows (for example [execo](https://pypi.org/project/execo/)) but here, we keep it simple and just show a small script to launch simulations.\n", "\n", "Since modifying manually launching scripts in Bash is very error prone, we automate the process with the [fluiddyn.clusters](https://fluiddyn.readthedocs.io/en/latest/generated/fluiddyn.clusters.html) package." ] }, { "cell_type": "code", "execution_count": 5, "id": "ce867928-8a76-4dd2-ac04-104316bcb4ee", "metadata": {}, "outputs": [ { "data": { "text/markdown": [ "```Python\n", "from fluiddyn.clusters.legi import Calcul8 as Cluster\n", "\n", "cluster = Cluster()\n", "\n", "cluster.commands_setting_env = [\n", " \"source /etc/profile\",\n", " \". $HOME/miniconda3/etc/profile.d/conda.sh\",\n", " \"conda activate env_fluidsim\",\n", " \"export FLUIDSIM_PATH=/fsnet/project/watu/2020/20MILESTONE\",\n", "]\n", "\n", "diameters = [0.25, 0.5]\n", "velocities = [0.05, 0.1, 0.2]\n", "\n", "for diameter in diameters:\n", " for speed in velocities:\n", " cluster.submit_script(\n", " f\"run_simul.py -D {diameter} -s {speed}\",\n", " name_run=\"milestone\",\n", " nb_cores_per_node=10,\n", " nb_mpi_processes=10,\n", " omp_num_threads=1,\n", " ask=False,\n", " )\n", "```" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with open(script_submit_simul) as file:\n", " code = file.read()\n", "\n", "md(\"```Python\\n\" + code + \"```\")" ] }, { "cell_type": "code", "execution_count": 6, "id": "ff80d8de-ff40-4d13-8a9d-26ca0515b21a", "metadata": {}, "outputs": [], "source": [ "import fluidsim as fls\n", "\n", "path_dir_data = Path(fls.FLUIDSIM_PATH) / \"tutorial_parametric_study\"\n", "shutil.rmtree(path_dir_data, ignore_errors=True)" ] }, { "cell_type": "markdown", "id": "80d6c22c-dadc-40f8-aa17-a8a9fc954208", "metadata": {}, "source": [ "For this tutorial, we don't submit the simulations on a cluster but just run 3 simulations sequentially by calling directly `mpirun`." ] }, { "cell_type": "code", "execution_count": 7, "id": "80fbb653-a39f-427c-ac67-b3456abb27a5", "metadata": {}, "outputs": [], "source": [ "longer_simulations = True\n", "if longer_simulations:\n", " ny_per_cylinder = 48\n", " speeds = [0.01, 0.02, 0.04, 0.06, 0.08]\n", "else:\n", " ny_per_cylinder = 24\n", " speeds = [0.08]" ] }, { "cell_type": "code", "execution_count": 8, "id": "d1d6c60f-ab49-4167-8109-70fb98d8a856", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-------------------------------------------------------------------------------\n", "Simulation 0\n", "Namespace(N=0.2, diameter=0.5, speed=0.01, number_cylinders=3, ny_per_cylinder=48, n_periods=2.0, only_init=False, width_boundary_layers=0.1)\n", "dx = 0.03125\n", "params.forcing.milestone.nx_max = 48\n", "params.time_stepping.deltat_max = 2.0\n", "eta_elav * kmax: 0.23667650850121094\n", "freq_nu4 0.25288935238750754\n", "freq_nu4 / freq_nu2 39.09766924201435\n", "\n", "--------\n", "nb_proc: 2\n", "N0 = 48 ; N1 = 144 ; N2 = 144\n", "Initialization (FFT3DMPIWithFFTWMPI3D) done in 0.951517 s\n", "*************************************\n", "Program fluidsim\n", "sim: .NewSimul'>\n", "sim.output: \n", "sim.oper: \n", "sim.state: \n", "sim.time_stepping: \n", "sim.init_fields: \n", "sim.forcing: \n", "\n", "solver ns3d.strat, RK4 and parallel (2 proc.)\n", "type fft: fluidfft.fft3d.mpi_with_fftwmpi3d\n", "nx = 144 ; ny = 144 ; nz = 48\n", "Lx = 4.5 ; Ly = 4.5 ; Lz = 1.5\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.01_D0.5_2021-10-05_15-35-47\n", "init_fields.type: noise\n", "\n", "Initialization outputs:\n", "sim.output.phys_fields: \n", "sim.output.spatial_means: \n", "sim.output.spatial_means_regions:\n", "sim.output.spatiotemporal_spectra:\n", "sim.output.spectra: \n", "sim.output.spect_energy_budg: \n", "sim.output.temporal_spectra: \n", "\n", "Memory usage at the end of init. (equiv. seq.): 637.14453125 Mo\n", "Size of state_spect (equiv. seq.): 32.292864 Mo\n", "*************************************\n", "Beginning of the computation\n", "save state_phys in file state_phys_t000000.000.nc\n", " compute until t = 1600\n", "it = 0 ; t = 0 ; deltat = 2\n", " energy = 2.627e-06 ; Delta energy = +0.000e+00\n", "\n", "MEMORY_USAGE: 639.140625 Mo\n", "it = 20 ; t = 40 ; deltat = 2\n", "[...]\n", "MEMORY_USAGE: 746.9921875 Mo\n", "Computation completed in 2183.46 s\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.01_D0.5_2021-10-05_15-35-47\n", "it = 2117 ; t = 1600.67 ; deltat = 0.70343\n", " energy = 2.778e-05 ; Delta energy = -4.844e-06\n", " estimated remaining duration = -1 day, 23:59:59\n", "MEMORY_USAGE: 747.05859375 Mo\n", "save state_phys in file state_phys_t001600.674.nc\n", "\n", "-------------------------------------------------------------------------------\n", "Simulation 1\n", "Namespace(N=0.2, diameter=0.5, speed=0.02, number_cylinders=3, ny_per_cylinder=48, n_periods=2.0, only_init=False, width_boundary_layers=0.1)\n", "dx = 0.03125\n", "params.forcing.milestone.nx_max = 48\n", "params.time_stepping.deltat_max = 1.0\n", "eta_elav * kmax: 0.14072869393182103\n", "freq_nu4 0.509012776745164\n", "freq_nu4 / freq_nu2 78.6953384840287\n", "\n", "--------\n", "nb_proc: 2\n", "N0 = 48 ; N1 = 144 ; N2 = 144\n", "Initialization (FFT3DMPIWithFFTWMPI3D) done in 0.687727 s\n", "*************************************\n", "Program fluidsim\n", "sim: .NewSimul'>\n", "sim.output: \n", "sim.oper: \n", "sim.state: \n", "sim.time_stepping: \n", "sim.init_fields: \n", "sim.forcing: \n", "\n", "solver ns3d.strat, RK4 and parallel (2 proc.)\n", "type fft: fluidfft.fft3d.mpi_with_fftwmpi3d\n", "nx = 144 ; ny = 144 ; nz = 48\n", "Lx = 4.5 ; Ly = 4.5 ; Lz = 1.5\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.02_D0.5_2021-10-05_16-12-36\n", "init_fields.type: noise\n", "\n", "Initialization outputs:\n", "sim.output.phys_fields: \n", "sim.output.spatial_means: \n", "sim.output.spatial_means_regions:\n", "sim.output.spatiotemporal_spectra:\n", "sim.output.spectra: \n", "sim.output.spect_energy_budg: \n", "sim.output.temporal_spectra: \n", "\n", "Memory usage at the end of init. (equiv. seq.): 600.65234375 Mo\n", "Size of state_spect (equiv. seq.): 32.292864 Mo\n", "*************************************\n", "Beginning of the computation\n", "save state_phys in file state_phys_t00000.000.nc\n", " compute until t = 800\n", "it = 0 ; t = 0 ; deltat = 1\n", " energy = 2.627e-06 ; Delta energy = +0.000e+00\n", "\n", "MEMORY_USAGE: 600.8671875 Mo\n", "it = 20 ; t = 20 ; deltat = 1\n", "[...]\n", "MEMORY_USAGE: 623.93359375 Mo\n", "Computation completed in 2188.39 s\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.02_D0.5_2021-10-05_16-12-36\n", "it = 2252 ; t = 800.132 ; deltat = 0.31235\n", " energy = 1.120e-04 ; Delta energy = -1.984e-05\n", " estimated remaining duration = 0:00:00\n", "MEMORY_USAGE: 623.93359375 Mo\n", "save state_phys in file state_phys_t00800.132.nc\n", "\n", "-------------------------------------------------------------------------------\n", "Simulation 2\n", "Namespace(N=0.2, diameter=0.5, speed=0.04, number_cylinders=3, ny_per_cylinder=48, n_periods=2.0, only_init=False, width_boundary_layers=0.1)\n", "dx = 0.03125\n", "params.forcing.milestone.nx_max = 48\n", "params.time_stepping.deltat_max = 0.5\n", "eta_elav * kmax: 0.08367778205438091\n", "freq_nu4 1.0212596254604769\n", "freq_nu4 / freq_nu2 157.8906769680574\n", "\n", "--------\n", "nb_proc: 2\n", "N0 = 48 ; N1 = 144 ; N2 = 144\n", "Initialization (FFT3DMPIWithFFTWMPI3D) done in 0.697291 s\n", "*************************************\n", "Program fluidsim\n", "sim: .NewSimul'>\n", "sim.output: \n", "sim.oper: \n", "sim.state: \n", "sim.time_stepping: \n", "sim.init_fields: \n", "sim.forcing: \n", "\n", "solver ns3d.strat, RK4 and parallel (2 proc.)\n", "type fft: fluidfft.fft3d.mpi_with_fftwmpi3d\n", "nx = 144 ; ny = 144 ; nz = 48\n", "Lx = 4.5 ; Ly = 4.5 ; Lz = 1.5\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.04_D0.5_2021-10-05_16-49-31\n", "init_fields.type: noise\n", "\n", "Initialization outputs:\n", "sim.output.phys_fields: \n", "sim.output.spatial_means: \n", "sim.output.spatial_means_regions:\n", "sim.output.spatiotemporal_spectra:\n", "sim.output.spectra: \n", "sim.output.spect_energy_budg: \n", "sim.output.temporal_spectra: \n", "\n", "Memory usage at the end of init. (equiv. seq.): 633.28515625 Mo\n", "Size of state_spect (equiv. seq.): 32.292864 Mo\n", "*************************************\n", "Beginning of the computation\n", "save state_phys in file state_phys_t00000.000.nc\n", " compute until t = 400\n", "it = 0 ; t = 0 ; deltat = 0.5\n", " energy = 2.627e-06 ; Delta energy = +0.000e+00\n", "\n", "MEMORY_USAGE: 637.1015625 Mo\n", "it = 20 ; t = 10 ; deltat = 0.5\n", "[...]\n", "MEMORY_USAGE: 660.9765625 Mo\n", "Computation completed in 2148.95 s\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.04_D0.5_2021-10-05_16-49-31\n", "it = 2342 ; t = 400.025 ; deltat = 0.15199\n", " energy = 4.473e-04 ; Delta energy = -8.048e-05\n", " estimated remaining duration = 0:00:00\n", "MEMORY_USAGE: 661.1640625 Mo\n", "save state_phys in file state_phys_t00400.025.nc\n", "\n", "-------------------------------------------------------------------------------\n", "Simulation 3\n", "Namespace(N=0.2, diameter=0.5, speed=0.06, number_cylinders=3, ny_per_cylinder=48, n_periods=2.0, only_init=False, width_boundary_layers=0.1)\n", "dx = 0.03125\n", "params.forcing.milestone.nx_max = 48\n", "params.time_stepping.deltat_max = 0.33333333333333337\n", "eta_elav * kmax: 0.06173645898680493\n", "freq_nu4 1.5335064741757896\n", "freq_nu4 / freq_nu2 237.08601545208603\n", "\n", "--------\n", "nb_proc: 2\n", "N0 = 48 ; N1 = 144 ; N2 = 144\n", "Initialization (FFT3DMPIWithFFTWMPI3D) done in 0.696624 s\n", "*************************************\n", "Program fluidsim\n", "sim: .NewSimul'>\n", "sim.output: \n", "sim.oper: \n", "sim.state: \n", "sim.time_stepping: \n", "sim.init_fields: \n", "sim.forcing: \n", "\n", "solver ns3d.strat, RK4 and parallel (2 proc.)\n", "type fft: fluidfft.fft3d.mpi_with_fftwmpi3d\n", "nx = 144 ; ny = 144 ; nz = 48\n", "Lx = 4.5 ; Ly = 4.5 ; Lz = 1.5\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.06_D0.5_2021-10-05_17-25-48\n", "init_fields.type: noise\n", "\n", "Initialization outputs:\n", "sim.output.phys_fields: \n", "sim.output.spatial_means: \n", "sim.output.spatial_means_regions:\n", "sim.output.spatiotemporal_spectra:\n", "sim.output.spectra: \n", "sim.output.spect_energy_budg: \n", "sim.output.temporal_spectra: \n", "\n", "Memory usage at the end of init. (equiv. seq.): 619.40234375 Mo\n", "Size of state_spect (equiv. seq.): 32.292864 Mo\n", "*************************************\n", "Beginning of the computation\n", "save state_phys in file state_phys_t00000.000.nc\n", " compute until t = 266.667\n", "it = 0 ; t = 0 ; deltat = 0.33333\n", " energy = 2.627e-06 ; Delta energy = +0.000e+00\n", "\n", "MEMORY_USAGE: 619.55859375 Mo\n", "it = 21 ; t = 7 ; deltat = 0.33333\n", "[...]\n", "MEMORY_USAGE: 658.9296875 Mo\n", "Computation completed in 2107.82 s\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.06_D0.5_2021-10-05_17-25-48\n", "it = 2353 ; t = 266.703 ; deltat = 0.10818\n", " energy = 1.034e-03 ; Delta energy = -1.524e-04\n", " estimated remaining duration = 0:00:00\n", "MEMORY_USAGE: 658.9296875 Mo\n", "save state_phys in file state_phys_t00266.703.nc\n", "\n", "-------------------------------------------------------------------------------\n", "Simulation 4\n", "Namespace(N=0.2, diameter=0.5, speed=0.08, number_cylinders=3, ny_per_cylinder=48, n_periods=2.0, only_init=False, width_boundary_layers=0.1)\n", "dx = 0.03125\n", "params.forcing.milestone.nx_max = 48\n", "params.time_stepping.deltat_max = 0.25\n", "eta_elav * kmax: 0.04975510689335839\n", "freq_nu4 2.0457533228911022\n", "freq_nu4 / freq_nu2 316.28135393611467\n", "\n", "--------\n", "nb_proc: 2\n", "N0 = 48 ; N1 = 144 ; N2 = 144\n", "Initialization (FFT3DMPIWithFFTWMPI3D) done in 0.669142 s\n", "*************************************\n", "Program fluidsim\n", "sim: .NewSimul'>\n", "sim.output: \n", "sim.oper: \n", "sim.state: \n", "sim.time_stepping: \n", "sim.init_fields: \n", "sim.forcing: \n", "\n", "solver ns3d.strat, RK4 and parallel (2 proc.)\n", "type fft: fluidfft.fft3d.mpi_with_fftwmpi3d\n", "nx = 144 ; ny = 144 ; nz = 48\n", "Lx = 4.5 ; Ly = 4.5 ; Lz = 1.5\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.08_D0.5_2021-10-05_18-01-23\n", "init_fields.type: noise\n", "\n", "Initialization outputs:\n", "sim.output.phys_fields: \n", "sim.output.spatial_means: \n", "sim.output.spatial_means_regions:\n", "sim.output.spatiotemporal_spectra:\n", "sim.output.spectra: \n", "sim.output.spect_energy_budg: \n", "sim.output.temporal_spectra: \n", "\n", "Memory usage at the end of init. (equiv. seq.): 647.98046875 Mo\n", "Size of state_spect (equiv. seq.): 32.292864 Mo\n", "*************************************\n", "Beginning of the computation\n", "save state_phys in file state_phys_t00000.000.nc\n", " compute until t = 200\n", "it = 0 ; t = 0 ; deltat = 0.25\n", " energy = 2.627e-06 ; Delta energy = +0.000e+00\n", "\n", "MEMORY_USAGE: 644.4765625 Mo\n", "it = 20 ; t = 5 ; deltat = 0.25\n", "[...]\n", "MEMORY_USAGE: 663.828125 Mo\n", "Computation completed in 2163.67 s\n", "path_run =\n", "/home/pierre/Sim_data/tutorial_parametric_study/ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.08_D0.5_2021-10-05_18-01-23\n", "it = 2431 ; t = 200.024 ; deltat = 0.074523\n", " energy = 1.912e-03 ; Delta energy = -2.816e-04\n", " estimated remaining duration = 0:00:00\n", "MEMORY_USAGE: 663.83984375 Mo\n", "save state_phys in file state_phys_t00200.024.nc\n", "\n" ] } ], "source": [ "logs = []\n", "for isim, speed in enumerate(speeds):\n", " print(\"-\" * 79 + f\"\\nSimulation {isim}\")\n", " process = subprocess.run(\n", " (\n", " f\"mpirun -np 2 python {script_run_simul} \"\n", " f\"-N 0.2 --diameter 0.5 --speed {speed} \"\n", " f\"--ny_per_cylinder {ny_per_cylinder} \"\n", " \"--number_cylinders 3 --width_boundary_layers 0.1 --n_periods 2\"\n", " ).split(),\n", " stdout=subprocess.PIPE,\n", " stderr=subprocess.DEVNULL, # hiding irrelevant warnings\n", " text=True,\n", " )\n", " lines = process.stdout.split(\"\\n\")\n", " print(\"\\n\".join(lines[:50]) + \"\\n[...]\\n\" + \"\\n\".join(lines[-10:]))" ] }, { "cell_type": "markdown", "id": "aea16d72-a23a-4251-9c7f-f95c12672c6e", "metadata": {}, "source": [ "The data created during the simulations should be in `path_dir_data`. Let's have a look:" ] }, { "cell_type": "code", "execution_count": 9, "id": "b520fd7e-d5e6-4746-be68-efe0606a3af8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.01_D0.5_2021-10-05_15-35-47',\n", " 'ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.02_D0.5_2021-10-05_16-12-36',\n", " 'ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.04_D0.5_2021-10-05_16-49-31',\n", " 'ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.06_D0.5_2021-10-05_17-25-48',\n", " 'ns3d.strat_144x144x48_V4.5x4.5x1.5_N0.2_Lf3.5_U0.08_D0.5_2021-10-05_18-01-23']" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "path_runs = sorted(path_dir_data.glob(\"*\"), key=lambda p: p.name)\n", "[p.name for p in path_runs]" ] }, { "cell_type": "markdown", "id": "5607cea9-61bc-4945-ad55-2c9d8aebc44d", "metadata": {}, "source": [ "We see that the directory names are understandable by humans and tell us about the parameters of the simulations." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.6" } }, "nbformat": 4, "nbformat_minor": 5 }