.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_oil_entrainment_rate.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_oil_entrainment_rate.py: Oil entrainment rate ==================== .. GENERATED FROM PYTHON SOURCE LINES 6-11 .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from opendrift.models.physics_methods import oil_wave_entrainment_rate_li2017 .. GENERATED FROM PYTHON SOURCE LINES 12-13 Viscosities from 0 to 20 Pa*s / kg/ms .. GENERATED FROM PYTHON SOURCE LINES 13-18 .. code-block:: Python vis = np.linspace(0, 20, 100) colors = ['b', 'g', 'r'] lstyles = ['-', '-.'] .. GENERATED FROM PYTHON SOURCE LINES 19-21 Calculating and plotting the entrainment rate as function of viscosity for 3 wind speeds .. GENERATED FROM PYTHON SOURCE LINES 21-48 .. code-block:: Python fig, ax = plt.subplots() for wind, color in zip([6, 10, 15], colors): # Entrainment rate from Li (2017) for ift, ls in zip([.003, 10], lstyles): r = oil_wave_entrainment_rate_li2017( dynamic_viscosity=vis, oil_density=950, interfacial_tension=ift, wind_speed=wind) # from instantaneous rate (s-1) we calculate the probability of entrainment within one hour: p1h = 1-np.exp(-3600*r) ax.plot(vis, p1h, color+ls, label='Li(2017), %s m/s wind, IFT: %s' % (wind, ift)) plt.legend() ax.set_xlim(vis.min(), vis.max()) ax.set_ylim(0, 1.05) # Make second x-axis showing viscosity in Centipoise ax2 = ax.twiny() x1, x2 = ax.get_xlim() ax2.set_xlim(1000*x1, 1000*x2) ax2.figure.canvas.draw() ax2.set_xlabel('Dynamic viscosity [Centipoise]') ax.set_ylabel('Fraction entrained in 1 hour') ax.set_xlabel('Dynamic viscosity [Pa*s] / [kg/ms]') plt.show() .. image-sg:: /gallery/images/sphx_glr_example_oil_entrainment_rate_001.png :alt: example oil entrainment rate :srcset: /gallery/images/sphx_glr_example_oil_entrainment_rate_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.320 seconds) .. _sphx_glr_download_gallery_example_oil_entrainment_rate.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_oil_entrainment_rate.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_oil_entrainment_rate.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_