Run a Delft3D-FM Simulation

This tutorial will show you how to run Delft3D-FM simulations using the Inductiva API.

We will work through Case1 from the ten Keswick Reservoir scenarios selected by the CA State Water Quality Control Board, available in the USGS ScienceBase Catalog.

Prerequisites

Download the required model.zip file from the link above. Once it’s downloaded, you’ll be ready to send your simulation to the cloud.

Running a Delft3D-FM Simulation

Here is the code required to run the Delft3D-FM simulation using the Inductiva API:

"""Delft3D-FM Simulation."""
import inductiva

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

# Initialize the Simulator
delft3d-fm = inductiva.simulators.Delft3DFM(\
    version="2024.03")

# Run simulation
task = delft3d-fm.run( \
    input_dir="/Path/to/model/Case1/Case1.dsproj_data/FlowFM/input",
    commands = ["dflowfm --partition:ndomains=16 FlowFM.mdu",
                "mpirun -np 16 dflowfm --autostartstop FlowFM.mdu"],
    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-16) equipped with 16 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 this script for your own simulations:

  • Replace the input_dir path with the location of your Delft3D-FM input files.
  • Adjust the commands to match your specific configuration.

⚠️ Important: If you change the number of virtual CPUs in the machine, make sure to update the corresponding value in the mpirun command (e.g., -np 16).

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 09/12, 11:06:44      1.151 s
    In Queue                  at 09/12, 11:06:45      39.1 s
    Preparing to Compute      at 09/12, 11:07:24      2.643 s
    In Progress               at 09/12, 11:07:27      10818.089 s
        ├> 2.094 s         dflowfm --partition:ndomains=16 FlowFM.mdu
        └> 10815.721 s     mpirun -np 16 dflowfm --autostartstop FlowFM.mdu
    Finalizing                at 09/12, 14:07:45      3.724 s
    Success                   at 09/12, 14:07:49      

Data:
    Size of zipped output:    407.82 MB
    Size of unzipped output:  774.30 MB
    Number of output files:   88

Total estimated cost (US$): 0.24 US$
    Estimated computation cost (US$): 0.23 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/how-it-works/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 approximately 3 hours.

Scale Up Your Simulation

Scaling up your simulation is as simple as updating the machine_type parameter to, for example, a 56 vCPU machine (c2d-highcpu-56).

By increasing the number of vCPUs, we've reduced the processing time from 3 hours to 1 hour and 45 minutes. The details are shown in the table below:

Machine TypevCPUsExecution TimeEstimated Cost (USD)
c2d-highcpu-16163h0.24
c2-highcpu-56561h, 45 min0.46