
Fluidsim
Configure FluidSim turbulence runs with custom forcing, in-script initial conditions, and Fourier-space hooks from an agent.
Overview
fluidsim is an agent skill for the Build phase that documents FluidSim advanced forcing and in-script initialization patterns for turbulence and related simulations.
Install
npx skills add https://github.com/k-dense-ai/scientific-agent-skills --skill fluidsimWhat is this skill?
- Documents three forcing modes: time-correlated random (tcrandom), proportional, and in-script custom Fourier forcing
- Shows nkmin/nkmax wavenumber bands, forcing_rate, and tcrandom_time_correlation parameter tuning
- In-script path overrides compute_forcing_fft on the sim object before time_stepping.start()
- Custom initial conditions via in-script initialization for full field control
- Python launch-script pattern tying params, Simul, and forcing_maker overrides together
- Documents 3 forcing types: tcrandom, proportional, and in_script
- Example tcrandom band uses nkmin_forcing 2 and nkmax_forcing 5 in SKILL.md samples
Adoption & trust: 514 installs on skills.sh; 27.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need reproducible FluidSim runs but your agent keeps guessing forcing types and Fourier-space hooks instead of using the library’s parameter and override APIs.
Who is it for?
Indie builders and small teams wiring agent-driven CFD or turbulence experiments where forcing and ICs must be explicit in code.
Skip if: Builders who only need a one-off matplotlib plot or who are not running FluidSim-backed simulations in Python.
When should I use this skill?
When an agent must configure FluidSim forcing, custom Fourier forcing, or in-script initial conditions for a simulation run.
What do I get? / Deliverables
After the skill runs, the agent emits params and launch-script snippets with the right forcing mode, custom compute_forcing_fft overrides, and a clear sim.time_stepping.start() flow.
- Parameter blocks for params.forcing and related simulation settings
- Launch script snippets with optional compute_forcing_fft override and time_stepping.start()
Recommended Skills
Journey fit
Computational fluid dynamics setup is product/engineering work once you are building simulation-backed analysis or research tooling. Forcing, parameters, and launch scripts map to backend numerical code and simulation orchestration, not distribution or ops.
How it compares
Library-focused procedural reference for FluidSim, not a generic DevOps deploy skill or an MCP server wrapper.
Common Questions / FAQ
Who is fluidsim for?
Solo builders and scientific-agent authors who implement or automate FluidSim turbulence simulations in Python and need forcing and initialization details agents can follow literally.
When should I use fluidsim?
Use it in Build when configuring sustained turbulence (tcrandom/proportional forcing), injecting custom Fourier forcing in-script, or replacing default initial conditions before starting time stepping.
Is fluidsim safe to install?
Treat it like any third-party skill: review the Security Audits panel on this Prism page and inspect the repo before letting an agent execute generated simulation scripts on your machine.
SKILL.md
READMESKILL.md - Fluidsim
# Advanced Features ## Custom Forcing ### Forcing Types FluidSim supports several forcing mechanisms to maintain turbulence or drive specific dynamics. #### Time-Correlated Random Forcing Most common for sustained turbulence: ```python params.forcing.enable = True params.forcing.type = "tcrandom" params.forcing.nkmin_forcing = 2 # minimum forced wavenumber params.forcing.nkmax_forcing = 5 # maximum forced wavenumber params.forcing.forcing_rate = 1.0 # energy injection rate params.forcing.tcrandom_time_correlation = 1.0 # correlation time ``` #### Proportional Forcing Maintains a specific energy distribution: ```python params.forcing.type = "proportional" params.forcing.forcing_rate = 1.0 ``` #### Custom Forcing in Script Define forcing directly in the launch script: ```python params.forcing.enable = True params.forcing.type = "in_script" sim = Simul(params) # Define custom forcing function def compute_forcing_fft(sim): """Compute forcing in Fourier space""" forcing_vx_fft = sim.oper.create_arrayK(value=0.) forcing_vy_fft = sim.oper.create_arrayK(value=0.) # Add custom forcing logic # Example: force specific modes forcing_vx_fft[10, 10] = 1.0 + 0.5j return forcing_vx_fft, forcing_vy_fft # Override forcing method sim.forcing.forcing_maker.compute_forcing_fft = lambda: compute_forcing_fft(sim) # Run simulation sim.time_stepping.start() ``` ## Custom Initial Conditions ### In-Script Initialization Full control over initial fields: ```python from math import pi import numpy as np params = Simul.create_default_params() params.oper.nx = params.oper.ny = 256 params.oper.Lx = params.oper.Ly = 2 * pi params.init_fields.type = "in_script" sim = Simul(params) # Get coordinate arrays X, Y = sim.oper.get_XY_loc() # Define velocity fields vx = sim.state.state_phys.get_var("vx") vy = sim.state.state_phys.get_var("vy") # Taylor-Green vortex vx[:] = np.sin(X) * np.cos(Y) vy[:] = -np.cos(X) * np.sin(Y) # Initialize state in Fourier space sim.state.statephys_from_statespect() # Run simulation sim.time_stepping.start() ``` ### Layer Initialization (Stratified Flows) Set up density layers: ```python from fluidsim.solvers.ns2d.strat.solver import Simul params = Simul.create_default_params() params.N = 1.0 # stratification params.init_fields.type = "in_script" sim = Simul(params) # Define dense layer X, Y = sim.oper.get_XY_loc() b = sim.state.state_phys.get_var("b") # buoyancy field # Gaussian density anomaly x0, y0 = pi, pi sigma = 0.5 b[:] = np.exp(-((X - x0)**2 + (Y - y0)**2) / (2 * sigma**2)) sim.state.statephys_from_statespect() sim.time_stepping.start() ``` ## Parallel Computing with MPI ### Running MPI Simulations Install with MPI support: ```bash uv pip install "fluidsim[fft,mpi]" ``` Run with MPI: ```bash mpirun -np 8 python simulation_script.py ``` FluidSim automatically detects MPI and distributes computation. ### MPI-Specific Parameters ```python # No special parameters needed # FluidSim handles domain decomposition automatically # For very large 3D simulations params.oper.nx = 512 params.oper.ny = 512 params.oper.nz = 512 # Run with: mpirun -np 64 python script.py ``` ### Output with MPI Output files are written from rank 0 processor. Analysis scripts work identically for serial and MPI runs. ## Parametric Studies ### Running Multiple Simulations Script to generate and run multiple parameter combinations: ```python from fluidsim.solvers.ns2d.solver import Simul import numpy as np # Parameter ranges viscosities = [1e-3, 5e-4, 1e-4, 5e-5] resolutions = [128, 256, 512] for nu in viscosities: for nx in resolutions: params = Simul.create_default_params() # Configure simulation params.oper.nx = params.oper.ny = nx params.nu_2 = nu params.time_stepping.t_end = 10.0 # Unique output directory params.output.sub_directory = f"nu{nu}_nx{nx}" # Run simulation sim = Simul(params)