Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
PythonControl
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PA
Operation
PythonControl
Commits
54f1dba2
Commit
54f1dba2
authored
Jun 1, 2023
by
Alexis GAMELIN
Browse files
Options
Downloads
Patches
Plain Diff
Add uniform beam injection functions
To be tested ...
parent
b7631748
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
__init__.py
+14
-0
14 additions, 0 deletions
__init__.py
injection.py
+103
-4
103 additions, 4 deletions
injection.py
with
117 additions
and
4 deletions
__init__.py
0 → 100644
+
14
−
0
View file @
54f1dba2
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 1 12:21:40 2023
@author: gamelina
"""
from
injection
import
(
get_linac_table
,
get_extraction_table
,
switch_injection_mode
,
set_injection
,
inject_beam
,
inject_uniform_beam
,
SPM_feedback
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
injection.py
+
103
−
4
View file @
54f1dba2
...
@@ -129,15 +129,114 @@ def inject_beam(booster_cav):
...
@@ -129,15 +129,114 @@ def inject_beam(booster_cav):
else
:
else
:
raise
ValueError
(
"
booster_cav must be 1 or 2.
"
)
raise
ValueError
(
"
booster_cav must be 1 or 2.
"
)
topup
=
DeviceProxy
(
"
boo/ae/pstopupmodemanager
"
)
boo_ps
=
DeviceProxy
(
"
boo/ae/pstopupmodemanager
"
)
central
=
DeviceProxy
(
"
ANS/SY/CENTRAL
"
)
central
=
DeviceProxy
(
"
ANS/SY/CENTRAL
"
)
counter
=
0
if
cav_booster
.
state
()
is
DevState
.
ON
:
if
cav_booster
.
state
()
is
DevState
.
ON
:
if
rampe
.
state
()
is
not
DevState
.
RUNNING
:
if
rampe
.
state
()
is
not
DevState
.
RUNNING
:
rampe
.
start
()
rampe
.
start
()
# Booster RF ramping
time
.
sleep
(
1
)
time
.
sleep
(
1
)
topup
.
nominal
()
boo_ps
.
nominal
()
# Booster power supply ramping
time
.
sleep
(
5
)
time
.
sleep
(
5
)
while
(
central
.
state
()
!=
DevState
.
ON
):
counter
+=
1
time
.
sleep
(
0.1
)
if
counter
==
100
:
raise
ValueError
(
"
Central state is not ON for more than 10s.
"
)
central
.
fireburstevent
()
central
.
fireburstevent
()
else
:
else
:
raise
ValueError
(
"
Booster cavity state is not ON.
"
)
raise
ValueError
(
"
Booster cavity state is not ON.
"
)
def
inject_uniform_beam
(
goal_current
,
booster_cav
,
fine_delay
):
"""
Inject
"
uniform
"
filling pattern by rotating the LPM injection bucket by 8
bucket at each injection.
Parameters
----------
goal_current : float
Total beam current to reach in [mA].
booster_cav : int
Booster cavity number to be used.
fine_delay : float
Fine delay in [s].
"""
dcct
=
DeviceProxy
(
"
ANS/DG/DCCT-CTRL
"
)
rendement
=
DeviceProxy
(
"
ANS/DG/RENDEMENT
"
)
eff_booster
=
np
.
ones
((
10
,))
*
100
eff_sr
=
np
.
ones
((
10
,))
*
100
count
=
0
while
dcct
.
current
<
goal_current
:
bucket_list
=
(
1
+
count
*
8
)
%
416
set_injection
(
"
LPM
"
,
bucket_list
,
fine_delay
)
inject_beam
(
booster_cav
)
time
.
sleep
(
0.5
)
eff_sr
[
0
]
=
rendement
.
efficiencyANS_LPM_avg
eff_booster
[
0
]
=
rendement
.
efficiencyBOO_LPM_avg
if
np
.
mean
(
eff_booster
)
<
40
:
raise
ValueError
(
"
Injection efficiency in booster is too low.
"
)
if
np
.
mean
(
eff_booster
)
<
40
:
raise
ValueError
(
"
Injection efficiency in storage ring is too low.
"
)
eff_booster
=
np
.
roll
(
eff_booster
,
1
)
eff_sr
=
np
.
roll
(
eff_sr
,
1
)
count
+=
1
def
SPM_feedback
(
goal_current
,
booster_cav
,
fine_delay
,
max_fill
=
10
):
"""
SPM injection feedback to try to correct a more uniform filling pattern.
Parameters
----------
goal_current : float
Total beam current to reach in [mA].
booster_cav : int
Booster cavity number to be used.
fine_delay : float
Fine delay in [s].
max_fill : int, optional
Maximum number of bucket to fill in a single FB iteration.
The default is 10.
"""
dcct
=
DeviceProxy
(
"
ANS/DG/DCCT-CTRL
"
)
rendement
=
DeviceProxy
(
"
ANS/DG/RENDEMENT
"
)
remplissage
=
DeviceProxy
(
"
ANS/DG/REMPLISSAGE
"
)
eff_booster
=
np
.
ones
((
10
,))
*
100
eff_sr
=
np
.
ones
((
10
,))
*
100
fill
=
remplissage
.
bunchesCurrent
h
=
416
goal_per_bunch
=
goal_current
/
h
while
True
:
if
dcct
.
current
<
goal_current
:
fill
=
remplissage
.
bunchesCurrent
idx
=
np
.
argsort
(
fill
)
idx
=
idx
[:
max_fill
]
to_fill
=
fill
[
idx
]
<
goal_per_bunch
bucket_list
=
idx
[
to_fill
]
+
1
print
(
f
"
Injecting in buckets:
{
bucket_list
}
"
)
print
(
f
"
With current per bunch:
{
fill
[
idx
[
to_fill
]]
}
"
)
set_injection
(
"
SPM
"
,
bucket_list
,
fine_delay
)
inject_beam
(
booster_cav
)
time
.
sleep
(
0.5
)
eff_sr
[
0
]
=
rendement
.
efficiencyANS_LPM_avg
eff_booster
[
0
]
=
rendement
.
efficiencyBOO_LPM_avg
if
np
.
mean
(
eff_booster
)
<
40
:
raise
ValueError
(
"
Injection efficiency in booster is too low.
"
)
if
np
.
mean
(
eff_booster
)
<
40
:
raise
ValueError
(
"
Injection efficiency in storage ring is too low.
"
)
eff_booster
=
np
.
roll
(
eff_booster
,
1
)
eff_sr
=
np
.
roll
(
eff_sr
,
1
)
else
:
time
.
sleep
(
5
)
\ No newline at end of file
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