{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "slideshow": { "slide_type": "skip" } }, "outputs": [ ], "source": [ "from itertools import product\n", "import numpy as np\n", "import plotly.graph_objects\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false, "slideshow": { "slide_type": "skip" } }, "outputs": [ ], "source": [ "mydefault = plotly.graph_objects.layout.Template()\n", "mydefault.layout.xaxis.showgrid = False\n", "mydefault.layout.yaxis.showgrid = False\n", "mydefault.layout.xaxis.showline = True\n", "mydefault.layout.yaxis.showline = True\n", "mydefault.layout.yaxis.linewidth = 2\n", "mydefault.layout.xaxis.ticks = \"outside\"\n", "mydefault.layout.yaxis.ticks = \"outside\"\n", "mydefault.layout.hovermode = False\n", "mydefault.layout.scene.hovermode = False\n", "mydefault.layout.xaxis.showspikes = False\n", "mydefault.layout.yaxis.showspikes = False\n", "mydefault.layout.scene.xaxis.showspikes = False\n", "mydefault.layout.scene.yaxis.showspikes = False\n", "mydefault.layout.scene.zaxis.showspikes = False\n", "plotly.io.templates[\"mydefault\"] = mydefault\n", "plotly.io.templates.default = \"mydefault\"\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false, "slideshow": { "slide_type": "slide" } }, "source": [ "**Learning goals:**\n", "\n", "- Know the four defining properties of chaos in a dynamical system. \n", "- Be able to explain what each one of them means. \n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false, "slideshow": { "slide_type": "subslide" } }, "source": [ "**Example:** The three-species food chain model (the Hastings model)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "slideshow": { "slide_type": "skip" } }, "outputs": [ ], "source": [ "state_vars = list(var(\"G, S, W\"))\n", "system = (\n", " G*(1 - G/3) - 2.5*G/(1 + G)*S, \n", " 2/3*2.5*G/(1 + G)*S - 0.4*S - 0.1*S/(1 + S)*W, \n", " 0.5*0.1*S/(1 + S)*W - 0.01*W, \n", ")\n", "vectorfield(G, S, W) = system\n", "delta_t = 0.1\n", "t_range = srange(0, 5000, delta_t)\n", "initial_state = (1, 1, 1)\n", "solution = desolve_odeint(vectorfield, initial_state, t_range, state_vars)\n", "solution = np.insert(solution, 0, t_range, axis=1)[int(2000/delta_t):]\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "slideshow": { "slide_type": "-" } }, "outputs": [ { "data": { "text/html": "\n
\n\n