In this guide, we will walk you through CaNS setup, one of the built-in simulators available via the Inductiva API.
We will cover:
Setting up CaNS for use with our API.
Example code to help you get started with simulations.
CaNS#
CaNS (Canonical Navier-Stokes) is a simulator designed for massively-parallel numerical simulations of fluid flows. CaNS specializes in simulating incompressible, Newtonian fluid flows and leverages a highly efficient FFT-based solver for the second-order finite-difference Poisson equation on a 3D Cartesian grid.
CaNS is currently running version 2.3.4 for CPU and is built using OpenMPI 4.1.2 and FFTW 3.3.8. A GPU version is planned for a future release to enhance performance.
Example Code#
"""CaNS example"""
import inductiva
# Instantiate machine group
machine_group = inductiva.resources.MachineGroup("c2-standard-4")
machine_group.start()
# Set simulation input directory
input_dir = inductiva.utils.download_from_url(
"https://storage.googleapis.com/inductiva-api-demo-files/"
"cans-input-example.zip",
unzip=True)
# Initialize the Simulator
cans = inductiva.simulators.CaNS()
# Run simulation with config files in the input directory
task = cans.run(input_dir=input_dir,
sim_config_filename="input.nml",
on=machine_group,
n_vcpus=4)
task.wait()
task.download_outputs()
machine_group.terminate()
Closing Notes: Make sure to include a designated ‘data’ folder in your input files to store simulation outputs.