diff --git a/dynamics_examples.ipynb b/dynamics_examples.ipynb index 73cc3ce7..68a8cc8c 100644 --- a/dynamics_examples.ipynb +++ b/dynamics_examples.ipynb @@ -68,6 +68,13 @@ "settings = (z = z_grid, tstops = 0:1e-3:T, Δ_E = 1e-04)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Testing and profiling the core function" + ] + }, { "cell_type": "code", "execution_count": null, @@ -84,19 +91,11 @@ "@btime f!($resid,$du,$u,[ ],$t)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "resid" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ + "## Solving the Full Problem with Dynamics\n", "Now let's solve the problem and draw the plots!" ] }, @@ -107,76 +106,20 @@ "outputs": [], "source": [ "# solve the dynamics!\n", - "solved_tuple = solve_dynamics(params_T, stationary_sol, settings, T, Ω)\n", + "@time solved_tuple = solve_dynamics(params_T, stationary_sol, settings, T, Ω)\n", "solved = solved_tuple.results\n", "v_t0 = solved_tuple.sol.u[1][1:M]\n", "v0 = solved[:v_0]\n", "\n", "# save v0 and v_hat_t0\n", - "v_hat_t0 = map(z -> exp((params.σ-1)*z), z_grid) .* v_t0" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot(solved.t, solved.entry_residual, label = \"entry_residual\", lw = 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot(solved.t, solved.g, label = \"g\", lw = 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot(solved.t, solved.z_hat, label = \"z_hat\", lw = 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot(solved.t, solved.S, label = \"S\", lw = 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot(solved.t, solved.L_tilde, label = \"L_tilde\", lw = 3)" + "v_hat_t0 = map(z -> exp((params.σ-1)*z), z_grid) .* v_t0;" ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plot(solved.t, solved.z_bar, label = \"z_bar\", lw = 3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "plot(solved.t, solved.π_min, label = \"pi_min\", lw = 3)" + "## Primary Plots" ] }, { @@ -185,16 +128,18 @@ "metadata": {}, "outputs": [], "source": [ - "plot(solved.t, solved.λ_ii, label = \"lambda_ii\", lw = 3)" + "plot1 = plot(solved.t, solved.g, label = \"g\", lw = 3)\n", + "plot2 = plot(solved.t, solved.z_hat, label = \"z_hat\", lw = 3)\n", + "plot3 = plot(solved.t, solved.S, label = \"S\", lw = 3)\n", + "plot4 = plot(solved.t, solved.entry_residual, label = \"entry_residual\", lw = 3)\n", + "plot(plot1, plot2, plot3, plot4, layout=(2,2))" ] }, { - "cell_type": "code", - "execution_count": null, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "plot(solved.t, solved.c, label = \"c\", lw = 3)" + "## Static Equations" ] }, { @@ -203,7 +148,14 @@ "metadata": {}, "outputs": [], "source": [ - "plot(solved.t, solved.E, label = \"E\", lw = 3)" + "plot1 = plot(solved.t, solved.L_tilde, label = \"L_tilde\", lw = 3)\n", + "plot2 = plot(solved.t, solved.z_bar, label = \"z_bar\", lw = 3)\n", + "plot3 = plot(solved.t, solved.π_min, label = \"pi_min\", lw = 3)\n", + "plot4 = plot(solved.t, solved.λ_ii, label = \"lambda_ii\", lw = 3)\n", + "plot5 = plot(solved.t, solved.c, label = \"c\", lw = 3)\n", + "plot6 = plot(solved.t, solved.E, label = \"E\", lw = 3)\n", + "plot7 = plot(z_grid, v_hat_t0, label = \"v_hat at t = 0\", lw = 3)\n", + "plot(plot1, plot2, plot3, plot4, plot5, plot6, layout=(3,2))" ] }, { @@ -212,7 +164,10 @@ "metadata": {}, "outputs": [], "source": [ - "plot(z_grid, v_hat_t0, label = \"v_hat at t = 0\", lw = 3)" + "# Can examine the returned data with the Voyager and/or Vegalite\n", + "using DataVoyager, VegaLite\n", + "solved |> Voyager()\n", + "#solved |> @vlplot(:line, x = :t, y = :g, width=400, height=400)" ] }, { @@ -220,9 +175,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "solved.v_0" - ] + "source": [] } ], "metadata": {