{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# 2D simulation profile\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport numpy as np\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Disable any 3D motion\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.disable_vertical_motion()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Define some constant current, wind and Stokes drift\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.set_config('environment:fallback:x_wind', 7)\no.set_config('environment:fallback:x_sea_water_velocity', .1)\no.set_config('environment:fallback:sea_surface_wave_stokes_drift_x_velocity', .2)\no.set_config('environment:fallback:sea_surface_wave_significant_height', 2)\no.set_config('environment:fallback:sea_surface_wave_period_at_variance_spectral_density_maximum', 8)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seed elements between surface and 5m depth\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "time = datetime.utcnow()\nz = -np.linspace(0, 5, 50)\no.seed_elements(lon=4.5, lat=60.0, z=z, radius=0, number=len(z), time=time)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model for 6 hours\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(duration=timedelta(hours=6), time_step=600)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To check that z is really kept constant for all particles\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.plot_property('z')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Vertical profile of advection. Note the decaying importance of Stokes drift, and the additional windage of the element at surface\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.animation_profile()" ] }, { "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 }