Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pyatsoleiloutils
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
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Optics
pyatsoleiloutils
Commits
92612ca8
Commit
92612ca8
authored
1 year ago
by
BLANCO-GARCIA
Browse files
Options
Downloads
Patches
Plain Diff
add lifetime and momentum aperture
parent
fd48effe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyatsoleiloutils/ltandmomap.py
+89
-0
89 additions, 0 deletions
pyatsoleiloutils/ltandmomap.py
with
89 additions
and
0 deletions
pyatsoleiloutils/ltandmomap.py
0 → 100644
+
89
−
0
View file @
92612ca8
"""
This file contains functions to calculate de momentum aperture
and lifetime of a ring
"""
import
numpy
import
scipy
import
at
import
h5py
from
.pyatsoleiloutils
import
savemomaphdf5
from
.pyatsoleiloutils
import
readmomaphdf5
__all__
=
[
'
gettouscheklt_SOLEIL_II
'
,
'
getmomap_SOLEIL_II
'
]
def
getmomaphdf5_SOLEIL_II
(
ring
,
foutn
=
'
momap.hdf5
'
):
"""
This function calculates the momentum aperture of a ring
and saves the result in a hdf5 file
"""
dpb
,
s_indexes
,
s_array
=
getmomap_SOLEIL_II
(
ring
)
savemomaphdf5
(
foutn
,
dpb
,
s_indexes
,
s_array
)
def
getmomap_SOLEIL_II
(
ring
):
"""
This function calculates the momentum aperture of a ring
"""
# check the s coordinate along the machine
s_list
=
at
.
get_s_pos
(
ring
,
range
(
len
(
ring
)))
#print(f'{len(ring)=}')
# choose unique s
refpts
=
numpy
.
arange
(
len
(
ring
))
mask
=
[
ring
[
r
].
Length
>
0.0
for
r
in
refpts
]
refpts
=
refpts
[
mask
]
# get momentum aperture
s_indexes
=
refpts
s_array
=
at
.
get_s_pos
(
ring
,
s_indexes
)
dp_boundary
,
_
,
_
=
at
.
get_momentum_acceptance
(
ring
,
resolution
=
0.5e-3
,
amplitude
=
0.10
,
nturns
=
512
,
grid_mode
=
at
.
GridMode
(
1
),
refpts
=
s_indexes
,
use_mp
=
True
,
verbose
=
True
,
divider
=
2
)
return
dp_boundary
,
s_indexes
,
s_array
def
gettouscheklt_SOLEIL_II
(
ring
,
beammode
=
'
TDR
'
,
finname
=
None
):
"""
This function calculates the Touschek lifetime of a ring
using a list of beam parameters
"""
beam_par
=
at
.
envelope_parameters
(
ring
)
ex
=
beam_par
.
emittances
[
0
]
nbunches
=
416
i_firstmode
=
500e-3
#[A]
if
beammode
==
'
TDR
'
:
ey
=
0.3
*
ex
# SOLEIL II TDR emittance
else
:
# 50% of emmittance on each plane
ey
=
0.5
*
ex
ex
=
ey
if
finnanme
==
None
:
momap_pn
,
s_indexes
,
s_array
=
getmomap_SOLEIL_II
(
ring
)
else
:
momap_pn
,
s_indexes
,
s_array
=
readmomaphdf5
(
momapfile
)
# get touschek lifetime
lt_tou
,
_
,
_
=
at
.
touschek
.
get_lifetime
(
ring
,
ey
,
i_firstmode
/
nbunches
,
emitx
=
ex
,
sigs
=
beam_par
.
sigma_l
,
sigp
=
beam_par
.
sigma_e
,
momap
=
momap_pn
,
refpts
=
s_indexes
)
return
lt_tou
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