{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Comparing Leeway and ShipDrift model\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The Leeway model contain many object categories from persons-in-water\nto various types of boats and ships.\nHere we compare the Leeway model with a fishing vessel to\nthe ShipDrift model using the same ship dimensions.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nfrom opendrift.models.leeway import Leeway\nfrom opendrift.models.shipdrift import ShipDrift" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We use a simple case with constant wind northwards, and no current.\nWave height and period is calculated automatically from wind,\nand wave direction is the same as wind direction\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "environment = {\n 'land_binary_mask': 0,\n 'x_sea_water_velocity': 0,\n 'y_sea_water_velocity': 0,\n 'x_wind': 0,\n 'y_wind': 18}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For the Leeway model we use \"FISHING-VESSEL-3\" with a length of 62m\nFor the ShipDrift model we define a ship with the same dimensions,\nas well as a \"large ship\" scaled up by a factor of 8\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ship = {'length': 62, 'beam': 8, 'height': 10, 'draft': 5}\nlarge_ship = {k: v*8 for k, v in ship.items()}\n\ncases = {\n 'Leeway, FISHING-VESSEL-3': {\n 'model': Leeway, 'kwargs': {'object_type': 52}},\n 'Shipdrift, large ship': {\n 'model': ShipDrift, 'kwargs': large_ship},\n 'Shipdrift, small ship': {\n 'model': ShipDrift, 'kwargs': ship}\n }\n\nlon=3.5\nlat=60\ntime = datetime.now()\nduration = timedelta(hours=24)\nsimulations = []\nfor cname, case in cases.items():\n o = case['model'](loglevel=50)\n for var, value in environment.items():\n o.set_config('environment:constant:' + var, value)\n o.set_config('general:use_auto_landmask', False)\n o.seed_elements(lon=lon, lat=lat, time=time, number=1000,\n **case['kwargs'])\n o.run(duration=duration)\n simulations.append(o)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We see that the overall drift speed of the ShipDrift model\nis comparable to the Leeway model.\nHowever, the Leeway model yields a much larger directional\nspread for ships orienters left and right respectively.\nFor the scaled up ship, the drift speed is slightly larger,\nand the directional spread is slightly larger, but still\nmuch smaller than with the Leeway model.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulations[0].plot(compare=simulations[1:], legend=list(cases), fast=False)\nsimulations[0].animation(compare=simulations[1:], legend=list(cases), fast=False)" ] }, { "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 }