.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_double_gyre_advection_schemes.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_double_gyre_advection_schemes.py: Double gyre, advection ====================== Illustrating the difference between Euler and Runge-Kutta propagation schemes, using an idealised (analytical) eddy current field. Double gyre current field from https://shaddenlab.berkeley.edu/uploads/LCS-tutorial/examples.html .. GENERATED FROM PYTHON SOURCE LINES 12-42 .. image-sg:: /gallery/images/sphx_glr_example_double_gyre_advection_schemes_001.png :alt: OpenDrift - OceanDrift 2000-01-01 00:00 to 2000-01-01 00:00 UTC (601 steps) :srcset: /gallery/images/sphx_glr_example_double_gyre_advection_schemes_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none euler, T=0.01s euler, T=0.10s runge-kutta, T=0.01s runge-kutta, T=0.10s runge-kutta4, T=0.01s runge-kutta4, T=0.10s (,
) | .. code-block:: Python import numpy as np from datetime import datetime, timedelta from opendrift.readers import reader_double_gyre from opendrift.models.oceandrift import OceanDrift double_gyre = reader_double_gyre.Reader(epsilon=.25, omega=0.628, A=0.25) duration=timedelta(seconds=6) x = [.6] y = [.3] lon, lat = double_gyre.xy2lonlat(x, y) runs = [] leg = [] i = 0 for scheme in ['euler', 'runge-kutta', 'runge-kutta4']: for time_step in [0.01, 0.1]: leg.append(scheme + ', T=%.2fs' % time_step) print(leg[-1]) o = OceanDrift(loglevel=50) o.set_config('environment:fallback:land_binary_mask', 0) o.set_config('drift:advection_scheme', scheme) o.add_reader(double_gyre) o.seed_elements(lon, lat, time=double_gyre.initial_time) o.run(duration=duration, time_step=time_step) runs.append(o) i = i + 1 runs[0].plot(compare=runs[1:], legend=leg, buffer=0.000001, hide_landmask=True) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 35.426 seconds) .. _sphx_glr_download_gallery_example_double_gyre_advection_schemes.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_double_gyre_advection_schemes.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_double_gyre_advection_schemes.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_