|
294 | 294 | }, |
295 | 295 | { |
296 | 296 | "cell_type": "code", |
297 | | - "execution_count": 36, |
| 297 | + "execution_count": 6, |
298 | 298 | "metadata": {}, |
299 | 299 | "outputs": [], |
300 | 300 | "source": [ |
|
307 | 307 | }, |
308 | 308 | { |
309 | 309 | "cell_type": "code", |
310 | | - "execution_count": 37, |
| 310 | + "execution_count": 7, |
311 | 311 | "metadata": {}, |
312 | 312 | "outputs": [], |
313 | 313 | "source": [ |
314 | 314 | "# %load -s solver_FECS, src-advec/advec1D.py\n", |
315 | 315 | "def solver_FECS(I, U0, v, L, dt, C, T, user_action=None):\n", |
316 | 316 | " Nt = int(round(T/float(dt)))\n", |
| 317 | + " t = np.linspace(0, Nt*dt, Nt+1) # Mesh points in time\n", |
317 | 318 | " dx = v*dt/C\n", |
318 | 319 | " Nx = int(round(L/dx))\n", |
319 | | - "\n", |
320 | | - " t = np.linspace(0, Nt*dt, Nt+1)\n", |
321 | | - " x = np.linspace(0, L, Nx+1)\n", |
| 320 | + " x = np.linspace(0, L, Nx+1) # Mesh points in space\n", |
| 321 | + " \n", |
| 322 | + " # Make sure dx and dt are compatible with x and t\n", |
322 | 323 | " dx = float(x[1] - x[0])\n", |
323 | 324 | " dt = float(t[1] - t[0])\n", |
324 | 325 | " C = v*dt/dx\n", |
325 | 326 | "\n", |
326 | 327 | " grid = Grid(shape=(Nx+1,), extent=(L,))\n", |
327 | | - " t_s=grid.stepping_dim\n", |
| 328 | + " t_s=grid.time_dim\n", |
328 | 329 | "\n", |
329 | 330 | " u = TimeFunction(name='u', grid=grid, space_order=2, save=Nt+1)\n", |
330 | 331 | "\n", |
|
333 | 334 | " stencil = solve(pde, u.forward)\n", |
334 | 335 | " eq = Eq(u.forward, stencil)\n", |
335 | 336 | " \n", |
336 | | - " bc = [Eq(u[t_s+1, 0], U0)]\n", |
337 | | - " u.data[1, :] = [I(xs) for xs in x]\n", |
338 | | - "\n", |
| 337 | + " # Set initial condition u(x,0) = I(x)\n", |
| 338 | + " u.data[1, :] = [I(xi) for xi in x]\n", |
| 339 | + " \n", |
| 340 | + " # Insert boundary condition\n", |
| 341 | + " bc = [Eq(u[t_s, 0], U0)]\n", |
| 342 | + " \n", |
339 | 343 | " op = Operator([eq] + bc)\n", |
340 | 344 | " op.apply(time_m=1, dt=dt)\n", |
341 | 345 | " if user_action is not None:\n", |
|
421 | 425 | }, |
422 | 426 | { |
423 | 427 | "cell_type": "code", |
424 | | - "execution_count": 38, |
| 428 | + "execution_count": 8, |
425 | 429 | "metadata": {}, |
426 | 430 | "outputs": [], |
427 | 431 | "source": [ |
|
674 | 678 | ] |
675 | 679 | }, |
676 | 680 | { |
677 | | - "cell_type": "code", |
678 | | - "execution_count": 141, |
| 681 | + "cell_type": "markdown", |
679 | 682 | "metadata": {}, |
680 | | - "outputs": [ |
681 | | - { |
682 | | - "ename": "NameError", |
683 | | - "evalue": "name 'scheme' is not defined", |
684 | | - "output_type": "error", |
685 | | - "traceback": [ |
686 | | - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
687 | | - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
688 | | - "\u001b[0;32m<ipython-input-141-61a51f7851a3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0;34m...\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mn\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mscheme\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m'FE'\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0;36m0.5\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mC\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
689 | | - "\u001b[0;31mNameError\u001b[0m: name 'scheme' is not defined" |
690 | | - ] |
691 | | - } |
692 | | - ], |
693 | 683 | "source": [ |
| 684 | + "```python\n", |
694 | 685 | "Nt = int(round(T/float(dt)))\n", |
695 | 686 | "t = np.linspace(0, Nt*dt, Nt+1) # Mesh points in time\n", |
696 | 687 | "...\n", |
697 | | - "u = np.zeros(Nx+1)\n", |
698 | | - "u_1 = np.zeros(Nx+1)\n", |
699 | | - "u_2 = np.zeros(Nx+1)\n", |
700 | | - "...\n", |
701 | | - "for n in range(0, Nt):\n", |
702 | | - " if scheme == 'FE':\n", |
703 | | - " for i in range(1, Nx):\n", |
704 | | - " u[i] = u_1[i] - 0.5*C*(u_1[i+1] - u_1[i-1])\n", |
705 | | - " elif scheme == 'LF':\n", |
706 | | - " if n == 0:\n", |
707 | | - " # Use some scheme for the first step\n", |
708 | | - " for i in range(1, Nx):\n", |
709 | | - " ...\n", |
710 | | - " else:\n", |
711 | | - " for i in range(1, Nx+1):\n", |
712 | | - " u[i] = u_2[i] - C*(u_1[i] - u_1[i-1])\n", |
713 | | - "\n", |
714 | | - " # Switch variables before next step\n", |
715 | | - " u_2, u_1, u = u_1, u, u_2" |
| 688 | + "if scheme == 'FE':\n", |
| 689 | + " u = TimeFunction(name='u', grid=grid, space_order=2, save=2)\n", |
| 690 | + " pde = u.dtr + v*u.dxc\n", |
| 691 | + " \n", |
| 692 | + " for i in range(1, Nx):\n", |
| 693 | + " u[i] = u_1[i] - 0.5*C*(u_1[i+1] - u_1[i-1])\n", |
| 694 | + "elif scheme == 'LF':\n", |
| 695 | + " # Use some scheme for the first step\n", |
| 696 | + " u1 = ...\n", |
| 697 | + " pde1 = ...\n", |
| 698 | + " ...\n", |
| 699 | + " \n", |
| 700 | + " # Move to the LF scheme after the next step\n", |
| 701 | + " u = TimeFunction(name='u', grid=grid, time_order=2, space_order=2, save=Nt+1)\n", |
| 702 | + " u.data[0:2, :] = u1.data\n", |
| 703 | + " pde = u.dtc + v*u.dxc\n", |
| 704 | + " ...\n", |
| 705 | + "```" |
716 | 706 | ] |
717 | 707 | }, |
718 | 708 | { |
|
1113 | 1103 | ] |
1114 | 1104 | }, |
1115 | 1105 | { |
1116 | | - "cell_type": "code", |
1117 | | - "execution_count": 147, |
| 1106 | + "cell_type": "markdown", |
1118 | 1107 | "metadata": {}, |
1119 | | - "outputs": [ |
1120 | | - { |
1121 | | - "ename": "NameError", |
1122 | | - "evalue": "name 'periodic_bc' is not defined", |
1123 | | - "output_type": "error", |
1124 | | - "traceback": [ |
1125 | | - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
1126 | | - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
1127 | | - "\u001b[0;32m<ipython-input-147-6c4e6ba84a70>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mperiodic_bc\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0mi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mu_2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mC\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mNx\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mu\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mu_2\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mC\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m-\u001b[0m \u001b[0mu_1\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
1128 | | - "\u001b[0;31mNameError\u001b[0m: name 'periodic_bc' is not defined" |
1129 | | - ] |
1130 | | - } |
1131 | | - ], |
1132 | 1108 | "source": [ |
1133 | | - "if periodic_bc:\n", |
1134 | | - " i = 0\n", |
1135 | | - " u[i] = u_2[i] - C*(u_1[i+1] - u_1[Nx-1])\n", |
1136 | | - "for i in range(1, Nx):\n", |
1137 | | - " u[i] = u_2[i] - C*(u_1[i+1] - u_1[i-1])\n", |
1138 | | - "if periodic_bc:\n", |
1139 | | - " u[Nx] = u[0]" |
| 1109 | + "```python\n", |
| 1110 | + "pbc = [Eq(u[t_s+1, 0], u[t_s-1, 0] - C*(u[t_s, 1] - u[t_s, Nx-1]))]\n", |
| 1111 | + "pbc += [Eq(u[t_s, Nx], u[t_s, 0])]\n", |
| 1112 | + "...\n", |
| 1113 | + "\n", |
| 1114 | + "op = Operator(bc + (pbc if periodic_bc else []) + [eq])\n", |
| 1115 | + "```" |
1140 | 1116 | ] |
1141 | 1117 | }, |
1142 | 1118 | { |
|
1194 | 1170 | ] |
1195 | 1171 | }, |
1196 | 1172 | { |
1197 | | - "cell_type": "code", |
1198 | | - "execution_count": 143, |
| 1173 | + "cell_type": "markdown", |
1199 | 1174 | "metadata": {}, |
1200 | | - "outputs": [ |
1201 | | - { |
1202 | | - "data": { |
1203 | | - "text/plain": [ |
1204 | | - "0.0" |
1205 | | - ] |
1206 | | - }, |
1207 | | - "execution_count": 143, |
1208 | | - "metadata": {}, |
1209 | | - "output_type": "execute_result" |
1210 | | - } |
1211 | | - ], |
1212 | 1175 | "source": [ |
1213 | | - "dx*(0.5*u[0] + 0.5*u[Nx] + np.sum(u[1:-1]))" |
| 1176 | + "```python\n", |
| 1177 | + "dx*(0.5*u[0] + 0.5*u[Nx] + np.sum(u[1:-1]))\n", |
| 1178 | + "```" |
1214 | 1179 | ] |
1215 | 1180 | }, |
1216 | 1181 | { |
|
1227 | 1192 | }, |
1228 | 1193 | { |
1229 | 1194 | "cell_type": "code", |
1230 | | - "execution_count": null, |
| 1195 | + "execution_count": 12, |
1231 | 1196 | "metadata": {}, |
1232 | 1197 | "outputs": [], |
1233 | 1198 | "source": [ |
1234 | | - "# %load -s solver, src-advec/advec1D.py\n", |
1235 | 1199 | "def solver(I, U0, v, L, dt, C, T, user_action=None,\n", |
1236 | | - " scheme='FE', periodic_bc=False):\n", |
1237 | | - " print('USING DEVITO')\n", |
| 1200 | + " scheme='FE', periodic_bc=True):\n", |
1238 | 1201 | " Nt = int(round(T/float(dt)))\n", |
1239 | 1202 | " t = np.linspace(0, Nt*dt, Nt+1) # Mesh points in time\n", |
1240 | 1203 | " dx = v*dt/C\n", |
|
1249 | 1212 | "\n", |
1250 | 1213 | " integral = np.zeros(Nt+1)\n", |
1251 | 1214 | "\n", |
1252 | | - "# if user_action is not None:\n", |
1253 | | - "# user_action(u_n, x, t, 0)\n", |
1254 | | - "\n", |
1255 | | - " grid = Grid(shape=(Nx+1,), extent=(L,))\n", |
1256 | | - " t_s=grid.stepping_dim\n", |
| 1215 | + " grid = Grid(shape=(Nx+1,), extent=(L,), dtype=np.float64)\n", |
| 1216 | + " t_s=grid.time_dim\n", |
1257 | 1217 | " u = None\n", |
1258 | 1218 | " pde = None\n", |
1259 | 1219 | " \n", |
|
1265 | 1225 | " u = u(so=2)\n", |
1266 | 1226 | " pde = u.dtr + v*u.dxc\n", |
1267 | 1227 | " \n", |
| 1228 | + " pbc = [Eq(u[t_s+1, 0], u[t_s, 0] - 0.5*C*(u[t_s, 1] - u[t_s, Nx]))]\n", |
| 1229 | + " pbc += [Eq(u[t_s, Nx], u[t_s, 0])]\n", |
| 1230 | + " \n", |
1268 | 1231 | " elif scheme == 'LF':\n", |
1269 | | - " u = u(to=2, so=2)\n", |
| 1232 | + " # Use UP scheme for first timestep\n", |
| 1233 | + " u1 = TimeFunction(name='u1', grid=grid, save=2)\n", |
| 1234 | + " pde1 = u1.dtr + v*u1.dxl\n", |
| 1235 | + " \n", |
| 1236 | + " stencil1 = solve(pde1, u1.forward)\n", |
| 1237 | + " eq1 = Eq(u1.forward, stencil1)\n", |
| 1238 | + " \n", |
| 1239 | + " # Set initial condition u(x,0) = I(x)\n", |
| 1240 | + " u1.data[0, :] = [I(xi) for xi in x]\n", |
| 1241 | + " \n", |
| 1242 | + " bc1 = [Eq(u1[t_s+1, 0], U0)]\n", |
| 1243 | + " pbc1 = [Eq(u1[t_s, 0], u1[t_s, Nx])]\n", |
| 1244 | + " \n", |
| 1245 | + " integral[0] = dx*(0.5*u1.data[0][0] + 0.5*u1.data[0][Nx] + np.sum(u1.data[0][1:Nx]))\n", |
| 1246 | + " \n", |
| 1247 | + " if user_action is not None:\n", |
| 1248 | + " user_action(u1.data[0], x, t, 0)\n", |
| 1249 | + " \n", |
| 1250 | + " op1 = Operator(bc1 + (pbc1 if periodic_bc else []) + [eq1])\n", |
| 1251 | + " op1.apply(dt=dt)\n", |
| 1252 | + " \n", |
| 1253 | + " integral[1] = dx*(0.5*u1.data[1][0] + 0.5*u1.data[1][Nx] + np.sum(u1.data[1][1:Nx]))\n", |
| 1254 | + " \n", |
| 1255 | + " if user_action is not None:\n", |
| 1256 | + " user_action(u1.data[1], x, t, 1)\n", |
| 1257 | + " \n", |
| 1258 | + " print('I:', integral[1])\n", |
| 1259 | + " \n", |
| 1260 | + " # Now continue with LF scheme\n", |
| 1261 | + " u = u(to=2, so=2)\n", |
| 1262 | + " u.data[0:2, :] = u1.data\n", |
1270 | 1263 | " pde = u.dtc + v*u.dxc\n", |
| 1264 | + " \n", |
| 1265 | + " pbc = [Eq(u[t_s+1, 0], u[t_s-1, 0] - C*(u[t_s, 1] - u[t_s, Nx - 1]))]\n", |
| 1266 | + " pbc += [Eq(u[t_s, Nx], u[t_s, 0])]\n", |
1271 | 1267 | " \n", |
1272 | 1268 | " elif scheme == 'UP':\n", |
1273 | 1269 | " u = u()\n", |
1274 | | - " pde = u.dtr - v*u.dxl\n", |
1275 | | - " \n", |
1276 | | - " elif scheme == 'LW':\n", |
1277 | | - " pass\n", |
1278 | | - " \n", |
| 1270 | + " pde = u.dtr + v*u.dxl\n", |
| 1271 | + " \n", |
| 1272 | + " pbc = [Eq(u[t_s, 0], u[t_s, Nx])]\n", |
| 1273 | + "\n", |
1279 | 1274 | " else:\n", |
1280 | 1275 | " raise ValueError('scheme=\"%s\" not implemented' % scheme)\n", |
1281 | 1276 | "\n", |
1282 | 1277 | " stencil = solve(pde, u.forward)\n", |
1283 | 1278 | " eq = Eq(u.forward, stencil)\n", |
1284 | 1279 | " \n", |
1285 | | - " bc = [Eq(u[t_s+1, 0], U0)] # non-periodic boundary condition\n", |
1286 | | - " u.data[0:2, :] = [I(xs) for xs in x]\n", |
| 1280 | + " if scheme != 'LF':\n", |
| 1281 | + " # Set initial condition u(x,0) = I(x)\n", |
| 1282 | + " u.data[0, :] = [I(xi) for xi in x]\n", |
| 1283 | + " \n", |
| 1284 | + " # Compute the integral under the curve\n", |
| 1285 | + " integral[0] = dx*(0.5*u.data[0][0] + 0.5*u.data[0][Nx] + np.sum(u.data[0][1:Nx]))\n", |
| 1286 | + " \n", |
| 1287 | + " if user_action is not None:\n", |
| 1288 | + " user_action(u.data[0], x, t, 0)\n", |
1287 | 1289 | "\n", |
1288 | | - " op = Operator([eq] + bc)\n", |
1289 | | - " op.apply(time_m=1, dt=float(dt))\n", |
1290 | | - " print(u.data)\n", |
1291 | | - " for n in range(0, Nt+1):\n", |
| 1290 | + " bc = [Eq(u[t_s+1, 0], U0)]\n", |
| 1291 | + "\n", |
| 1292 | + " op = Operator(bc + (pbc if periodic_bc else []) + [eq])\n", |
| 1293 | + " op.apply(time_m=1 if scheme == 'LF' else 0, time_M=Nt-1, dt=float(dt))\n", |
| 1294 | + "\n", |
| 1295 | + " for n in range(2 if scheme == 'LF' else 1, Nt+1):\n", |
1292 | 1296 | " # Compute the integral under the curve\n", |
1293 | 1297 | " integral[n] = dx*(0.5*u.data[n][0] + 0.5*u.data[n][Nx] + np.sum(u.data[n][1:Nx]))\n", |
1294 | 1298 | "\n", |
|
1313 | 1317 | }, |
1314 | 1318 | { |
1315 | 1319 | "cell_type": "code", |
1316 | | - "execution_count": 151, |
| 1320 | + "execution_count": 15, |
1317 | 1321 | "metadata": {}, |
1318 | 1322 | "outputs": [], |
1319 | 1323 | "source": [ |
|
1341 | 1345 | " lines = plt.plot(x, u)\n", |
1342 | 1346 | " plt.axis([x[0], x[-1], -0.5, 1.5])\n", |
1343 | 1347 | " plt.xlabel('x'); plt.ylabel('u')\n", |
1344 | | - " plt.axes().set_aspect(0.15)\n", |
1345 | 1348 | " plt.savefig('tmp_%04d.png' % n)\n", |
1346 | 1349 | " plt.savefig('tmp_%04d.pdf' % n)\n", |
1347 | 1350 | " else:\n", |
|
1401 | 1404 | " plt.figure(2)\n", |
1402 | 1405 | " plt.axis([0, L, -0.5, 1.1])\n", |
1403 | 1406 | " plt.xlabel('$x$'); plt.ylabel('$u$')\n", |
1404 | | - " plt.axes().set_aspect(0.5) # no effect\n", |
1405 | 1407 | " plt.savefig('tmp1.png'); plt.savefig('tmp1.pdf')\n", |
1406 | 1408 | " plt.show()\n", |
1407 | 1409 | " # Make videos from figure(1) animation files\n", |
|
0 commit comments