SWAN (Simulating WAves Nearshore)

In this guide, we will walk you through setting up and running SWAN simulations using the Inductiva API.

We will cover:

  • Configuring SWAN simulations using the Inductiva API.

  • Example code to help you get started with simulations.

  • Available benchmarks to test SWAN’s capabilities.

SWAN (Simulating WAves Nearshore)#

SWAN is a simulator used to obtain realistic estimates of wave parameters in coastal areas, lakes, and estuaries based on wind, sea floor, and current conditions. SWAN is widely applied in coastal engineering, environmental assessments, and maritime safety studies.

The SWAN simulator is typically configured using a single .swn file, along with additional files that define the domain, sea floor, and input conditions. These files should be organized in an input directory, which will be passed to the simulator.

Example Code#

Below is an example of running a SWAN simulation via the Inductiva API:

"""SWAN 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.files.download_from_url(
    "https://storage.googleapis.com/inductiva-api-demo-files/"
    "swan-input-example.zip", True)

# Initialize the Simulator
swan = inductiva.simulators.SWAN()

# Run simulation with config files in the input directory
task = swan.run(input_dir=input_dir,
                sim_config_filename="a11refr.swn",
                on=machine_group)

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

machine_group.terminate()

For more detailed information on SWAN configuration, refer to the official documentation.

Available Benchmarks for SWAN#

The following benchmark is available to test SWAN:

  • Ring: This example simulates wave propagation and interaction in a circular domain, based on the official SWAN documentation.