Skip to content

Commit 811b941

Browse files
kangwonleebeachdweller
authored andcommitted
50 / 30 : set arguments for exact plotter
Clean ipynb 8bfa77e
1 parent 9e1f228 commit 811b941

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

50_ode/30_Runge_Kutta.ipynb

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,11 @@
270270
]
271271
},
272272
{
273-
"cell_type": "code",
274-
"execution_count": null,
273+
"cell_type": "markdown",
275274
"metadata": {},
276-
"outputs": [],
277275
"source": [
278-
"def exact(t):\n",
279-
" return x_0 * py.exp((-a_1 / a_0) * t)\n",
276+
"Initial value $x(t_0)$<br>초기값 $x(t_0)$\n",
277+
"\n",
280278
"\n"
281279
]
282280
},
@@ -286,15 +284,18 @@
286284
"metadata": {},
287285
"outputs": [],
288286
"source": [
289-
"import ode_solver\n",
287+
"x_0 = 4.5\n",
290288
"\n"
291289
]
292290
},
293291
{
294-
"cell_type": "markdown",
292+
"cell_type": "code",
293+
"execution_count": null,
295294
"metadata": {},
295+
"outputs": [],
296296
"source": [
297-
"$\\Delta t$\n",
297+
"def exact(t):\n",
298+
" return x_0 * py.exp((-a_1 / a_0) * t)\n",
298299
"\n"
299300
]
300301
},
@@ -304,17 +305,15 @@
304305
"metadata": {},
305306
"outputs": [],
306307
"source": [
307-
"delta_t = 1.0\n",
308-
"t_sec_array = np.arange(0, 6 + delta_t*0.5, delta_t)\n",
308+
"import ode_solver\n",
309309
"\n"
310310
]
311311
},
312312
{
313313
"cell_type": "markdown",
314314
"metadata": {},
315315
"source": [
316-
"초기값<br>Initial value<br>\n",
317-
"$x(t_0)$\n",
316+
"$\\Delta t$\n",
318317
"\n"
319318
]
320319
},
@@ -324,7 +323,8 @@
324323
"metadata": {},
325324
"outputs": [],
326325
"source": [
327-
"x_0 = 4.5\n",
326+
"delta_t = 0.01\n",
327+
"t_sec_array = np.arange(0, 6 + delta_t*0.5, delta_t)\n",
328328
"\n"
329329
]
330330
},
@@ -419,7 +419,10 @@
419419
"\n",
420420
"# *** Exact Solution\n",
421421
"t_exact_array = np.linspace(0, 6)\n",
422-
"exact = ode_plot.ExactPlotterFirstOrderODE(t_exact_array)\n",
422+
"exact = ode_plot.ExactPlotterFirstOrderODE(\n",
423+
" t_exact_array,\n",
424+
" a_0=a_0, a_1=a_1, x_0=x_0)\n",
425+
"\n",
423426
"exact.plot()\n",
424427
"\n",
425428
"py.xlabel('t(sec)')\n",
@@ -481,8 +484,11 @@
481484
"py.plot(t_rk4___out, x_rk4___out, '.-', label='RK4')\n",
482485
"\n",
483486
"# plot exact solution\n",
484-
"exact = ode_plot.ExactPlotterFirstOrderODE(py.array(t_rk4___out))\n",
487+
"exact = ode_plot.ExactPlotterFirstOrderODE(\n",
488+
" py.array(t_rk4___out),\n",
489+
" a_0=a_0, a_1=a_1, x_0=x_0)\n",
485490
"exact.plot()\n",
491+
"\n",
486492
"py.grid(True)\n",
487493
"py.xlabel('t(sec)')\n",
488494
"py.ylabel('y(t)')\n",

0 commit comments

Comments
 (0)