"What about the vertical plane now? The quadrupoles have their function inverted, a horizontally focusing quadrupole defocuses in the vertical plane, so the same lattice looks like \"D-O-F-O\" with respect to the vertical plane:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c812ee8-e125-4511-9d77-18d4dd9eaeff",
"metadata": {},
"outputs": [],
"source": [
"sig_y = 5e-3\n",
"sig_yp = 3e-4\n",
"\n",
"y = np.random.normal(0, sig_y, N)\n",
"yp = np.random.normal(0, sig_yp, N)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4fbf3925-8597-4bc1-a914-77b1c4dcd824",
"metadata": {},
"outputs": [],
"source": [
"Qfy = M_quad_y(ds, k)\n",
"Qdy = M_quad_y(ds, -k)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "df82b0c1-608e-48c1-b6a2-66925175ca07",
"metadata": {},
"outputs": [],
"source": [
"# 1/2 vertically defocusing quad (horizontally focusing, so \"Qf\")\n",
"for s in np.arange(0, 0.5001, ds):\n",
" y, yp = track(Qfy, y, yp)\n",
" plt.scatter(np.ones(N) * s, y, c='C0', s=1, marker='.')\n",
"# drift\n",
"for s in np.arange(0.5, 4.5001, ds)[1:]:\n",
" y, yp = track(D, y, yp)\n",
" plt.scatter(np.ones(N) * s, y, c='C0', s=1, marker='.')\n",
"# defocusing quad (horizontally defocusing, so \"Qd\")\n",
"for s in np.arange(4.5, 5.5001, ds)[1:]:\n",
" y, yp = track(Qdy, y, yp)\n",
" plt.scatter(np.ones(N) * s, y, c='C0', s=1, marker='.')\n",
"# drift\n",
"for s in np.arange(5.5, 9.5001, ds)[1:]:\n",
" y, yp = track(D, y, yp)\n",
" plt.scatter(np.ones(N) * s, y, c='C0', s=1, marker='.')\n",
"# 1/2 focusing quad\n",
"for s in np.arange(9.5, 10.0001, ds)[1:]:\n",
" y, yp = track(Qfy, y, yp)\n",
" plt.scatter(np.ones(N) * s, y, c='C0', s=1, marker='.')\n",
"plt.xlabel('$s$')\n",
"plt.ylabel('$y$');"
]
},
{
"cell_type": "markdown",
"id": "631ece08-d991-4155-826d-ab4af9a81c8e",
"metadata": {},
"source": [
"$\\implies$ can ensure quasi-harmonic motion in both (!) transverse planes! Transverse confinement of beam by alternating-gradient (AG) focusing! This is the principle behind synchrotrons!\n",
"\n",
"How does this look like over long time scales? Let us build the one-cell matrix and track for many cells:"
"$\\implies$ motion becomes unstable! Is the one-cell matrix a \"valid\" (symplectic) betatron matrix?"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b0caacc4-b24e-4543-a7d9-9ea62a6b76bc",
"metadata": {},
"outputs": [],
"source": [
"np.linalg.det(M_cell)"
]
},
{
"cell_type": "markdown",
"id": "4bf0efe8-0181-4993-a08e-0700ee2711db",
"metadata": {},
"source": [
"$\\implies$ the matrix obeys $\\det(\\mathcal{M})=1$ and is thus symplectic. But what about the eigenvalues?\n",
"\n",
"Solve the characteristic polynomial of the one-cell matrix, $\\det(\\mathcal{M}-\\lambda\\mathbb{1})=0$ for $\\lambda$:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51533d43-b457-4368-b070-bff2973a74dd",
"metadata": {},
"outputs": [],
"source": [
"np.linalg.eigvals(M_cell)"
]
},
{
"cell_type": "markdown",
"id": "f8944c88-5aa1-45e2-96d4-41b1a0ea27fd",
"metadata": {},
"source": [
"$\\implies$ we find one $|\\lambda|>1$! If one absolute eigenvalue becomes larger than unity, the magnet configuration becomes unstable! That explains the instability (exponential divergence) here! Equivalently one finds $|\\mathrm{Tr}(\\mathcal{M})|>2$:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8e92e564-514c-4587-a7bc-0c8dce9146c9",
"metadata": {},
"outputs": [],
"source": [
"np.trace(M_cell)"
]
},
{
"cell_type": "markdown",
"id": "4b8c2711-50ef-4df9-9f93-073232be83ff",
"metadata": {},
"source": [
"What happens to a single particle in phase space in the Poincaré section?"
"<h3>6. Simulating a FODO cell with a sextupole:</h3>\n",
"\n",
"We go back to the stable FODO cell configuration and add a thin sextupole magnet after 1/4 of the lattice, between the first focusing and the second defocusing quadrupole!\n",
"\n",
"The sextupole kick provides a non-linearity in the potential that confines the particles. At large enough amplitude, the non-linear term dominates the particles are no longer bound / confined!\n",
"\n",
"We need to track in 4D phase-space (full transverse plane with both x and y), as the sextupole provides coupling terms:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9c298f2d-a26e-4d43-bbc3-7b77613ec6d5",
"metadata": {},
"outputs": [],
"source": [
"np.random.seed(12345)"
]
},
{
"cell_type": "markdown",
"id": "e44d0e59-8e22-4810-a759-e75d6cd97346",
"metadata": {},
"source": [
"We need a first matrix 1/4 of the cell until the sextupole, one for the $x$ (`M_cell_x_1`) and another one for the $y$ plane (`M_cell_y_1`). Then a second matrix each to track $x$ and $y$ for the remaining 3/4 of the cell (`M_cell_x_2`, `M_cell_y_2`):"
"$\\implies$ single particles do not maintain the same (linear) ampitude (radius in $x-x'$) during the tracking!\n",
"\n",
"A single particle looks like this:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "efd05d93-505b-4d57-adbe-4729b014dbce",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(rec_x[:, 0])\n",
"plt.xlabel('Turns')\n",
"plt.ylabel('$x$');"
]
},
{
"cell_type": "markdown",
"id": "04445659-6999-406f-a2b6-e0e859a6ee49",
"metadata": {},
"source": [
"$\\implies$ distorted regular motion (see the asymmetry between positive and negative $x$ values in the oscillation), the particle is still bound but the sextupole deforms the phase-space topology from the regular circles we observed for purely linear tracking.\n",
"\n",
"Remember, the last particle was just a copy from the first particle with a slightly increased $y'$ value. Let us investigate the difference in their horizontal position during the tracking:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c9ab0ac-a81d-488a-bd56-387d949db3cc",
"metadata": {},
"outputs": [],
"source": [
"plt.plot(np.abs(rec_x[:,0] - rec_x[:,-1]))\n",
"plt.yscale('log')\n",
"plt.xlabel('Turns')\n",
"plt.ylabel(r'$|\\Delta x|$')"
]
},
{
"cell_type": "markdown",
"id": "622c588f-aa4b-4333-a9b3-e2f93aaba518",
"metadata": {},
"source": [
"$\\implies$ for finite sextupole strength, we observe on average an exponential increase. This points to a finite positive maximum Lyapunov exponent, which is an early indicator of deterministic chaos.\n",
"\n",
"All in all, the thin sextupole magnet in the lattice\n",
"- provides a non-linearity in the potential which the particles see\n",
"- distorts the regular motion in phase-space\n",
"- leads to a change of the (linear) amplitude in phase space\n",
"- provides deterministic chaos, in particular at larger amplitudes (positive Lyapunov exponent!)"
]
},
{
"cell_type": "markdown",
"id": "e10b9110-3c8c-40e2-8087-9676ca171b4f",
"metadata": {},
"source": [
"$\\implies$ repeat this exercise with a zero sextupole strength $m=0$ to confirm these insights for yourself!\n",
"\n",
"Hint: in order to observe a meaningful result in the last plot, add a factor `* 1.001` to `xp` for the last particle to see an effect. Due to the absent coupling between $x$ and $y$, there will be no difference in the $x$ motion of both particles without the sextupole!"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "86f36f7c-b066-42c2-acc7-7e62db426ec3",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.20"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
%% Cell type:markdown id:incomplete-medline tags:
<h1style="text-align: center; vertical-align: middle;">Numerical Methods in Accelerator Physics</h1>
What about the vertical plane now? The quadrupoles have their function inverted, a horizontally focusing quadrupole defocuses in the vertical plane, so the same lattice looks like "D-O-F-O" with respect to the vertical plane:
$\implies$ can ensure quasi-harmonic motion in both (!) transverse planes! Transverse confinement of beam by alternating-gradient (AG) focusing! This is the principle behind synchrotrons!
How does this look like over long time scales? Let us build the one-cell matrix and track for many cells:
$\implies$ we find one $|\lambda|>1$! If one absolute eigenvalue becomes larger than unity, the magnet configuration becomes unstable! That explains the instability (exponential divergence) here! Equivalently one finds $|\mathrm{Tr}(\mathcal{M})|>2$:
<h3>6. Simulating a FODO cell with a sextupole:</h3>
We go back to the stable FODO cell configuration and add a thin sextupole magnet after 1/4 of the lattice, between the first focusing and the second defocusing quadrupole!
The sextupole kick provides a non-linearity in the potential that confines the particles. At large enough amplitude, the non-linear term dominates the particles are no longer bound / confined!
We need to track in 4D phase-space (full transverse plane with both x and y), as the sextupole provides coupling terms:
We need a first matrix 1/4 of the cell until the sextupole, one for the $x$ (`M_cell_x_1`) and another one for the $y$ plane (`M_cell_y_1`). Then a second matrix each to track $x$ and $y$ for the remaining 3/4 of the cell (`M_cell_x_2`, `M_cell_y_2`):
$\implies$ distorted regular motion (see the asymmetry between positive and negative $x$ values in the oscillation), the particle is still bound but the sextupole deforms the phase-space topology from the regular circles we observed for purely linear tracking.
Remember, the last particle was just a copy from the first particle with a slightly increased $y'$ value. Let us investigate the difference in their horizontal position during the tracking:
$\implies$ for finite sextupole strength, we observe on average an exponential increase. This points to a finite positive maximum Lyapunov exponent, which is an early indicator of deterministic chaos.
All in all, the thin sextupole magnet in the lattice
- provides a non-linearity in the potential which the particles see
- distorts the regular motion in phase-space
- leads to a change of the (linear) amplitude in phase space
- provides deterministic chaos, in particular at larger amplitudes (positive Lyapunov exponent!)
$\implies$ repeat this exercise with a zero sextupole strength $m=0$ to confirm these insights for yourself!
Hint: in order to observe a meaningful result in the last plot, add a factor `* 1.001` to `xp` for the last particle to see an effect. Due to the absent coupling between $x$ and $y$, there will be no difference in the $x$ motion of both particles without the sextupole!