.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_vertical_mixing.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_vertical_mixing.py: Vertical mixing =============== .. GENERATED FROM PYTHON SOURCE LINES 6-11 .. code-block:: Python import numpy as np from datetime import datetime, timedelta from opendrift.models.oceandrift import OceanDrift .. GENERATED FROM PYTHON SOURCE LINES 12-13 Configuration. Edit this section to see the differences. .. GENERATED FROM PYTHON SOURCE LINES 13-29 .. code-block:: Python N = 10000 # Number of particles seed_depth = -10 # meters hours = 2 # Number of hours to mix particles sea_floor_depth = 100 # m timestep_seconds = 60 # Timestep for vertical mixing terminal_velocity = 0 # Neutral particles #terminal_velocity = 0.005 # Rising particles #terminal_velocity = -0.005 # Sinking particles # Profile of diffusivities z = np.arange(0, -40, -1) diffusivity = np.ones(z.shape)*.01 # Constant diffusivity diffusivity[z<-20] = 0.001 # uncomment to reduce mixing below 20m .. GENERATED FROM PYTHON SOURCE LINES 30-31 Preparing mixing timestep .. GENERATED FROM PYTHON SOURCE LINES 31-50 .. code-block:: Python time = datetime(2020, 1, 1, 0) o = OceanDrift(loglevel=20) o.set_config('drift:vertical_mixing', True) o.set_config('vertical_mixing:diffusivitymodel', 'environment') o.set_config('vertical_mixing:timestep', timestep_seconds) o.set_config('environment:fallback:land_binary_mask', 0) o.seed_elements(lon=4, lat=60, z=seed_depth, time=time, number=N, terminal_velocity=terminal_velocity) o.time = time o.time_step = timedelta(hours=hours) o.release_elements() o.environment = np.array(list(zip(np.ones(N)*sea_floor_depth, np.zeros(N))), dtype=[('sea_floor_depth_below_sea_level', np.float32), ('sea_surface_height', np.float32)]).view(np.recarray) o.environment.ocean_mixed_layer_thickness = np.ones(N)*50 o.environment_profiles = { 'z': z, 'ocean_vertical_diffusivity': np.tile(diffusivity, (N, 1)).T} .. rst-class:: sphx-glr-script-out .. code-block:: none 17:14:12 INFO opendrift:513: OpenDriftSimulation initialised (version 1.14.2 / v1.14.2-88-gf09b7bd) 17:14:12 INFO opendrift.models.basemodel.environment:206: Adding a global landmask from GSHHG 17:14:16 INFO opendrift.models.basemodel.environment:229: Fallback values will be used for the following variables which have no readers: 17:14:16 INFO opendrift.models.basemodel.environment:232: x_sea_water_velocity: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: y_sea_water_velocity: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: sea_surface_height: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: x_wind: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: y_wind: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: upward_sea_water_velocity: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: ocean_vertical_diffusivity: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_significant_height: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_x_velocity: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_y_velocity: 0.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: ocean_mixed_layer_thickness: 50.000000 17:14:16 INFO opendrift.models.basemodel.environment:232: sea_floor_depth_below_sea_level: 10000.000000 .. GENERATED FROM PYTHON SOURCE LINES 51-52 Calculate vertical mixing, and return particle depths at all positions .. GENERATED FROM PYTHON SOURCE LINES 52-58 .. code-block:: Python print('Calculating...') depths = o.vertical_mixing(store_depths=True) print('Making animation...') o.animate_vertical_distribution(depths=depths) .. rst-class:: sphx-glr-script-out .. code-block:: none Calculating... Making animation... 17:14:17 INFO opendrift:4553: Saving animation to /root/project/docs/source/gallery/animations/example_vertical_mixing_0.gif... 17:14:38 INFO opendrift.models.oceandrift:633: Time to make animation: 0:00:21.678440 .. GENERATED FROM PYTHON SOURCE LINES 59-60 .. image:: /gallery/animations/example_vertical_mixing_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 31.324 seconds) .. _sphx_glr_download_gallery_example_vertical_mixing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_vertical_mixing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_vertical_mixing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_vertical_mixing.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_