Run Your First Simulation

Step-by-step guide to run your first SWASH simulation on Inductiva.AI. Easily launch, monitor and analyse results.

This tutorial will show you how to run SWASH simulations using the Inductiva API.

We will cover the Berkhoff shoal use case from the official SWASH documentation, to help you get started with simulations.

Prerequisites

Download the SWASH test case collection here. You'll find the input file needed to run this use case in the l41berkh folder. Then, you'll be ready to send your simulation to the Cloud!

Running a SWASH Simulation

Here is the code required to run a SWASH simulation using the Inductiva API:

"""SWASH example."""
import inductiva

# Allocate cloud machine on Google Cloud Platform
cloud_machine = inductiva.resources.MachineGroup( \
    provider="GCP",
    machine_type="c2d-highcpu-4",
    spot=True)

# Initialize the Simulator
swash = inductiva.simulators.SWASH(\
    version="11.01")

# Run simulation
task = swash.run(input_dir="/Path/to/l41berkh",
    sim_config_filename="l41ber01.sws",
    on=cloud_machine)

# Wait for the simulation to finish and download the results
task.wait()
cloud_machine.terminate()

task.download_outputs()

task.print_summary()

In this basic example, we're using a cloud machine (c2d-highcpu-4) equipped with 4 virtual CPUs. For larger or more compute-intensive simulations, consider adjusting the machine_type parameter to select a machine with more virtual CPUs and increased memory capacity. You can explore the full range of available machines here.

Note: Setting spot=True enables the use of spot machines, which are available at substantial discounts. However, your simulation may be interrupted if the cloud provider reclaims the machine.

To adapt the code for this or any other use case, simply replace input_dir with the path to your SWASH input files and set the sim_config_filename accordingly. Be sure to specify the SWASH version compatible with your input files.

When the simulation is complete, we terminate the machine, download the results and print a summary of the simulation as shown below.

Task status: Success

Timeline:
    Waiting for Input         at 21/04, 19:43:50      0.941 s
    In Queue                  at 21/04, 19:43:51      35.635 s
    Preparing to Compute      at 21/04, 19:44:27      2.26 s
    In Progress               at 21/04, 19:44:29      140.425 s
        ├> 1.063 s         dd if=/dev/stdin of=machinefile
        └> 139.205 s       swashrun -input l41ber01.sws -mpi 4
    Finalizing                at 21/04, 19:46:49      1.665 s
    Success                   at 21/04, 19:46:51

Data:
    Size of zipped output:    35.41 MB
    Size of unzipped output:  110.91 MB
    Number of output files:   19

Total estimated cost (US$): 0.0113 US$
    Estimated computation cost (US$): 0.0013 US$
    Task orchestration fee (US$): 0.010 US$

Note: A per-run orchestration fee (0.010 US$) applies to tasks run from 01 Dec 2025, in addition to the computation costs.
Learn more about costs at: https://inductiva.ai/guides/basics/how-much-does-it-cost

As you can see in the "In Progress" line, the part of the timeline that represents the actual execution of the simulation, the core computation time of this simulation was 140.4 seconds (approximately 2 minutes and 20 seconds).