Skip to content

Commit a2d74b8

Browse files
committed
Rearranged plots and added datavoyager
1 parent e382281 commit a2d74b8

1 file changed

Lines changed: 32 additions & 79 deletions

File tree

dynamics_examples.ipynb

Lines changed: 32 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868
"settings = (z = z_grid, tstops = 0:1e-3:T, Δ_E = 1e-04)"
6969
]
7070
},
71+
{
72+
"cell_type": "markdown",
73+
"metadata": {},
74+
"source": [
75+
"## Testing and profiling the core function"
76+
]
77+
},
7178
{
7279
"cell_type": "code",
7380
"execution_count": null,
@@ -84,19 +91,11 @@
8491
"@btime f!($resid,$du,$u,[ ],$t)"
8592
]
8693
},
87-
{
88-
"cell_type": "code",
89-
"execution_count": null,
90-
"metadata": {},
91-
"outputs": [],
92-
"source": [
93-
"resid"
94-
]
95-
},
9694
{
9795
"cell_type": "markdown",
9896
"metadata": {},
9997
"source": [
98+
"## Solving the Full Problem with Dynamics\n",
10099
"Now let's solve the problem and draw the plots!"
101100
]
102101
},
@@ -107,76 +106,20 @@
107106
"outputs": [],
108107
"source": [
109108
"# solve the dynamics!\n",
110-
"solved_tuple = solve_dynamics(params_T, stationary_sol, settings, T, Ω)\n",
109+
"@time solved_tuple = solve_dynamics(params_T, stationary_sol, settings, T, Ω)\n",
111110
"solved = solved_tuple.results\n",
112111
"v_t0 = solved_tuple.sol.u[1][1:M]\n",
113112
"v0 = solved[:v_0]\n",
114113
"\n",
115114
"# save v0 and v_hat_t0\n",
116-
"v_hat_t0 = map(z -> exp((params.σ-1)*z), z_grid) .* v_t0"
117-
]
118-
},
119-
{
120-
"cell_type": "code",
121-
"execution_count": null,
122-
"metadata": {},
123-
"outputs": [],
124-
"source": [
125-
"plot(solved.t, solved.entry_residual, label = \"entry_residual\", lw = 3)"
126-
]
127-
},
128-
{
129-
"cell_type": "code",
130-
"execution_count": null,
131-
"metadata": {},
132-
"outputs": [],
133-
"source": [
134-
"plot(solved.t, solved.g, label = \"g\", lw = 3)"
135-
]
136-
},
137-
{
138-
"cell_type": "code",
139-
"execution_count": null,
140-
"metadata": {},
141-
"outputs": [],
142-
"source": [
143-
"plot(solved.t, solved.z_hat, label = \"z_hat\", lw = 3)"
144-
]
145-
},
146-
{
147-
"cell_type": "code",
148-
"execution_count": null,
149-
"metadata": {},
150-
"outputs": [],
151-
"source": [
152-
"plot(solved.t, solved.S, label = \"S\", lw = 3)"
153-
]
154-
},
155-
{
156-
"cell_type": "code",
157-
"execution_count": null,
158-
"metadata": {},
159-
"outputs": [],
160-
"source": [
161-
"plot(solved.t, solved.L_tilde, label = \"L_tilde\", lw = 3)"
115+
"v_hat_t0 = map(z -> exp((params.σ-1)*z), z_grid) .* v_t0;"
162116
]
163117
},
164118
{
165-
"cell_type": "code",
166-
"execution_count": null,
167-
"metadata": {},
168-
"outputs": [],
169-
"source": [
170-
"plot(solved.t, solved.z_bar, label = \"z_bar\", lw = 3)"
171-
]
172-
},
173-
{
174-
"cell_type": "code",
175-
"execution_count": null,
119+
"cell_type": "markdown",
176120
"metadata": {},
177-
"outputs": [],
178121
"source": [
179-
"plot(solved.t, solved.π_min, label = \"pi_min\", lw = 3)"
122+
"## Primary Plots"
180123
]
181124
},
182125
{
@@ -185,16 +128,18 @@
185128
"metadata": {},
186129
"outputs": [],
187130
"source": [
188-
"plot(solved.t, solved.λ_ii, label = \"lambda_ii\", lw = 3)"
131+
"plot1 = plot(solved.t, solved.g, label = \"g\", lw = 3)\n",
132+
"plot2 = plot(solved.t, solved.z_hat, label = \"z_hat\", lw = 3)\n",
133+
"plot3 = plot(solved.t, solved.S, label = \"S\", lw = 3)\n",
134+
"plot4 = plot(solved.t, solved.entry_residual, label = \"entry_residual\", lw = 3)\n",
135+
"plot(plot1, plot2, plot3, plot4, layout=(2,2))"
189136
]
190137
},
191138
{
192-
"cell_type": "code",
193-
"execution_count": null,
139+
"cell_type": "markdown",
194140
"metadata": {},
195-
"outputs": [],
196141
"source": [
197-
"plot(solved.t, solved.c, label = \"c\", lw = 3)"
142+
"## Static Equations"
198143
]
199144
},
200145
{
@@ -203,7 +148,14 @@
203148
"metadata": {},
204149
"outputs": [],
205150
"source": [
206-
"plot(solved.t, solved.E, label = \"E\", lw = 3)"
151+
"plot1 = plot(solved.t, solved.L_tilde, label = \"L_tilde\", lw = 3)\n",
152+
"plot2 = plot(solved.t, solved.z_bar, label = \"z_bar\", lw = 3)\n",
153+
"plot3 = plot(solved.t, solved.π_min, label = \"pi_min\", lw = 3)\n",
154+
"plot4 = plot(solved.t, solved.λ_ii, label = \"lambda_ii\", lw = 3)\n",
155+
"plot5 = plot(solved.t, solved.c, label = \"c\", lw = 3)\n",
156+
"plot6 = plot(solved.t, solved.E, label = \"E\", lw = 3)\n",
157+
"plot7 = plot(z_grid, v_hat_t0, label = \"v_hat at t = 0\", lw = 3)\n",
158+
"plot(plot1, plot2, plot3, plot4, plot5, plot6, layout=(3,2))"
207159
]
208160
},
209161
{
@@ -212,17 +164,18 @@
212164
"metadata": {},
213165
"outputs": [],
214166
"source": [
215-
"plot(z_grid, v_hat_t0, label = \"v_hat at t = 0\", lw = 3)"
167+
"# Can examine the returned data with the Voyager and/or Vegalite\n",
168+
"using DataVoyager, VegaLite\n",
169+
"solved |> Voyager()\n",
170+
"#solved |> @vlplot(:line, x = :t, y = :g, width=400, height=400)"
216171
]
217172
},
218173
{
219174
"cell_type": "code",
220175
"execution_count": null,
221176
"metadata": {},
222177
"outputs": [],
223-
"source": [
224-
"solved.v_0"
225-
]
178+
"source": []
226179
}
227180
],
228181
"metadata": {

0 commit comments

Comments
 (0)