Model Integration

A BarotropicModel is a representation of the barotropic PV equation and provides temporal integrators to advance the flow contained in State objects in time. The forcing and the numerical diffusion are configured with the BarotropicModel.

BarotropicModel

class barotropic.BarotropicModel(rhs=None, diffusion_order=2, diffusion_coeff=1000000000000000.0, diffusion_bg=None)

Bases: object

Integrate the barotropic PV equation on the sphere forward in time.

Parameters:
  • rhs (rhs.RHS) – Model forcing. Build from the components provided in rhs.

  • diffusion_order (int) – Order of diffusion term added for numerical stability to the PV equation. Hyperdiffusion by default.

  • diffusion_coeff (number) – Strength of diffusion.

  • diffusion_bg (array | None) – A background vorticity field that is removed before application of the diffusion steps.

Barotropic PV equation with forcing:

Dq/Dt = ∂q/∂t + ∇(u·q) = RHS,

where q is the barotropic potential vorticity (i.e. absolute vorticity) and u is the divergence-free horizontal wind (which can be obtained from the PV by inversion).

Does not carry state aside from the forcing and diffusion setup and can be reused for multiple integrations with different State instances (though note that when used with the diffusion_bg parameter or some RHS terms, the BarotropicModel can be restricted to a specific grid resolution).

Added in version 3.1: The diffusion_bg parameter.

euler(state_now, dt)

Step forward in time with a first-order Euler-forward scheme

Parameters:
  • state_now (State) – Initial state.

  • dt (number | timedelta) – Time step size.

Returns:

New State instance.

leapfrog(state_old, state_now, filter_parameter=0.2)

Step forward in time using a filtered leapfrog scheme.

Parameters:
  • state_old (State) – Last State.

  • state_now (State) – Current state.

  • filter_parameter (number) – Strength paramter of the Robert-Asselin filter.

Returns:

Tuple containing filtered current state and next step as new State instances.

The timestep size is determined automatically from the difference of the given input fields state_old and state_now.

run(state_init, dt, tend, save_every=0)

Run the model until a specified time is reached.

Parameters:
  • state_init (State) – State from which the integration starts.

  • dt (number | timedelta) – Time step size. Either a number in seconds or a timedelta.

  • tend (number | datetime) – Time after which the integration stops. The model will not try to reach this time exactly, but stop as soon as it is exeeded.

  • save_every (number) – If larger than zero, an intermediate state is saved and returned in the list of states every time this time interval is exceeded. Does not work for datetime/timedelta dt currently.

Returns:

Tuple containing the final state (State) and a list of all saved intermediate states (StateList).

Initializes with a first-order Euler forward step, then continues with second-order Leapfrog steps.