Claudio Gomes 6 лет назад
Родитель
Сommit
8eb2259a9d

+ 1 - 1
README.md

@@ -14,7 +14,7 @@ The best way to run the examples is to use [Docker](https://www.docker.com/).
 1. Open your browser and navigate to `http://MACHINE_IP:8888/?token=TOKEN`
 1. Explore the examples.
 1. Go back to docker's console, and exit the running container by typing `Ctrl+C`. 
-1. List the running containers: `docker container ls` . If there are running containers, note their ID and stop them using: `docker stop CONTAINERID`
+1. List the running containers: `docker container ls` . If there are running containers, note their ID and stop them using: `docker stop CONTAINERID`. Alternatively, you can just stop all containers by running `docker stop $(docker ps -aq)`.
 
 
 

Разница между файлами не показана из-за своего большого размера
+ 61 - 13
examples/Example2_MassSpringDamper/.ipynb_checkpoints/Example2_MassSpringDamper-checkpoint.ipynb


+ 48 - 2
examples/Example2_MassSpringDamper/Example2_MassSpringDamper.ipynb

@@ -225,7 +225,7 @@
     "        x = x0\n",
     "        xs = [x]\n",
     "        for i in range(1, max_steps):\n",
-    "            x = x + f(x, t0 + h*(i-1))*h\n",
+    "            x = x + f(x)*h\n",
     "            xs.append(x)\n",
     "        return xs\n",
     "\n",
@@ -238,7 +238,7 @@
     "x0 = np.matrix([[1.0],[0.0]]) \n",
     "\n",
     "# Simulation\n",
-    "xs_e = Explicit_Euler().simulate(lambda x,t: A_num*x, x0, 0.0, h, num_steps)\n",
+    "xs_e = Explicit_Euler().simulate(lambda x: A_num*x, x0, 0.0, h, num_steps)\n",
     "\n",
     "# Plotting\n",
     "plt.figure(1)\n",
@@ -318,6 +318,52 @@
     "\n",
     "plt.show()"
    ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Exercise: Implement the Midpoint Method"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "Adapt the midpoint method introduced in the Example1_CruiseController notebook to work with the mass spring damper vector IVP."
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "class Midpoint:\n",
+    "    def simulate(self, f, x0, t0, h, max_steps):\n",
+    "        x = x0\n",
+    "        xs = [x]\n",
+    "        for i in range(1, max_steps):\n",
+    "            # TODO: implement the following \n",
+    "            x = ...\n",
+    "            xs.append(x)\n",
+    "        return xs\n",
+    "\n",
+    "# Run solver and plot\n",
+    "xs_mid = Midpoint().simulate(lambda x: A_num*x, x0, 0.0, h, num_steps)\n",
+    "\n",
+    "# Plotting\n",
+    "plt.figure(1)\n",
+    "plt.plot(t_range,[x[0,0] for x in xs_e], 'o', markersize=3, label='x_euler')\n",
+    "plt.plot(t_range,[x[0,0] for x in xs_mid], 'o', markersize=3, label='x_midpoint')\n",
+    "plt.plot(t_range,[x[0,0] for x in xs_sol], '-', markersize=3, label='x_solution')\n",
+    "plt.xlabel('t (s)')\n",
+    "plt.ylabel('position (m)')\n",
+    "\n",
+    "plt.legend()\n",
+    "\n",
+    "plt.show()"
+   ]
   }
  ],
  "metadata": {

Разница между файлами не показана из-за своего большого размера
+ 1395 - 168
examples/Loading_FunctionalMockupUnits/.ipynb_checkpoints/Loading_FunctionalMockupUnits-checkpoint.ipynb


Разница между файлами не показана из-за своего большого размера
+ 1395 - 168
examples/Loading_FunctionalMockupUnits/Loading_FunctionalMockupUnits.ipynb