# opendrift.models.eulerdrift.simulation

## Module Contents

### Classes

 Simulation The simulation. ExplSimulation A simple explicit scheme for integrating the convection-equation.

### Attributes

opendrift.models.eulerdrift.simulation.logger
class opendrift.models.eulerdrift.simulation.Simulation(grid)[source]

The simulation.

It contains the problem to be simulated, means to read necessary input variables, and the physics for modeling the convection of the initial conditions.

Convection:

Convection consists of advection and diffusion.

Diffusion is given by:

$\frac{\partial U}{\partial t} = D \left( \frac{\partial^2 U}{\partial x^2} + \frac{\partial^2 U}{\partial y^2} \right)$

The convection equation is (wiki):

$\frac{\partial c}{\partial t} = ...$

with the assumptions that:

• the diffusion constant D is constant for the field,

• and that the flow u is incompressible (i.e. has no divergence).

the equation simplifies to:

$\frac{\partial c}{\partial t} = D \nabla^2 c - \mathbf{v} \cdot \nabla T$

where $$\nabla^2 = \triangle$$ is the Laplacian.

grid

Reference time datetime.Datetime

t0

Current time offset after t0

t = 0.0

Diffusivity ($$m^2/s$$). E.g. between 0.01 and 0.1 for oil on the surface of the ocean (Matsuzakia et. al., 2017).

Decreasing diffusivity places stricter stability criteria on time step.

D = 0.1

Porosity, rate of liquid volume to total volume (fraction of flux)

rho = 1.0

classmethod new(lon0=10.0, lat0=65.0, res=10.0, shape=(100, 100))[source]

New simulation on a grid.RegularGrid.

Args:

lon0: lower-left corner longitude

lat0: lower-left corner latitude

res: resolution (dx and dy)

shape: shape (size) of grid

source(lon, lat, X)[source]

Source X onto grid with lower-left corner lon, lat.

source_gaussian_blob(lon, lat, A=1.0, N=10, sigma=10.0)[source]

Source a Gaussian blob (2D normal distribution) at lon and lat with sigma (standard deviation, meters) radius.

Args:

lon, lat: Center coordinates, or $$\bar \mu$$.

A: Amplitude.

N: Kernel size.

sigma: standard deviation ($$\sigma$$) in meters.

U(t)[source]

Get U (ocean current) for t0 + t

abstract step(dt=None)[source]

Step the simulation.

Stepping the simulation involves applying diffusion and advection to the field.

Args:

dt: time delta (or use automatic).

abstract integrate(dt=None, max_t=None, max_steps=None, observer=None)[source]

Run simulation until termination condition is met.

Args:

dt: override time step

observer: function to call after each step taking simulation object as first argument. the function may return False to stop the integration.

Termination conditions:

max_t: max time max_steps: max iterations

class opendrift.models.eulerdrift.simulation.ExplSimulation(grid)[source]

Bases: Simulation

A simple explicit scheme for integrating the convection-equation.

• Forward difference in time

• ndimage.laplace and np.gradient for spatial differences.

https://en.wikipedia.org/wiki/Numerical_solution_of_the_convection%E2%80%93diffusion_equation#Solving_the_convection%E2%80%93diffusion_equation_using_the_finite_difference_method

stability(dx, D, umax)[source]

https://en.wikipedia.org/wiki/Numerical_solution_of_the_convection%E2%80%93diffusion_equation#Solving_the_convection%E2%80%93diffusion_equation_using_the_finite_difference_method

step(dt=None)[source]

Step the simulation.

Stepping the simulation involves applying diffusion and advection to the field.

Args:

dt: time delta (or use automatic).