2D simulation profile

from datetime import datetime, timedelta
import numpy as np
from opendrift.models.oceandrift import OceanDrift

o = OceanDrift(loglevel=20)  # Set loglevel to 0 for debug information

Out:

13:43:51 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)

Disable any 3D motion

o.disable_vertical_motion()

Out:

13:43:51 INFO    opendrift.models.oceandrift: Setting config: drift:vertical_advection -> False
13:43:51 INFO    opendrift.models.oceandrift: Setting config: drift:vertical_mixing -> False

Define some constant current, wind and Stokes drift

o.set_config('environment:fallback:x_wind', 7)
o.set_config('environment:fallback:x_sea_water_velocity', .1)
o.set_config('environment:fallback:sea_surface_wave_stokes_drift_x_velocity', .2)
o.set_config('environment:fallback:sea_surface_wave_significant_height', 2)
o.set_config('environment:fallback:sea_surface_wave_period_at_variance_spectral_density_maximum', 8)

Seed elements between surface and 5m depth

time = datetime.utcnow()
z = -np.linspace(0, 5, 50)
o.seed_elements(lon=4.5, lat=60.0, z=z, radius=0, number=len(z), time=time)

Running model for 6 hours

o.run(duration=timedelta(hours=6), time_step=600)

Out:

13:43:51 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:43:51 INFO    opendrift.models.basemodel:    x_sea_water_velocity: 0.100000
13:43:51 INFO    opendrift.models.basemodel:    y_sea_water_velocity: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    x_wind: 7.000000
13:43:51 INFO    opendrift.models.basemodel:    y_wind: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    upward_sea_water_velocity: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    ocean_vertical_diffusivity: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 2.000000
13:43:51 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.200000
13:43:51 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    sea_surface_wave_period_at_variance_spectral_density_maximum: 8.000000
13:43:51 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    surface_downward_x_stress: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    surface_downward_y_stress: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    turbulent_kinetic_energy: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    turbulent_generic_length_scale: 0.000000
13:43:51 INFO    opendrift.models.basemodel:    sea_floor_depth_below_sea_level: 10000.000000
13:43:51 INFO    opendrift.models.basemodel: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1 m/s. Adding a customised landmask may be faster...
13:43:51 INFO    opendrift_landmask_data.mask: locking landmask for generation..
13:43:51 INFO    opendrift_landmask_data.mask: decompressing memmap landmask to /tmp/landmask/mask.dat..
13:44:04 INFO    opendrift_landmask_data.mask: landmask generated
13:44:08 INFO    opendrift.models.basemodel: Using existing reader for land_binary_mask
13:44:08 INFO    opendrift.models.basemodel: All points are in ocean
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 13:43:51.314722 - step 1 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 13:53:51.314722 - step 2 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 14:03:51.314722 - step 3 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 14:13:51.314722 - step 4 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 14:23:51.314722 - step 5 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 14:33:51.314722 - step 6 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 14:43:51.314722 - step 7 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 14:53:51.314722 - step 8 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 15:03:51.314722 - step 9 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 15:13:51.314722 - step 10 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 15:23:51.314722 - step 11 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 15:33:51.314722 - step 12 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 15:43:51.314722 - step 13 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 15:53:51.314722 - step 14 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 16:03:51.314722 - step 15 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 16:13:51.314722 - step 16 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 16:23:51.314722 - step 17 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 16:33:51.314722 - step 18 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 16:43:51.314722 - step 19 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 16:53:51.314722 - step 20 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 17:03:51.314722 - step 21 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 17:13:51.314722 - step 22 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 17:23:51.314722 - step 23 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 17:33:51.314722 - step 24 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 17:43:51.314722 - step 25 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 17:53:51.314722 - step 26 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 18:03:51.314722 - step 27 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 18:13:51.314722 - step 28 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 18:23:51.314722 - step 29 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 18:33:51.314722 - step 30 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 18:43:51.314722 - step 31 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 18:53:51.314722 - step 32 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 19:03:51.314722 - step 33 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 19:13:51.314722 - step 34 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 19:23:51.314722 - step 35 of 36 - 50 active elements (0 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2021-09-24 19:33:51.314722 - step 36 of 36 - 50 active elements (0 deactivated)

To check that z is really kept constant for all particles

o.plot_property('z')
z

Vertical profile of advection. Note the decaying importance of Stokes drift, and the additional windage of the element at surface

o.animation_profile()

Out:

13:44:09 INFO    opendrift.models.basemodel: Saving animation to /root/project/docs/source/gallery/animations/example_2d_0.gif...
13:44:09 INFO    opendrift.models.basemodel: Making animated gif...
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_2d_0.gif

Total running time of the script: ( 0 minutes 21.126 seconds)

Gallery generated by Sphinx-Gallery