Using FRIDOM Models

Contents

Using FRIDOM Models#

This chapter provides a comprehensive guide on how to work with FRIDOM and utilize its built-in models. We will introduce the foundational concepts step by step. By the end of this chapter, you will be equipped to:

  • Visualize and plot field variables,

  • Create custom initial conditions and forcings,

  • Save model outputs as netCDF files,

  • Generate animations,

  • Submit simulations to a computing cluster with automated restarts.

Throughout this chapter, we primarily use the 2D shallow water model as our example, as its 2D data is easier to visualize compared to 3D data. However, most of the concepts covered can be seamlessly applied to other models. To illustrate this, we will set up a basic simulation using both the 2D shallow water model and the 3D nonhydrostatic model. While the specific code details will be further explored in subsequent tutorials, our focus here is to showcase the similarities in setup between the two models.

import fridom.shallowwater as sw

# Create the grid and model settings
grid = sw.grid.cartesian.Grid(N=(256,256), L=(1,1), periodic_bounds=(True, True))
mset = sw.ModelSettings(grid=grid, f0=1, csqr=1)
mset.time_stepper.dt = 0.7e-3
mset.setup()

# Create the initial condition
z = sw.initial_conditions.Jet(mset, width=0.1, wavenum=2, waveamp=0.05)

# Create the model and run it
model = sw.Model(mset)
model.z = z  # set the initial condition
model.run(runlen=2.5)

# Plot the final total energy (kinetic + potential)
model.z.etot.xr.plot(cmap="RdBu_r")
import fridom.nonhydro as nh

# Create the grid and model settings
grid = nh.grid.cartesian.Grid(N=(256,256,16), L=(1,1,1), periodic_bounds=(True, True, False))
mset = nh.ModelSettings(grid=grid, f0=1, N2=1, Ro=0.5)
mset.time_stepper.dt = 1e-3
mset.setup()

# Create the initial condition
z = nh.initial_conditions.BarotropicJet(mset, wavenum=2, jet_width=0.01)

# Create the model and run it
model = nh.Model(mset)
model.z = z  # set the initial condition
model.run(runlen=2.5)

# Plot the final total energy (kinetic + potential)
model.z.etot.xrs[:,:,0].plot(cmap="RdBu_r")

Tutorials#

1. The Grid and the Model Settings

Learn how to create a grid and set up the model settings.

The Grid and the Model Settings
2. Scalar Fields and Plotting

Learn how to work with scalar fields and how to plot them.

Scalar Fields and Plotting
3. The State Vector and Initial Conditions

Learn how to work with the state vector and how to create custom initial conditions.

The State Vector and Initial Conditions
4. Running the Model

Learn how to run the model.

Running the Model
5. Modules Part 1: Understanding Modules

Learn what FRIDOM modules are and how to use them to add custom components as for example friction or forcing.

Modules Part 1: Understanding Modules
6. Saving Model Output

Learn how to save model output as netCDF files.

Saving model output
7. Modules Part 2: Creating Custom Modules

Learn how to create custom modules to add new functionality to models.

Modules Part 2: Creating Custom Modules
8. Generating Animations

Learn how to generate animations of the model outputs.

Generating animations
9. Time-stepping Schemes

Learn how to choose and modify time-stepping schemes.

Time-stepping schemes
10. Submitting Simulations to a Computing Cluster

Learn how to submit simulations to a computing cluster with automated restarts.

Submitting Simulations to a Computing Cluster
11. Parallelizing Simulations

Learn how to parallelize simulations to run them faster (future feature).

Parallelizing simulations