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
12:50:31 INFO    opendrift.models.basemodel:515: OpenDriftSimulation initialised (version 1.11.13 / v1.11.13-99-gd2132d3)

Disable any 3D motion

o.disable_vertical_motion()
12:50:31 INFO    opendrift.models.oceandrift:377: Setting config: drift:vertical_advection -> False
12:50:31 INFO    opendrift.models.oceandrift:377: 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)
12:50:31 INFO    opendrift.models.basemodel.environment:218: Adding a dynamical landmask with max. priority based on assumed maximum speed of 2.0 m/s. Adding a customised landmask may be faster...
12:50:35 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
12:50:35 INFO    opendrift.models.basemodel.environment:248:    x_sea_water_velocity: 0.100000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    y_sea_water_velocity: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_height: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    x_wind: 7.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    y_wind: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    upward_sea_water_velocity: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    ocean_vertical_diffusivity: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 2.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.200000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_period_at_variance_spectral_density_maximum: 8.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_to_direction: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_peak_period_from_variance_spectral_density: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_significant_height: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_to_direction: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_mean_period: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_significant_height: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    surface_downward_x_stress: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    surface_downward_y_stress: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    turbulent_kinetic_energy: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    turbulent_generic_length_scale: 0.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    ocean_mixed_layer_thickness: 50.000000
12:50:35 INFO    opendrift.models.basemodel.environment:248:    sea_floor_depth_below_sea_level: 10000.000000

Running model for 6 hours

o.run(duration=timedelta(hours=6), time_step=600)
12:50:36 INFO    opendrift.models.basemodel:936: Using existing reader for land_binary_mask
12:50:36 INFO    opendrift.models.basemodel:947: All points are in ocean
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 12:50:31.219782 - step 1 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:00:31.219782 - step 2 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:10:31.219782 - step 3 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:20:31.219782 - step 4 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:30:31.219782 - step 5 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:40:31.219782 - step 6 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:50:31.219782 - step 7 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:00:31.219782 - step 8 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:10:31.219782 - step 9 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:20:31.219782 - step 10 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:30:31.219782 - step 11 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:40:31.219782 - step 12 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:50:31.219782 - step 13 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:00:31.219782 - step 14 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:10:31.219782 - step 15 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:20:31.219782 - step 16 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:30:31.219782 - step 17 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:40:31.219782 - step 18 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:50:31.219782 - step 19 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:00:31.219782 - step 20 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:10:31.219782 - step 21 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:20:31.219782 - step 22 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:30:31.219782 - step 23 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:40:31.219782 - step 24 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:50:31.219782 - step 25 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:00:31.219782 - step 26 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:10:31.219782 - step 27 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:20:31.219782 - step 28 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:30:31.219782 - step 29 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:40:31.219782 - step 30 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:50:31.219782 - step 31 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:00:31.219782 - step 32 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:10:31.219782 - step 33 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:20:31.219782 - step 34 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:30:31.219782 - step 35 of 36 - 50 active elements (0 deactivated)
12:50:36 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:40:31.219782 - 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()
/root/project/opendrift/models/basemodel/__init__.py:3156: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  points = ax.scatter([], [],
12:50:36 INFO    opendrift.models.basemodel:4613: Saving animation to /root/project/docs/source/gallery/animations/example_2d_0.gif...
12:50:40 INFO    opendrift.models.basemodel:3251: Time to make animation: 0:00:03.636295
../_images/example_2d_0.gif

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

Gallery generated by Sphinx-Gallery