{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Euler simulation / Finite differnce of Gaussian blob\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nfrom opendrift.models import eulerdrift\n\neulerdrift.install_logs() #remove\n\ns = eulerdrift.ExplSimulation.new(shape = (200, 200))\ns.readers.append(\n eulerdrift.readers.ConstantReader.new_xy(5, 5))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set the diffusion, greater diffusion increases stability of simulation.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s.D = 10." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add a source field (Gaussian blob) at the center of the grid\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "loc, lac = s.grid.center()\ns.source_gaussian_blob(loc, lac, 1., 70, 20.)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot the initial conditions\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s.grid.plot()\nplt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Integrate\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s.integrate(dt = .01, max_steps = 5000)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot integrated field\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "s.grid.plot()\nplt.show()" ] } ], "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 }