Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
mbtrack2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PA
Collective Effects
mbtrack2
Commits
6e4dba64
Commit
6e4dba64
authored
4 years ago
by
Watanyu Foosang
Browse files
Options
Downloads
Patches
Plain Diff
Update SynchrotronRadiation and add SkewQuadrupole
parent
00233cc9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tracking/__init__.py
+2
-1
2 additions, 1 deletion
tracking/__init__.py
tracking/element.py
+49
-36
49 additions, 36 deletions
tracking/element.py
with
51 additions
and
37 deletions
tracking/__init__.py
+
2
−
1
View file @
6e4dba64
...
...
@@ -12,7 +12,8 @@ from mbtrack2.tracking.rf import RFCavity, CavityResonator
from
mbtrack2.tracking.parallel
import
Mpi
from
mbtrack2.tracking.optics
import
Optics
,
PhyisicalModel
from
mbtrack2.tracking.element
import
(
Element
,
LongitudinalMap
,
TransverseMap
,
SynchrotronRadiation
)
TransverseMap
,
SynchrotronRadiation
,
SkewQuadrupole
)
from
mbtrack2.tracking.aperture
import
(
CircularAperture
,
ElipticalAperture
,
RectangularAperture
)
from
mbtrack2.tracking.wakepotential
import
WakePotential
...
...
This diff is collapsed.
Click to expand it.
tracking/element.py
+
49
−
36
View file @
6e4dba64
...
...
@@ -125,44 +125,18 @@ class SynchrotronRadiation(Element):
if
(
self
.
switch
[
0
]
==
True
):
rand
=
np
.
random
.
normal
(
size
=
len
(
bunch
))
bunch
[
"
delta
"
]
=
((
1
-
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
2
])
*
bunch
[
"
delta
"
]
+
2
*
self
.
ring
.
sigma_delta
*
(
self
.
ring
.
T0
/
self
.
ring
.
tau
[
2
])
**
0.5
*
rand
)
2
*
self
.
ring
.
sigma_delta
*
(
self
.
ring
.
T0
/
self
.
ring
.
tau
[
2
])
**
0.5
*
rand
)
if
(
self
.
switch
[
1
]
==
True
):
rand
=
np
.
random
.
normal
(
size
=
(
len
(
bunch
),
2
))
bunch
[
"
x
"
]
+=
self
.
ring
.
sigma
()[
0
]
*
(
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
0
])
**
0.5
*
rand
[:,
0
]
bunch
[
"
xp
"
]
=
(
1
+
bunch
[
"
delta
"
])
/
(
1
+
bunch
[
"
delta
"
]
+
bunch
.
energy_change
)
*
bunch
[
"
xp
"
]
bunch
[
"
xp
"
]
+=
self
.
ring
.
sigma
()[
1
]
*
(
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
0
])
**
0.5
*
rand
[:,
1
]
rand
=
np
.
random
.
normal
(
size
=
len
(
bunch
))
bunch
[
"
xp
"
]
=
((
1
-
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
0
])
*
bunch
[
"
xp
"
]
+
2
*
self
.
ring
.
sigma
()[
1
]
*
(
self
.
ring
.
T0
/
self
.
ring
.
tau
[
0
])
**
0.5
*
rand
)
if
(
self
.
switch
[
2
]
==
True
):
rand
=
np
.
random
.
normal
(
size
=
(
len
(
bunch
),
2
))
bunch
[
"
y
"
]
+=
self
.
ring
.
sigma
()[
2
]
*
(
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
1
])
**
0.5
*
rand
[:,
0
]
bunch
[
"
yp
"
]
=
(
1
+
bunch
[
"
delta
"
])
/
(
1
+
bunch
[
"
delta
"
]
+
bunch
.
energy_change
)
*
bunch
[
"
yp
"
]
bunch
[
"
yp
"
]
+=
self
.
ring
.
sigma
()[
3
]
*
(
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
1
])
**
0.5
*
rand
[:,
1
]
# Reset energy change to 0 for next turn
bunch
.
energy_change
=
0
#--------------------------------------
# if (self.switch[0] == True):
# rand = np.random.normal(size=len(bunch))
# bunch["delta"] = ((1 - 2*self.ring.T0/self.ring.tau[2])*bunch["delta"] +
# 2*self.ring.sigma_delta*(self.ring.T0/self.ring.tau[2])**0.5*rand)
# if (self.switch[1] == True):
# rand = np.random.normal(size=(len(bunch),2))
# bunch["x"] += self.ring.sigma[0]*(2*self.ring.T0/self.ring.tau[0])**0.5*rand[:,0]
# bunch["xp"] = (1 + bunch["delta"])/(1 + bunch["delta"] + bunch.energy_change)*bunch["xp"]
# bunch["xp"] += self.ring.sigma[1]*(2*self.ring.T0/self.ring.tau[0])**0.5*rand[:,1]
# if (self.switch[2] == True):
# rand = np.random.normal(size=(len(bunch),2))
# bunch["y"] += self.ring.sigma[2]*(2*self.ring.T0/self.ring.tau[1])**0.5*rand[:,0]
# bunch["yp"] = (1 + bunch["delta"])/(1 + bunch["delta"] + bunch.energy_change)*bunch["yp"]
# bunch["yp"] += self.ring.sigma[3]*(2*self.ring.T0/self.ring.tau[1])**0.5*rand[:,1]
# # Reset energy change to 0 for next turn
# bunch.energy_change = 0
#----------------------------------------
rand
=
np
.
random
.
normal
(
size
=
len
(
bunch
))
bunch
[
"
yp
"
]
=
((
1
-
2
*
self
.
ring
.
T0
/
self
.
ring
.
tau
[
1
])
*
bunch
[
"
yp
"
]
+
2
*
self
.
ring
.
sigma
()[
1
]
*
(
self
.
ring
.
T0
/
self
.
ring
.
tau
[
1
])
**
0.5
*
rand
)
class
TransverseMap
(
Element
):
"""
Transverse map for a single turn in the synchrotron.
...
...
@@ -226,3 +200,42 @@ class TransverseMap(Element):
bunch
[
"
xp
"
]
=
xp
bunch
[
"
y
"
]
=
y
bunch
[
"
yp
"
]
=
yp
class
SkewQuadrupole
:
"""
Skew quadrupole element used to introduce betatron coupling. The length of
the quadrupole is neglected.
Parameters
----------
strength : float
Integrated strength of the skew quadrupole [m].
"""
def
__init__
(
self
,
strength
):
self
.
strength
=
strength
@Element.parallel
def
track
(
self
,
bunch
):
"""
Tracking method for the element.
No bunch to bunch interaction, so written for Bunch objects and
@Element.parallel is used to handle Beam objects.
Parameters
----------
bunch : Bunch or Beam object
"""
matrix
=
np
.
zeros
((
4
,
4
,
len
(
bunch
)))
matrix
[
0
,
0
,:]
=
1
matrix
[
1
,
1
,:]
=
1
matrix
[
2
,
2
,:]
=
1
matrix
[
3
,
3
,:]
=
1
matrix
[
1
,
2
,:]
=
-
1
*
self
.
strength
matrix
[
3
,
0
,:]
=
-
1
*
self
.
strength
xp
=
bunch
[
'
xp
'
]
+
matrix
[
1
,
2
,:]
*
bunch
[
'
y
'
]
yp
=
bunch
[
'
yp
'
]
+
matrix
[
3
,
0
,:]
*
bunch
[
'
x
'
]
bunch
[
'
xp
'
]
=
xp
bunch
[
'
yp
'
]
=
yp
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment