"The `longitudinal_tomograpy` package is developed at CERN: control room apps tomographically reconstruct the longitudinal phase-space distribution from bunch profile measurements!"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8b7a23b9-4a4c-4ece-896a-61fed6f32ded",
"metadata": {},
"outputs": [],
"source": [
"import longitudinal_tomography.tomography.tomography as tmo\n",
"Consider a circulating bunch in a synchrotron or storage ring. Longitudinal bunch profiles can be recorded via wall current monitor with a high-bandwidth oscilloscope: store $V_\\mathrm{gap}(t)$ during the bunch passage time $t$.\n",
"\n",
"<h3>Physical Beam Parameters</h3>\n",
"\n",
"During previous lectures we discussed reduced models for the longitudinal plane. We have\n",
"- `voltage`: rf voltage\n",
"- `harmonic`: rf frequency divided by revolution frequency\n",
"- `circumference`: accelerator ring circumference\n",
"- `gamma`: Lorentz gamma of bunch\n",
"- `alpha_c`: momentum compaction of the ring"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1c168076-fbb7-49f0-a3bc-23fb77c8ecdb",
"metadata": {},
"outputs": [],
"source": [
"voltage = 24e3\n",
"harmonic = 7\n",
"circumference = 100 * 2 * np.pi\n",
"\n",
"gamma = 3.1\n",
"beta = np.sqrt(1 - gamma**-2)\n",
"\n",
"alpha_c = 0.027\n",
"eta = alpha_c - gamma**-2"
]
},
{
"cell_type": "markdown",
"id": "89338727-8ec4-4845-9407-7367a8805a65",
"metadata": {},
"source": [
"We look at a circuating proton bunch in a CERN Proton Synchrotron like machine. A \"full bunch length\" of $B_L = 180$ns translates to an rms bunch length in meters of $\\sigma_z=B_L/4\\cdot\\beta c$. As before, the following `PyHEADTAIL` `RFBucket` class captures most of the important quantities for computation."
"A single bin of the profile measurement amounts to a time (in seconds) of"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dc8747e8-cd7b-4c1f-8bdc-ab97ff806a88",
"metadata": {},
"outputs": [],
"source": [
"dtbin = (z_bins[1] - z_bins[0]) / (beta * c)\n",
"dtbin"
]
},
{
"cell_type": "markdown",
"id": "322e852e-5fe7-4411-a035-e6cc40dca5b8",
"metadata": {},
"source": [
"The synchrotron period `T_s`, i.e. the time period of the longitudinal motion, amounts to the following number of turns:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5db3c2ac-8bcb-4ba2-8a6a-159ceb7de70d",
"metadata": {},
"outputs": [],
"source": [
"T_s = int(1 / rfb.Q_s)\n",
"T_s"
]
},
{
"cell_type": "markdown",
"id": "a67c605b-725f-4339-a39c-06ecd58ead0f",
"metadata": {},
"source": [
"<h4>Deliberate mismatch</h4>\n",
"\n",
"To provide some interesting dynamics for the tomographic reconstruction, let's mismatch the distribution in momentum. This will launch a quadrupolar oscillation, i.e. the bunch length and momentum spread will oscillate during the synchrotron period."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2687813-e761-4571-9ee7-4a4730c9d581",
"metadata": {},
"outputs": [],
"source": [
"dp *= 0.3"
]
},
{
"cell_type": "markdown",
"id": "4bad2836-9110-4f0f-bbe6-40451b9e8f74",
"metadata": {},
"source": [
"As one can see, the distribution does not follow the iso-Hamiltonian lines (red) any longer but is slightly compressed along the momentum $\\delta$ axis:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ba4eea27-7fa8-4ad0-aebc-dafd4275cd23",
"metadata": {},
"outputs": [],
"source": [
"plot_mp(z, dp, rfb);"
]
},
{
"cell_type": "markdown",
"id": "5181b045-3d9a-4266-aec7-3798b43505c9",
"metadata": {},
"source": [
"<h4>Particle Tracking</h4>\n",
"\n",
"We model the synchrotron motion of the particles due to the rf cavities once more via a second order leap-frog integrator. The `track` function advances the particles by one turn:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "505d1c30-2a1d-48dd-9714-c5e7f1325bb5",
"metadata": {},
"outputs": [],
"source": [
"def track(z, dp, rfb=rfb):\n",
" # half drift\n",
" z = z - eta * dp * circumference / 2\n",
" # rf kick\n",
" amplitude = rfb.charge * voltage / (beta * c * rfb.p0)\n",
"Let's gather the data for the tomographic reconstruction by recording a bunch profile every few turns during one `T_s`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "db897c47-ae66-4dfb-97c8-2bc7680f9efc",
"metadata": {},
"outputs": [],
"source": [
"record_every_nturns = 10"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9d2d43f6-e358-4050-8fd6-6806ed1773f4",
"metadata": {},
"outputs": [],
"source": [
"raw_data = [np.histogram(z, bins=z_bins)[0]]\n",
"\n",
"for i in tnrange(1, T_s + 1):\n",
" z, dp = track(z, dp)\n",
" if not i % record_every_nturns:\n",
" # the discrete WCW measurement:\n",
" raw_data += [np.histogram(z, bins=z_bins)[0]]"
]
},
{
"cell_type": "markdown",
"id": "6866540e-3289-4117-83d2-52f8fa0bd58a",
"metadata": {},
"source": [
"The quadrupole oscillation is clearly visible:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "13d4c0ad-c2bf-49d5-acde-da11290dae65",
"metadata": {},
"outputs": [],
"source": [
"plt.imshow(raw_data)\n",
"plt.xlabel('Profile bin')\n",
"plt.ylabel('#Profile')\n",
"plt.colorbar(label='Density');"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "be6d3b02-a46a-498b-96b6-1822da1e7d00",
"metadata": {},
"outputs": [],
"source": [
"std=[np.sqrt(np.average((np.array((z_bins[:-1]+z_bins[1:])/2) - np.average(np.array((z_bins[:-1]+z_bins[1:])/2),weights=raw_data[i]))**2, weights=raw_data[i])) for i in range(len(raw_data))]\n",
"Here is the full reconstructed phase-space distribution:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f6f8ce0-1b2a-4091-ba3e-310dc6306269",
"metadata": {},
"outputs": [],
"source": [
"plot_tomo(phasespace, z_rec, dp_rec, rfb);"
]
},
{
"cell_type": "markdown",
"id": "da897b01-ba2b-490f-9327-e035356cb45e",
"metadata": {},
"source": [
"$\\implies$ Does this fit the initial macro-particle distribution?\n",
"\n",
"$\\implies$ Re-run the tomographic reconstruction for the last profile (see settings part above, start from section B.)! Does it match the final macro-particle distribution?"
]
},
{
"cell_type": "markdown",
"id": "3e9f525c-fd4e-407a-b279-b74d0df58f0f",
"metadata": {},
"source": [
"The final macro-particle phase-space distribution after the simulation:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9bfba1ed-218b-4de8-9e46-64de032b6a50",
"metadata": {},
"outputs": [],
"source": [
"plot_mp(z, dp, rfb);"
]
}
],
"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>
The `longitudinal_tomograpy` package is developed at CERN: control room apps tomographically reconstruct the longitudinal phase-space distribution from bunch profile measurements!
Consider a circulating bunch in a synchrotron or storage ring. Longitudinal bunch profiles can be recorded via wall current monitor with a high-bandwidth oscilloscope: store $V_\mathrm{gap}(t)$ during the bunch passage time $t$.
<h3>Physical Beam Parameters</h3>
During previous lectures we discussed reduced models for the longitudinal plane. We have
-`voltage`: rf voltage
-`harmonic`: rf frequency divided by revolution frequency
We look at a circuating proton bunch in a CERN Proton Synchrotron like machine. A "full bunch length" of $B_L = 180$ns translates to an rms bunch length in meters of $\sigma_z=B_L/4\cdot\beta c$. As before, the following `PyHEADTAIL``RFBucket` class captures most of the important quantities for computation.
To provide some interesting dynamics for the tomographic reconstruction, let's mismatch the distribution in momentum. This will launch a quadrupolar oscillation, i.e. the bunch length and momentum spread will oscillate during the synchrotron period.
As one can see, the distribution does not follow the iso-Hamiltonian lines (red) any longer but is slightly compressed along the momentum $\delta$ axis:
We model the synchrotron motion of the particles due to the rf cavities once more via a second order leap-frog integrator. The `track` function advances the particles by one turn:
$\implies$ Does this fit the initial macro-particle distribution?
$\implies$ Re-run the tomographic reconstruction for the last profile (see settings part above, start from section B.)! Does it match the final macro-particle distribution?