|
68 | 68 | "settings = (z = z_grid, tstops = 0:1e-3:T, Δ_E = 1e-04)" |
69 | 69 | ] |
70 | 70 | }, |
| 71 | + { |
| 72 | + "cell_type": "markdown", |
| 73 | + "metadata": {}, |
| 74 | + "source": [ |
| 75 | + "## Testing and profiling the core function" |
| 76 | + ] |
| 77 | + }, |
71 | 78 | { |
72 | 79 | "cell_type": "code", |
73 | 80 | "execution_count": null, |
|
84 | 91 | "@btime f!($resid,$du,$u,[ ],$t)" |
85 | 92 | ] |
86 | 93 | }, |
87 | | - { |
88 | | - "cell_type": "code", |
89 | | - "execution_count": null, |
90 | | - "metadata": {}, |
91 | | - "outputs": [], |
92 | | - "source": [ |
93 | | - "resid" |
94 | | - ] |
95 | | - }, |
96 | 94 | { |
97 | 95 | "cell_type": "markdown", |
98 | 96 | "metadata": {}, |
99 | 97 | "source": [ |
| 98 | + "## Solving the Full Problem with Dynamics\n", |
100 | 99 | "Now let's solve the problem and draw the plots!" |
101 | 100 | ] |
102 | 101 | }, |
|
107 | 106 | "outputs": [], |
108 | 107 | "source": [ |
109 | 108 | "# 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", |
111 | 110 | "solved = solved_tuple.results\n", |
112 | 111 | "v_t0 = solved_tuple.sol.u[1][1:M]\n", |
113 | 112 | "v0 = solved[:v_0]\n", |
114 | 113 | "\n", |
115 | 114 | "# 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;" |
162 | 116 | ] |
163 | 117 | }, |
164 | 118 | { |
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", |
176 | 120 | "metadata": {}, |
177 | | - "outputs": [], |
178 | 121 | "source": [ |
179 | | - "plot(solved.t, solved.π_min, label = \"pi_min\", lw = 3)" |
| 122 | + "## Primary Plots" |
180 | 123 | ] |
181 | 124 | }, |
182 | 125 | { |
|
185 | 128 | "metadata": {}, |
186 | 129 | "outputs": [], |
187 | 130 | "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))" |
189 | 136 | ] |
190 | 137 | }, |
191 | 138 | { |
192 | | - "cell_type": "code", |
193 | | - "execution_count": null, |
| 139 | + "cell_type": "markdown", |
194 | 140 | "metadata": {}, |
195 | | - "outputs": [], |
196 | 141 | "source": [ |
197 | | - "plot(solved.t, solved.c, label = \"c\", lw = 3)" |
| 142 | + "## Static Equations" |
198 | 143 | ] |
199 | 144 | }, |
200 | 145 | { |
|
203 | 148 | "metadata": {}, |
204 | 149 | "outputs": [], |
205 | 150 | "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))" |
207 | 159 | ] |
208 | 160 | }, |
209 | 161 | { |
|
212 | 164 | "metadata": {}, |
213 | 165 | "outputs": [], |
214 | 166 | "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)" |
216 | 171 | ] |
217 | 172 | }, |
218 | 173 | { |
219 | 174 | "cell_type": "code", |
220 | 175 | "execution_count": null, |
221 | 176 | "metadata": {}, |
222 | 177 | "outputs": [], |
223 | | - "source": [ |
224 | | - "solved.v_0" |
225 | | - ] |
| 178 | + "source": [] |
226 | 179 | } |
227 | 180 | ], |
228 | 181 | "metadata": { |
|
0 commit comments