{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Oil film thickness\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from datetime import datetime, timedelta\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom opendrift.models.openoil import OpenOil\n\n\nnumber = 10000\ntimestep = timedelta(minutes=10)\ntimestep_output = timedelta(minutes=60)\nduration = timedelta(hours=20)\nmass_oil = 2000 # mass oil per particle\noil_type = 'GENERIC DIESEL'\n#oil_type = 'GENERIC BUNKER C'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First run, where surface oil thickness is updated\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o1 = OpenOil(loglevel=20, weathering_model='noaa')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Northwards wind, eastwards current\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o1.set_config('environment:fallback:land_binary_mask', 0)\no1.set_config('environment:fallback:x_wind', 0)\no1.set_config('environment:fallback:y_wind', 7)\no1.set_config('environment:fallback:sea_surface_wave_stokes_drift_x_velocity', 0)\no1.set_config('environment:fallback:sea_surface_wave_stokes_drift_y_velocity', .3)\no1.set_config('environment:fallback:x_sea_water_velocity', .1)\no1.set_config('environment:fallback:y_sea_water_velocity', 0)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Using Johansen droplet spectrum, which depends on oil film thickness\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o1.set_config('wave_entrainment:droplet_size_distribution',\n 'Johansen et al. (2015)')\no1.set_config('drift:wind_uncertainty', 2)\no1.set_config('drift:current_uncertainty', .1)\no1.set_config('processes:dispersion', False)\no1.set_config('processes:update_oilfilm_thickness', True)\n\no1.seed_elements(lon=4.5, lat=60, number=number,\n mass_oil=mass_oil, radius=1000,\n oil_type=oil_type,\n time=datetime.utcnow())\no1.run(time_step=timestep, time_step_output=timestep_output,\n duration=duration)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Animation shows how oil thickness evolves,\nand decreases due to evaporation and spreading\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"unitfactor=1e6 # show film thickness in micrometers\no1.animation(color='oil_film_thickness', fast=True,\n vmin=1e-7*unitfactor, vmax=1e-4*unitfactor,\n unitfactor=unitfactor, surface_only=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Second run, identical but without updating surface oil thickness\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o2 = OpenOil(loglevel=20, weathering_model='noaa')\no2.set_config('environment:fallback:land_binary_mask', 0)\no2.set_config('environment:fallback:x_wind', 0)\no2.set_config('environment:fallback:y_wind', 7)\no2.set_config('environment:fallback:sea_surface_wave_stokes_drift_x_velocity', 0)\no2.set_config('environment:fallback:sea_surface_wave_stokes_drift_y_velocity', .3)\no2.set_config('environment:fallback:x_sea_water_velocity', .1)\no2.set_config('environment:fallback:y_sea_water_velocity', 0)\n\no2.set_config('wave_entrainment:droplet_size_distribution',\n 'Johansen et al. (2015)')\no2.set_config('drift:wind_uncertainty', 2)\no2.set_config('drift:current_uncertainty', .1)\no2.set_config('processes:dispersion', False)\no2.set_config('processes:update_oilfilm_thickness', False)\n\no2.seed_elements(lon=4.5, lat=60, number=number,\n mass_oil=mass_oil, radius=1000,\n oil_type=oil_type,\n time=datetime.utcnow())\no2.run(time_step=timestep, time_step_output=timestep_output,\n duration=duration)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Comparison plots\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o1.plot_oil_budget()\no2.plot_oil_budget()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Entrainment\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"b1 = o1.get_oil_budget()\nb2 = o2.get_oil_budget()\nplt.plot(b1['mass_surface'], '-r', linewidth=2,\n label='Surface, updated thickness')\nplt.plot(b1['mass_submerged'], '--r', linewidth=2,\n label='Submerged, updated thickness')\nplt.plot(b1['mass_evaporated'], '-.r', linewidth=2,\n label='Evaporated, updated thickness')\nplt.plot(b2['mass_surface'], '-b', linewidth=2,\n label='Surface, constant thickness')\nplt.plot(b2['mass_submerged'], '--b', linewidth=2,\n label='Submerged, constant thickness')\nplt.plot(b2['mass_evaporated'], '-.b', linewidth=2,\n label='Evaporated, constant thickness')\nplt.legend()\nplt.xlabel('Time step')\nplt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that with the updated film thickness,\nthe droplets are getting gradually smaller\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"r1 = o1.get_property('diameter')[0]\nr2 = o2.get_property('diameter')[0]\nplt.plot(np.median(r1*1e6, 1))\nplt.plot(np.median(r2*1e6, 1))\nplt.legend(['With updated film thickness', 'With constant film thickness'])\nplt.xlabel('Time step')\nplt.ylabel('Median droplet diameter [micrometer]')\nplt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We see that oil film thickness has virtually no impact on horizontal drift\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o1.animation(compare=o2, fast=True,\n legend=['Updated film thickness',\n 'Constant/default film thickness'])"
]
},
{
"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
}