Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyat
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dt
exercises
pyat
Commits
1105a60b
Commit
1105a60b
authored
2 months ago
by
Claudio Scafuri
Browse files
Options
Downloads
Patches
Plain Diff
added
parent
53ab1dd5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
elettra2track.py
+47
-0
47 additions, 0 deletions
elettra2track.py
shiftrotate.py
+77
-0
77 additions, 0 deletions
shiftrotate.py
with
124 additions
and
0 deletions
elettra2track.py
0 → 100755
+
47
−
0
View file @
1105a60b
#!/usr/bin/python3
import
os
import
at
import
matplotlib.pylab
as
mp
import
numpy
as
np
lattfile
=
"
~/src/gitlab/dt/machine/lattice/elettra2/srElettra2_9_4_beta.mat
"
#lattfile = "~/src/gitlab/dt/machine/lattice/elettra2/srElettra2_9_4_beta_test_digital_twins.mat"
#lattfile = "~/esrf_visit/last.mat"
lattfile
=
os
.
path
.
expanduser
(
lattfile
)
ring
=
at
.
load_lattice
(
lattfile
,
energy
=
2.4e9
)
refpts
=
range
(
len
(
ring
)
+
1
)
ring
.
radiation_off
()
elemdata0
,
ringdata
,
elemdata
=
at
.
linopt6
(
ring
,
refpts
,
0.00
)
[
chromH
,
chromV
]
=
ring
.
get_chrom
()
[
tuneH
,
tuneV
]
=
ring
.
get_tune
()
s_pos
=
elemdata
[
'
s_pos
'
]
#--- lionop needs radiation off
ring
.
radiation_on
()
ring
.
rf_voltage
=
2e6
#elemdata0, tune, chrom, elemdata=at.linopt(ring,refpts)
incoord
=
np
.
array
([
0.0001
,
0.00
,
0.0002
,
0.0
,
0.0
,
0.0
])
mrefpts
=
[
3
]
nt
=
10000
coord
=
at
.
lattice_pass
(
ring
,
incoord
,
nt
,
mrefpts
)
h_traj
=
coord
[
0
,
0
,
:,
:]
# get X
v_traj
=
coord
[
3
,
0
,
:,
:]
# get Y
plotbase
=
(
np
.
array
([
np
.
arange
(
0
,
nt
)]))
mp
.
figure
()
mp
.
plot
(
plotbase
,
h_traj
,
'
.
'
)
mp
.
xlabel
(
'
n
'
)
mp
.
ylabel
(
'
x
'
)
mp
.
title
(
'
traj_x
'
)
mp
.
figure
()
mp
.
plot
(
plotbase
,
v_traj
,
'
.
'
)
mp
.
xlabel
(
'
n
'
)
mp
.
ylabel
(
'
y
'
)
mp
.
title
(
'
traj_y
'
)
mp
.
xlabel
(
'
s [m]
'
)
mp
.
ylabel
(
'
m
'
)
mp
.
title
(
'
traj_x
'
)
mp
.
show
()
This diff is collapsed.
Click to expand it.
shiftrotate.py
0 → 100755
+
77
−
0
View file @
1105a60b
#!/usr/bin/python3
import
at
import
math
#--------- test shift ---------------
#function for extracting shift elemnts that is alignemnt errors
def
get_elem_shift
(
elem
):
#if thre is no T1 and T2????
dx2
=
elem
.
T2
[
0
]
dy2
=
elem
.
T2
[
2
]
dx1
=
elem
.
T1
[
0
]
dy1
=
elem
.
T1
[
2
]
#check coherency
if
dx1
+
dx2
!=
0.0
or
dy1
+
dy2
!=
0.0
:
print
(
elem
.
FamName
,
"
incoherent T1 and T2 vectors
"
)
return
dx2
,
dy2
QF
=
at
.
Quadrupole
(
'
QF:
'
,
1.0
,
0.2
)
#create a Quadrupole
dx
=
0.1
# horizontal shift [m] positive to the left
dy
=
0.2
# vertical shift [m] positive up
at
.
shift_elem
(
QF
,
dx
,
dy
,
relative
=
False
)
#use absolute shift
# now check T1 and T2 matrices
t1
=
QF
.
T1
t2
=
QF
.
T2
print
(
"
T1
"
,
t1
)
print
(
"
T2
"
,
t2
)
print
(
t1
[
0
],
t1
[
2
])
print
(
t2
[
0
],
t2
[
2
])
a
,
b
=
get_elem_shift
(
QF
)
print
(
"
dx
"
,
a
,
"
dy
"
,
b
)
QF
.
T1
[
2
]
*=
0.00001
a2
,
b2
=
get_elem_shift
(
QF
)
print
(
"
dx
"
,
a2
,
"
dy
"
,
b2
)
at
.
shift_elem
(
QF
,
0.0
,
0.0
,
relative
=
False
)
a3
,
b3
=
get_elem_shift
(
QF
)
#----------- test rotations -------------------------
print
(
"
rotations
"
)
SD
=
at
.
Sextupole
(
'
SD
'
,
1.0
,
0.2
)
#create a Quadrupole
at
.
shift_elem
(
SD
,
0
,
0
)
a
,
b
=
get_elem_shift
(
SD
)
#print("dx",a,"dy",b)
tilt
=
math
.
asin
(
0.01
)
# rotation around s-axis
pitch
=
math
.
asin
(
0.02
)
# rotation around x-axis
yaw
=
math
.
asin
(
0.03
)
# rotation around y-axis
at
.
rotate_elem
(
SD
,
tilt
,
pitch
,
yaw
,
relative
=
False
)
a2
,
b2
=
get_elem_shift
(
SD
)
print
(
"
dx
"
,
a2
,
"
dy
"
,
b2
)
# ALAERT: rotations modify also T1 and T2 that is shift! Where is the rotation centre???? NOT CLEAR
This diff is collapsed.
Click to expand it.
Preview
0%
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