Run a simple simulation and launch it on a cluster

Of course online plotting slows down the simulation, so for larger simulation we just remove the plot command from the script, which gives:

from math import pi

from fluidsim.solvers.ns2d.solver import Simul

params = Simul.create_default_params()

params.output.sub_directory = "examples_restart"

params.oper.nx = params.oper.ny = nh = 24
params.oper.Lx = params.oper.Ly = Lh = 2 * pi

delta_x = Lh / nh
params.nu_8 = 2.0 * params.forcing.forcing_rate ** (1.0 / 3) * delta_x**8

params.time_stepping.t_end = 2.0

params.init_fields.type = "dipole"

params.forcing.enable = True
params.forcing.type = "proportional"

params.output.periods_print.print_stdout = 0.25

params.output.periods_save.phys_fields = 1.0
params.output.periods_save.spectra = 0.5
params.output.periods_save.spatial_means = 0.05
params.output.periods_save.spect_energy_budg = 0.5
params.output.periods_save.increments = 0.5

params.output.periods_plot.phys_fields = 0.0

sim = Simul(params)

sim.time_stepping.start()

This script can be launched by the commands python simul_ns2d.py (sequential) and mpirun -np 4 python simul_ns2d.py (parallel on 4 processes).

To submit the simulation on a cluster (here on one node):

from fluiddyn.clusters.legi import Calcul as Cluster

# or
# from fluiddyn.clusters.legi import Calcul7 as Cluster
# or
# from fluiddyn.clusters.legi import Calcul8 as Cluster

cluster = Cluster()

cluster.commands_setting_env = [
    "source /etc/profile",
    'export PATH="$HOME/miniconda3/bin:$PATH"',
]

cluster.submit_script(
    "simul_ns2d.py",
    name_run="fld_example",
    nb_cores_per_node=4,
    nb_mpi_processes=4,
    omp_num_threads=1,
)