{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Double gyre - LCS with particles\n\nDrift of particles in an idealised (analytical) eddy current field,\nplotted on top of the LCS. This takes some minutes to calculate.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport matplotlib.pyplot as plt\n\nfrom opendrift.readers import reader_double_gyre\nfrom opendrift.models.oceandrift import OceanDrift" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Setting some parameters\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "duration = timedelta(seconds=12) # T\ntime_step=timedelta(seconds=.5)\ntime_step_output=timedelta(seconds=.5)\ndelta=.02 # spatial resolution\nsteps = int(duration.total_seconds()/\n time_step_output.total_seconds() + 1)\n\no = OceanDrift(loglevel=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that Runge-Kutta here makes a difference to Euler scheme\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.set_config('drift:advection_scheme', 'runge-kutta4')\no.disable_vertical_motion()\no.set_config('environment:fallback:land_binary_mask', 0)\n\ndouble_gyre = reader_double_gyre.Reader(epsilon=.25, omega=0.628, A=0.1)\nprint(double_gyre)\no.add_reader(double_gyre)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Calculate Lyapunov exponents\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "times = [double_gyre.initial_time +\n n*time_step_output for n in range(steps)]\nlcs = o.calculate_ftle(time=times, time_step=time_step,\n duration=duration, delta=delta, RLCS=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Make run with particles for the same period\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o = o.clone()\no.disable_vertical_motion()\nx = [.9]\ny = [.5]\nlon, lat = double_gyre.xy2lonlat(x, y)\n\no.seed_elements(lon, lat, radius=.15, number=2000,\n time=double_gyre.initial_time)\no.run(duration=duration, time_step=time_step,\n time_step_output=time_step_output)\no.animation(buffer=0, lcs=lcs, hide_landmask=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.6" } }, "nbformat": 4, "nbformat_minor": 0 }