Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Step 6 -- 2D Nonlinear Convection

Authors
Affiliations
University of Valencia

We now replace the constant advection velocity with the solution itself, giving the 2D nonlinear convection (inviscid Burgers) system:

∂u∂t+u∂u∂x+v∂u∂y=0\frac{\partial u}{\partial t} + u \frac{\partial u}{\partial x} + v \frac{\partial u}{\partial y} = 0
∂v∂t+u∂v∂x+v∂v∂y=0\frac{\partial v}{\partial t} + u \frac{\partial v}{\partial x} + v \frac{\partial v}{\partial y} = 0

What you will learn:

  1. How nonlinear self-advection produces wave steepening in 2D

  2. Working with two-component state vectors (u,v)(u, v)

  3. How the solution differs from the linear case

Physics

In the linear case (Step 5) the wave translates at constant speed without changing shape. Here the local propagation speed is the solution: regions of higher amplitude travel faster, causing the wave front to steepen. Without viscosity, this eventually leads to a shock (gradient blow-up). In practice we run for a short time to observe the steepening before any numerical instability.

Grid layout and boundary conditions

In 2D, somax uses the Arakawa C-grid where different variables live at different positions within each cell:

       V_{j+1/2}
    ┌─────●─────┐
    │           │
 U  ●     T     ●  U
i-1/2   (i,j)    i+1/2
    │           │
    └─────●─────┘
       V_{j-1/2}
  • T-points (cell centres): scalars (uu, pp, ω\omega)

  • U-points (east/west faces): x-fluxes

  • V-points (north/south faces): y-fluxes

  • X-points (corners): vorticity (in some formulations)

The full array has shape (Ny, Nx) with a 1-cell ghost ring on all sides:

 ┌───────────────────────────────────┐
 │  ghost  ghost  ghost  ghost  ghost│  ← row 0
 │  ghost  T(1,1) T(1,2) ···   ghost│  ← row 1
 │  ghost  T(2,1) T(2,2) ···   ghost│
 │   ⋮      ⋮      ⋮           ⋮    │
 │  ghost  T(n,1) T(n,2) ···   ghost│  ← row Ny-2
 │  ghost  ghost  ghost  ghost  ghost│  ← row Ny-1
 └───────────────────────────────────┘
        col 0  col 1  ···  col Nx-1

Interior cells are [1:-1, 1:-1]. Ghost cells are filled by boundary conditions before each RHS evaluation.

Periodic BCs (enforce_periodic) copy the last interior row/column to the opposite ghost row/column. Both u and v fields receive the same periodic treatment:

 field[0, :]  = field[-2, :]   (south ghost ← north interior)
 field[-1, :] = field[1, :]    (north ghost ← south interior)
 field[:, 0]  = field[:, -2]   (west ghost ← east interior)
 field[:, -1] = field[:, 1]    (east ghost ← west interior)

1. Create the model

NonlinearConvection2D(
  grid=ArakawaCGrid2D(Nx=66, Ny=66, Lx=2.0, Ly=2.0, dx=0.03125, dy=0.03125),
  advection=Advection2D(
    grid=ArakawaCGrid2D(Nx=66, Ny=66, Lx=2.0, Ly=2.0, dx=0.03125, dy=0.03125),
    recon=Reconstruction2D(
      grid=ArakawaCGrid2D(Nx=66, Ny=66, Lx=2.0, Ly=2.0, dx=0.03125, dy=0.03125)
    )
  ),
  interp=Interpolation2D(
    grid=ArakawaCGrid2D(Nx=66, Ny=66, Lx=2.0, Ly=2.0, dx=0.03125, dy=0.03125)
  )
)
Grid: Nx=66, Ny=66
Spacing: dx=0.0312, dy=0.0312

2. Initial condition

A 2D Gaussian for both velocity components, centred at (1.0,1.0)(1.0, 1.0).

State shapes: u=(66, 66), v=(66, 66)

3. Run the simulation

Solution shapes: u=(150, 66, 66), v=(150, 66, 66)

4. Visualize steepening

Compare the initial and final uu and vv fields. The Gaussian should steepen on one side as faster-moving peaks overtake slower regions.

<Figure size 1200x1000 with 8 Axes>

5. Cross-sections through the steepening front

Taking a 1D slice through the middle row makes the steepening easier to see.

<Figure size 1200x400 with 2 Axes>

6. Compare with linear convection

In the linear case (Step 5) the peak amplitude is preserved. Here self-advection redistributes energy and the peak drops as the front steepens.

<Figure size 800x400 with 1 Axes>

7. Energy evolution

Total kinetic energy E=12∑(u2+v2) dx dyE = \tfrac{1}{2}\sum(u^2 + v^2)\,dx\,dy should not increase for this inviscid system (numerical dissipation may cause a slight decrease).

<Figure size 800x300 with 1 Axes>
Energy: initial = 0.125664, final = 0.105718

8. Gradient through the initial state

Even without explicit parameters, we can differentiate through the nonlinear dynamics with respect to the initial condition.

<Figure size 1200x500 with 4 Axes>

Summary

ConceptAPI
Create modelNonlinearConvection2D.create(nx=64, ny=64)
Two-component stateNonlinearConvection2DState(u=u0, v=v0)
Self-advectionvelocity = solution itself
Observable effectwave steepening, peak decay

Next: Step 7 adds diffusion in 2D, which counteracts steepening and has an analytical Gaussian solution we can validate against.