|
179 | 179 | "outputs": [], |
180 | 180 | "source": [ |
181 | 181 | "# Compute wakefield arrays (slow due to numerical integration)\n", |
182 | | - "zs = np.linspace(0, 200e-6, 30)\n", |
| 182 | + "# Wake is defined for z < 0 (behind the source particle)\n", |
| 183 | + "zs = -np.linspace(1e-6, 200e-6, 30) # negative z values\n", |
183 | 184 | "Wz_flat = imp_flat.wakefield(zs, k_max=1e6)\n", |
184 | 185 | "Wz_round = imp_round.wakefield(zs, k_max=1e6)" |
185 | 186 | ] |
|
192 | 193 | "outputs": [], |
193 | 194 | "source": [ |
194 | 195 | "fig, ax = plt.subplots(figsize=(8, 4))\n", |
195 | | - "ax.plot(zs * 1e6, Wz_flat * 1e-12, label=\"Flat\")\n", |
196 | | - "ax.plot(zs * 1e6, Wz_round * 1e-12, \"--\", label=\"Round\")\n", |
197 | | - "ax.set_xlabel(r\"$z$ (µm)\")\n", |
| 196 | + "ax.plot(-zs * 1e6, Wz_flat * 1e-12, label=\"Flat\") # plot as distance behind source\n", |
| 197 | + "ax.plot(-zs * 1e6, Wz_round * 1e-12, \"--\", label=\"Round\")\n", |
| 198 | + "ax.set_xlabel(r\"Distance behind source $|z|$ (µm)\")\n", |
198 | 199 | "ax.set_ylabel(r\"$W(z)$ (V/pC/m)\")\n", |
199 | 200 | "ax.legend()\n", |
200 | 201 | "ax.set_title(\"Wakefield Comparison: Flat vs Round Geometry\")" |
|
251 | 252 | "outputs": [], |
252 | 253 | "source": [ |
253 | 254 | "# Evaluate pseudomode wakefields (very fast!)\n", |
254 | | - "zs_fine = np.linspace(0, 200e-6, 200)\n", |
255 | | - "\n", |
256 | | - "# Note: pseudomode expects negative z (trailing the source)\n", |
257 | | - "Wz_pseudo_flat = wake_flat.pseudomode(-zs_fine)\n", |
258 | | - "Wz_pseudo_round = wake_round.pseudomode(-zs_fine)" |
| 255 | + "# Both methods use z < 0 for trailing particles\n", |
| 256 | + "zs_fine = -np.linspace(1e-6, 200e-6, 200) # negative z values\n", |
| 257 | + "Wz_pseudo_flat = wake_flat.pseudomode(zs_fine)\n", |
| 258 | + "Wz_pseudo_round = wake_round.pseudomode(zs_fine)" |
259 | 259 | ] |
260 | 260 | }, |
261 | 261 | { |
|
269 | 269 | "fig, axes = plt.subplots(1, 2, figsize=(12, 5))\n", |
270 | 270 | "\n", |
271 | 271 | "ax = axes[0]\n", |
272 | | - "ax.plot(zs * 1e6, Wz_flat * 1e-12, \"o\", label=\"Numerical\", markersize=5)\n", |
273 | | - "ax.plot(zs_fine * 1e6, Wz_pseudo_flat * 1e-12, \"-\", label=\"Pseudomode\", alpha=0.8)\n", |
274 | | - "ax.set_xlabel(r\"$z$ (µm)\")\n", |
| 272 | + "ax.plot(-zs * 1e6, Wz_flat * 1e-12, \"o\", label=\"Numerical\", markersize=5)\n", |
| 273 | + "ax.plot(-zs_fine * 1e6, Wz_pseudo_flat * 1e-12, \"-\", label=\"Pseudomode\", alpha=0.8)\n", |
| 274 | + "ax.set_xlabel(r\"Distance behind source $|z|$ (µm)\")\n", |
275 | 275 | "ax.set_ylabel(r\"$W(z)$ (V/pC/m)\")\n", |
276 | 276 | "ax.legend()\n", |
277 | 277 | "ax.set_title(\"Flat Geometry\")\n", |
278 | 278 | "\n", |
279 | 279 | "ax = axes[1]\n", |
280 | | - "ax.plot(zs * 1e6, Wz_round * 1e-12, \"o\", label=\"Numerical\", markersize=5)\n", |
281 | | - "ax.plot(zs_fine * 1e6, Wz_pseudo_round * 1e-12, \"-\", label=\"Pseudomode\", alpha=0.8)\n", |
282 | | - "ax.set_xlabel(r\"$z$ (µm)\")\n", |
| 280 | + "ax.plot(-zs * 1e6, Wz_round * 1e-12, \"o\", label=\"Numerical\", markersize=5)\n", |
| 281 | + "ax.plot(-zs_fine * 1e6, Wz_pseudo_round * 1e-12, \"-\", label=\"Pseudomode\", alpha=0.8)\n", |
| 282 | + "ax.set_xlabel(r\"Distance behind source $|z|$ (µm)\")\n", |
283 | 283 | "ax.set_ylabel(r\"$W(z)$ (V/pC/m)\")\n", |
284 | 284 | "ax.legend()\n", |
285 | 285 | "ax.set_title(\"Round Geometry\")\n", |
|
307 | 307 | "source": [ |
308 | 308 | "%%timeit -n 1 -r 3\n", |
309 | 309 | "# Numerical integration for 20 points\n", |
310 | | - "z_test = np.linspace(0, 100e-6, 20)\n", |
| 310 | + "z_test = -np.linspace(1e-6, 100e-6, 20)\n", |
311 | 311 | "_ = imp_flat.wakefield(z_test, k_max=1e6)" |
312 | 312 | ] |
313 | 313 | }, |
|
320 | 320 | "source": [ |
321 | 321 | "%%timeit -n 1000 -r 3\n", |
322 | 322 | "# Pseudomode for 1000 points\n", |
323 | | - "z_test = np.linspace(0, 100e-6, 1000)\n", |
324 | | - "_ = wake_flat.pseudomode(-z_test)" |
| 323 | + "z_test = -np.linspace(1e-6, 100e-6, 1000)\n", |
| 324 | + "_ = wake_flat.pseudomode(z_test)" |
325 | 325 | ] |
326 | 326 | }, |
327 | 327 | { |
|
341 | 341 | "- Working with unusual parameter regimes\n", |
342 | 342 | "- Need access to the impedance spectrum $Z(k)$" |
343 | 343 | ] |
| 344 | + }, |
| 345 | + { |
| 346 | + "cell_type": "markdown", |
| 347 | + "id": "592c26c6", |
| 348 | + "metadata": {}, |
| 349 | + "source": [] |
| 350 | + }, |
| 351 | + { |
| 352 | + "cell_type": "markdown", |
| 353 | + "id": "b76be5fd", |
| 354 | + "metadata": {}, |
| 355 | + "source": [] |
344 | 356 | } |
345 | 357 | ], |
346 | 358 | "metadata": { |
|
0 commit comments