A bug in elegant2astra was reported by Piotr Traczykowski (Univ. Strathclyde). The conversion of time coordinate (used by elegant) to dz (used by ASTRA) was incorrect by the factor beta/betaz. The corrected verison of the script is attached.
--Michael
elegant2astra bug
Moderators: michael_borland, soliday
-
- Posts: 1959
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
elegant2astra bug
- Attachments
-
- elegant2astra.gz
- (893 Bytes) Downloaded 664 times
Re: elegant2astra bug
Hi Michael,
I am reading the elegant2astra csh scripts, I am confused about the calculation of betaz in line 35 and z in line 36. Why betaz=pz/sqrt(px^2+py^2+pz^2) ? According to this definition, betaz=vz/v (not vz/c). I searched the forum, you said that "ASTRA is a snapshot of the beam at a fixed time rather than a record of particle coordinates crossing a fixed z plane." Is this the reason that causes such differences?
And also I am confused about the calculation of x and y in line 44 and 45, x_astra = x_elegant + dz * xp, it means that x_astra = x_elegant + dz * px/pz. why?
Best,
Biaobin
I am reading the elegant2astra csh scripts, I am confused about the calculation of betaz in line 35 and z in line 36. Why betaz=pz/sqrt(px^2+py^2+pz^2) ? According to this definition, betaz=vz/v (not vz/c). I searched the forum, you said that "ASTRA is a snapshot of the beam at a fixed time rather than a record of particle coordinates crossing a fixed z plane." Is this the reason that causes such differences?
And also I am confused about the calculation of x and y in line 44 and 45, x_astra = x_elegant + dz * xp, it means that x_astra = x_elegant + dz * px/pz. why?
Best,
Biaobin
-
- Posts: 1959
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: elegant2astra bug
Biaobin,
You are correct that there is a bug. Line 35 should be changed from
to
That is, betaz = pz/gamma. For highly relativistic particles it won't make any difference.
As for your second question px/pz = vx/vz = (dx/dt)/(dz/dt) = dx/dz, which is why we use that expression.
I've attached a corrected version of the script. Thanks for reporting the bug.
--Michael
You are correct that there is a bug. Line 35 should be changed from
Code: Select all
"-define=column,betaz,pz px sqr py sqr + pz sqr + sqrt /"
Code: Select all
"-define=column,betaz,pz px sqr py sqr + pz sqr + 1 + sqrt /"
As for your second question px/pz = vx/vz = (dx/dt)/(dz/dt) = dx/dz, which is why we use that expression.
I've attached a corrected version of the script. Thanks for reporting the bug.
--Michael
- Attachments
-
- update.zip
- (1.01 KiB) Downloaded 285 times
Re: elegant2astra bug
Hi Michael,
Sorry for misleading you, I think the initial one is right. I think I understand it now.
betaz = vz/c = (m vz)/(mc) = pz/(mv * c/v) = (pz/p)*beta.
For highly relativistic particles beta is about 1. So betaz = pz/p, that's what you are using in your code.
And for low energy case, beta = sqrt(gamma^2 —1)/gamma = p / sqrt(p^2 + m0^2 * c^2), where p=sqrt(px^2 + py^2 + pz^2), and m0 is the rest mass. As we often perform the simulation with elegant begins at about 100 MeV to 150 MeV, it is highly relativistic case. Is this the reason that you are using the approximation formula ?
And for the second question, my confusion is that when transfer from elegant to astra, x_astra = x_elegant + dz * dx/dz, why it is not just x_astra = x_elegant ?
Sorry for misleading you, I think the initial one is right. I think I understand it now.
betaz = vz/c = (m vz)/(mc) = pz/(mv * c/v) = (pz/p)*beta.
For highly relativistic particles beta is about 1. So betaz = pz/p, that's what you are using in your code.
And for low energy case, beta = sqrt(gamma^2 —1)/gamma = p / sqrt(p^2 + m0^2 * c^2), where p=sqrt(px^2 + py^2 + pz^2), and m0 is the rest mass. As we often perform the simulation with elegant begins at about 100 MeV to 150 MeV, it is highly relativistic case. Is this the reason that you are using the approximation formula ?
And for the second question, my confusion is that when transfer from elegant to astra, x_astra = x_elegant + dz * dx/dz, why it is not just x_astra = x_elegant ?
-
- Posts: 1959
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: elegant2astra bug
Biaobin,
I think the original version was incorrect for non-relativistic particles:
pz = betaz*gamma, so betaz = pz/gamma = pz/sqrt(px^2+py^2+pz^2+1). Only when p>>1 is betaz = pz/p approximately right.
You are right that elegant2astra was used mostly for highly relativistic particles, so practically speaking it probably doesn't matter.
The reason for the adjustment of x is that ASTRA needs a snapshot of the beam at a particular time (t= constant, z varies), whereas elegant outputs the time at which all particles cross a z plane (z=constant, t varies). Since the particles provided to ASTRA have to have their z coordinates adjusted, the x and y coordinates need to change according to the slopes.
--Michael
I think the original version was incorrect for non-relativistic particles:
pz = betaz*gamma, so betaz = pz/gamma = pz/sqrt(px^2+py^2+pz^2+1). Only when p>>1 is betaz = pz/p approximately right.
You are right that elegant2astra was used mostly for highly relativistic particles, so practically speaking it probably doesn't matter.
The reason for the adjustment of x is that ASTRA needs a snapshot of the beam at a particular time (t= constant, z varies), whereas elegant outputs the time at which all particles cross a z plane (z=constant, t varies). Since the particles provided to ASTRA have to have their z coordinates adjusted, the x and y coordinates need to change according to the slopes.
--Michael
Re: elegant2astra bug
Hi Michael,
Actually we are talking about the same thing, we are using different units.
- (px, py, pz, p) in my previous reply are all in units of [eV/c]
- (px, py, pz, p) in your previous reply are all dimensionless, p = beta*gamma, pz = betaz* gamma
- In the code, (px, py, pz) are in units of [eV/c], (xp, yp, p) are dimensionless, p = beta*gamma
So in order to include the non-relativistic situation, line 35 should be modified as
Actually we are talking about the same thing, we are using different units.
- (px, py, pz, p) in my previous reply are all in units of [eV/c]
- (px, py, pz, p) in your previous reply are all dimensionless, p = beta*gamma, pz = betaz* gamma
- In the code, (px, py, pz) are in units of [eV/c], (xp, yp, p) are dimensionless, p = beta*gamma
So in order to include the non-relativistic situation, line 35 should be modified as
Code: Select all
"-define=column,beta,p p sqr 1 + sqrt /" \
"-define=column,betaz,pz px sqr py sqr + pz sqr + sqrt / beta *" \
-
- Posts: 1959
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: elegant2astra bug
Biaobin,
You are correct. I missed the units issue. Here's the corrected version.
Thanks for your help.
--Michael
You are correct. I missed the units issue. Here's the corrected version.
Thanks for your help.
--Michael
- Attachments
-
- update.zip
- (1.02 KiB) Downloaded 308 times