Skip to content

Commit

Permalink
Rearranged plots and added datavoyager
Browse files Browse the repository at this point in the history
  • Loading branch information
jlperla committed Sep 20, 2018
1 parent e382281 commit a2d74b8
Showing 1 changed file with 32 additions and 79 deletions.
111 changes: 32 additions & 79 deletions dynamics_examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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!"
]
},
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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))"
]
},
{
Expand All @@ -212,17 +164,18 @@
"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)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"solved.v_0"
]
"source": []
}
],
"metadata": {
Expand Down

0 comments on commit a2d74b8

Please sign in to comment.