skills/fluidsim/references/simulation_workflow.md
Before code, record:
Do not proceed from a prompt that only says “simulate turbulence” or supplies a Reynolds number without its definition and scaling.
Every plan must explicitly bound:
max_elapsed.The bundled JSON schema requires these fields. Start from:
python3 scripts/solver_config_validator.py --example
Save the reviewed JSON locally, then:
python3 scripts/solver_config_validator.py --config config.json
python3 scripts/grid_resource_estimator.py --config config.json
python3 scripts/simulation_dry_run.py --config config.json --output run.py
The generator does not import FluidSim or run anything. The generated script
prints a JSON dry run by default. Execution requires both --execute and the
exact reviewed config ID. An MPI plan is only a command preview; the tool never
invokes a launcher or scheduler.
In an isolated exact environment:
from importlib.metadata import version
from fluidfft import get_methods
assert version("fluidsim") == "0.9.0"
assert version("fluidfft") == "0.4.5"
print(sorted(get_methods()))
Record the actual FFT methods. A documented method that is absent from
get_methods() is not installed. Importing a package is not enough: construct
the selected solver's defaults.
After approval, use a trivial, bounded state:
from fluidsim.solvers.ns2d.solver import Simul
params = Simul.create_default_params()
params.oper.nx = params.oper.ny = 8
params.oper.Lx = params.oper.Ly = 2.0
params.oper.coef_dealiasing = 2 / 3
params.time_stepping.USE_CFL = False
params.time_stepping.deltat0 = 0.001
params.time_stepping.deltat_max = 0.001
params.time_stepping.t_end = 0.001
params.time_stepping.max_elapsed = "00:01:00"
params.init_fields.type = "constant"
params.init_fields.constant.value = 0.0
params.output.HAS_TO_SAVE = False
params.output.ONLINE_PLOT_OK = False
sim = Simul(params)
sim.time_stepping.start()
This checks import, FFT construction, initialization, and one bounded step. It does not test the intended physics, forcing, conservation, convergence, performance, output, or restart.
Use a dedicated empty output root under a quota. Keep:
params.output.sub_directory a safe one-component study identifier.ONLINE_PLOT_OK = False for unattended runs.t_end, short max_elapsed, and low resolution.Inspect before analysis:
python3 scripts/output_inventory.py --path fluidsim-runs
python3 scripts/budget_summary.py --path fluidsim-runs
Confirm exact filenames and growth. FluidSim 0.9 defaults to
state_phys_t*.nc for physical states; spectra remain HDF5.
Increase only enough to exercise the intended:
During and after the pilot, check:
deltat history against all relevant wave/advection/diffusion limits.A passing pilot permits planning a refinement study; it does not validate a production run.
The generated script is deliberately gated:
python3 run.py
python3 run.py --execute --acknowledge-config-id REVIEWED_CONFIG_ID
The first command is dry-run only. The second is a real simulation and must be issued by the user or approved operator after reviewing limits and output destination.
Never silently increase resolution, duration, save frequency, rank count, or wall time after approval.
Use the lightweight loader:
from fluidsim import load_sim_for_plot
sim = load_sim_for_plot(
"run-directory",
merge_missing_params=False,
hide_stdout=True,
)
Official 0.9 source shows that it:
NEW_DIR_RESULTS = False.output.HAS_TO_SAVE = False and ONLINE_PLOT_OK = False.merge_missing_params=True helps load old metadata but does not prove that an
old result is scientifically or numerically equivalent under the new version.
from fluidsim import load_state_phys_file
sim = load_state_phys_file(
"run-directory",
t_approx="last",
modif_save_params=True,
merge_missing_params=False,
init_with_initialized_state=True,
hide_stdout=True,
)
This constructs a full-resolution operator and loads state; it can be expensive.
With the default modif_save_params=True, saving and online plotting are
disabled. Loading a state object is not the same as approving a restart.
First compare metadata:
python3 scripts/restart_compatibility.py \
--source state_phys_t001.000.nc \
--target-config restart-config.json
Then, after approval:
from fluidsim import load_for_restart
params, Simul = load_for_restart(
"run-directory",
t_approx="last",
merge_missing_params=False,
)
params.time_stepping.t_end = 2.0
params.time_stepping.max_elapsed = "00:10:00"
params.NEW_DIR_RESULTS = True
sim = Simul(params)
sim.time_stepping.start()
load_for_restart reads parameters from /info_simul/params, sets
init_fields.type = "from_file", points it to the selected state file, and by
default sets NEW_DIR_RESULTS = False. Explicitly choose append versus new
directory. Never append to an irreplaceable run without a backup and checksum.
Record:
FluidSim 0.9.0 stores “state parameters” in restarting files. FluidSim 0.8.6 fixed incorrect restart of time-correlated forcing; old checkpoints need extra review.
Safe first action:
fluidsim-restart --only-check run-directory --t_end 2.0
Current options include --only-check, --only-init, --new-dir-results,
--t_approx, target/additive time or iteration bounds,
--merge-missing-params, and --max-elapsed.
Avoid --modify-params with any untrusted or generated text. Official source
passes that string to Python code execution. The bundled generator never emits
this option.
The CLI does not supply scheduler resource limits. Running it under MPI or a scheduler remains a separate, explicit operational action.
Do not change oper.nx/ny/nz and treat an old state file as directly compatible.
FluidSim provides:
fluidsim-modif-resolution run-directory 5/4
This creates a new state at modified resolution. Before use:
Do not run this automatically or on a large state by default.
After a serial pilot:
The 2019 FluidSim/FluidFFT performance results are hardware- and shape-specific. Do not extrapolate their wall times or fastest backend to another cluster.