lhcoptics 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lhcoptics-0/PKG-INFO +14 -0
- lhcoptics-0/README.md +19 -0
- lhcoptics-0/pyproject.toml +16 -0
- lhcoptics-0/setup.cfg +4 -0
- lhcoptics-0/src/lhcoptics/__init__.py +11 -0
- lhcoptics-0/src/lhcoptics/arcs.py +145 -0
- lhcoptics-0/src/lhcoptics/circuits.py +78 -0
- lhcoptics-0/src/lhcoptics/ir1.py +17 -0
- lhcoptics-0/src/lhcoptics/ir2.py +19 -0
- lhcoptics-0/src/lhcoptics/ir3.py +5 -0
- lhcoptics-0/src/lhcoptics/ir4.py +5 -0
- lhcoptics-0/src/lhcoptics/ir5.py +17 -0
- lhcoptics-0/src/lhcoptics/ir6.py +5 -0
- lhcoptics-0/src/lhcoptics/ir7.py +250 -0
- lhcoptics-0/src/lhcoptics/ir8.py +19 -0
- lhcoptics-0/src/lhcoptics/irs.py +171 -0
- lhcoptics-0/src/lhcoptics/knob.py +23 -0
- lhcoptics-0/src/lhcoptics/model_madx.py +371 -0
- lhcoptics-0/src/lhcoptics/model_xsuite.py +138 -0
- lhcoptics-0/src/lhcoptics/optics.py +181 -0
- lhcoptics-0/src/lhcoptics/rdmsignal.py +36 -0
- lhcoptics-0/src/lhcoptics/section.py +174 -0
- lhcoptics-0/src/lhcoptics.egg-info/PKG-INFO +14 -0
- lhcoptics-0/src/lhcoptics.egg-info/SOURCES.txt +25 -0
- lhcoptics-0/src/lhcoptics.egg-info/dependency_links.txt +1 -0
- lhcoptics-0/src/lhcoptics.egg-info/requires.txt +5 -0
- lhcoptics-0/src/lhcoptics.egg-info/top_level.txt +1 -0
lhcoptics-0/PKG-INFO
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: lhcoptics
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Library to build LHC Optics
|
|
5
|
+
Author-email: Riccardo De Maria <riccardodemaria@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: homepage, https://github.com/rdemaria/optics
|
|
8
|
+
Project-URL: repository, https://github.com/ rdemaria/optics
|
|
9
|
+
Keywords: LHC,beam dynamics
|
|
10
|
+
Requires-Dist: numpy
|
|
11
|
+
Requires-Dist: matplotlib
|
|
12
|
+
Requires-Dist: xsuite
|
|
13
|
+
Requires-Dist: pyoptics
|
|
14
|
+
Requires-Dist: cpymad
|
lhcoptics-0/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# lhcoptics
|
|
2
|
+
|
|
3
|
+
Build LHC optics
|
|
4
|
+
|
|
5
|
+
Usage:
|
|
6
|
+
```
|
|
7
|
+
python examples/data/make.py
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
from lhcoptics import LHCOptics
|
|
12
|
+
|
|
13
|
+
inj=LHCOptics.from_json("data/opt_inj.json")
|
|
14
|
+
inj.set_xsuite_model("data/lhc.json") # set an xsuite model
|
|
15
|
+
inj.get_params()
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Currently needs `github.com/rdemaria/xtrack` branch `attr_in_twiss`
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=42", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lhcoptics"
|
|
7
|
+
version = "0.0.0"
|
|
8
|
+
description = "Library to build LHC Optics"
|
|
9
|
+
authors = [{ name = "Riccardo De Maria", email = "riccardodemaria@gmail.com" }]
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
urls = { homepage = "https://github.com/rdemaria/optics", repository = "https://github.com/ rdemaria/optics" }
|
|
12
|
+
keywords = ["LHC", "beam dynamics"]
|
|
13
|
+
dependencies = [ "numpy", "matplotlib", "xsuite", "pyoptics", "cpymad"]
|
|
14
|
+
|
|
15
|
+
[tool.black]
|
|
16
|
+
line-length = 79
|
lhcoptics-0/setup.cfg
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
LHCModel -> Compute twiss, aperture, match
|
|
3
|
+
LHCOptics -> Contains complete optics
|
|
4
|
+
LHCIROptics -> Contains strengths, constraints, knobs
|
|
5
|
+
LHCArcOptics -> Contains strengths, constraints, knobs
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.0.0"
|
|
9
|
+
from .optics import LHCOptics
|
|
10
|
+
from .model_xsuite import LHCXsuiteModel, LHCMadModel
|
|
11
|
+
from .circuits import LHCCircuits
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from .section import LHCSection
|
|
2
|
+
from .model_xsuite import LHCMadModel
|
|
3
|
+
import xtrack as xt
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class LHCArc(LHCSection):
|
|
7
|
+
@classmethod
|
|
8
|
+
def from_madx(cls, madx, name="a12"):
|
|
9
|
+
madmodel = LHCMadModel(madx)
|
|
10
|
+
i1, i2 = int(name[1]), int(name[2])
|
|
11
|
+
strength_names = []
|
|
12
|
+
strength_names += madmodel.filter(f"kq[fd]\.*{name}$")
|
|
13
|
+
strength_names += madmodel.filter(f"kqt[fd]\.*{name}b[12]$")
|
|
14
|
+
strength_names += madmodel.filter(f"kqs\.*{name}b[12]$")
|
|
15
|
+
strength_names += madmodel.filter(f"ksq\.*r{i1}b[12]$")
|
|
16
|
+
strength_names += madmodel.filter(f"ksq\.*l{i2}b[12]$")
|
|
17
|
+
strength_names += madmodel.filter(f"ks[fd][12]\.*{name}b[12]$")
|
|
18
|
+
strength_names += madmodel.filter(f"ko[fd]\.*{name}b[12]$")
|
|
19
|
+
knobs = {}
|
|
20
|
+
params = {}
|
|
21
|
+
strengths = {st: madx.globals[st] for st in strength_names}
|
|
22
|
+
return cls(name, strengths, params, knobs)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
name=None,
|
|
28
|
+
strengths=None,
|
|
29
|
+
params=None,
|
|
30
|
+
knobs=None,
|
|
31
|
+
start=None,
|
|
32
|
+
end=None,
|
|
33
|
+
):
|
|
34
|
+
i1, i2 = int(name[1]), int(name[2])
|
|
35
|
+
start = f"s.ds.r{i1}"
|
|
36
|
+
end = f"e.ds.l{i2}"
|
|
37
|
+
super().__init__(name, start, end, strengths, params, knobs)
|
|
38
|
+
self.i1 = i1
|
|
39
|
+
self.i2 = i2
|
|
40
|
+
self.start_cell = {1: f"s.cell.{i1}{i2}.b1", 2: f"s.cell.{i1}{i2}.b2"}
|
|
41
|
+
self.end_cell = {1: f"e.cell.{i1}{i2}.b1", 2: f"e.cell.{i1}{i2}.b2"}
|
|
42
|
+
self.startb = {1: f"s.ds.r{i1}.b1", 2: f"s.ds.r{i1}.b2"}
|
|
43
|
+
self.endb = {1: f"e.ds.l{i2}.b1", 2: f"e.ds.l{i2}.b2"}
|
|
44
|
+
|
|
45
|
+
def twiss_init(self, beam):
|
|
46
|
+
tw = self.twiss(beam)
|
|
47
|
+
return [
|
|
48
|
+
tw.get_twiss_init(self.startb[beam]),
|
|
49
|
+
tw.get_twiss_init(self.endb[beam]),
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
def twiss_cell(self, beam=None):
|
|
53
|
+
if beam is None:
|
|
54
|
+
return [self.twiss_cell(beam=1), self.twiss_cell(beam=2)]
|
|
55
|
+
sequence = self.model.sequence[beam]
|
|
56
|
+
start_cell = self.start_cell[beam]
|
|
57
|
+
end_cell = self.end_cell[beam]
|
|
58
|
+
return sequence.twiss(start=start_cell, end=end_cell, init="periodic")
|
|
59
|
+
|
|
60
|
+
def twiss_cell_init(self, beam):
|
|
61
|
+
sequence = self.model.sequence[beam]
|
|
62
|
+
start_cell = self.start_cell[beam]
|
|
63
|
+
end_cell = self.end_cell[beam]
|
|
64
|
+
twinit_cell = sequence.twiss(
|
|
65
|
+
start=start_cell,
|
|
66
|
+
end=end_cell,
|
|
67
|
+
init="periodic",
|
|
68
|
+
only_twiss_init=True,
|
|
69
|
+
)
|
|
70
|
+
return twinit_cell
|
|
71
|
+
|
|
72
|
+
def twiss_full(self, beam=None):
|
|
73
|
+
if beam is None:
|
|
74
|
+
return [self.twiss_full(beam=1), self.twiss_full(beam=2)]
|
|
75
|
+
else:
|
|
76
|
+
sequence = self.model.sequence[beam]
|
|
77
|
+
start = self.startb12[beam]
|
|
78
|
+
end = self.endb12[beam]
|
|
79
|
+
init = sequence.twiss().get_twiss_init(start)
|
|
80
|
+
return sequence.twiss(start=start, end=end, init=init)
|
|
81
|
+
|
|
82
|
+
def twiss(self, beam=None):
|
|
83
|
+
if beam is None:
|
|
84
|
+
return [self.twiss(beam=1), self.twiss(beam=2)]
|
|
85
|
+
else:
|
|
86
|
+
twinit_cell = self.twiss_cell_init(beam)
|
|
87
|
+
start_arc = self.startb[beam]
|
|
88
|
+
end_arc = self.endb[beam]
|
|
89
|
+
|
|
90
|
+
sequence = self.model.sequence[beam]
|
|
91
|
+
res = sequence.twiss(
|
|
92
|
+
start=start_arc, end=end_arc, init=twinit_cell
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
res["mux"] = res["mux"] - res["mux", start_arc]
|
|
96
|
+
res["muy"] = res["muy"] - res["muy", start_arc]
|
|
97
|
+
|
|
98
|
+
return res
|
|
99
|
+
|
|
100
|
+
def plot(self, beam=None, method="periodic", figlabel=None):
|
|
101
|
+
if beam is None:
|
|
102
|
+
return [self.plot(beam=1), self.plot(beam=2)]
|
|
103
|
+
else:
|
|
104
|
+
twiss = self.twiss(beam)
|
|
105
|
+
if figlabel is None:
|
|
106
|
+
figlabel = f"{self.name}b{beam}"
|
|
107
|
+
return twiss.plot(figlabel=figlabel)
|
|
108
|
+
|
|
109
|
+
def get_params_from_twiss(self, tw1, tw2):
|
|
110
|
+
params = {
|
|
111
|
+
f"mux{self.name}b1": tw1.mux[-1],
|
|
112
|
+
f"muy{self.name}b1": tw1.muy[-1],
|
|
113
|
+
f"mux{self.name}b2": tw2.mux[-1],
|
|
114
|
+
f"muy{self.name}b2": tw2.muy[-1],
|
|
115
|
+
f"muxcell{self.name[1:]}b1": tw1["mux", self.end_cell[1]]
|
|
116
|
+
- tw1["mux", self.start_cell[1]],
|
|
117
|
+
f"muxcell{self.name[1:]}b2": tw2["mux", self.end_cell[2]]
|
|
118
|
+
- tw2["mux", self.start_cell[2]],
|
|
119
|
+
f"muycell{self.name[1:]}b1": tw1["muy", self.end_cell[1]]
|
|
120
|
+
- tw1["muy", self.start_cell[1]],
|
|
121
|
+
f"muycell{self.name[1:]}b2": tw2["muy", self.end_cell[2]]
|
|
122
|
+
- tw2["muy", self.start_cell[2]],
|
|
123
|
+
}
|
|
124
|
+
return params
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def get_params(self):
|
|
128
|
+
"""Get params from model"""
|
|
129
|
+
tw1, tw2 = self.twiss()
|
|
130
|
+
return self.get_params_from_twiss(tw1, tw2)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class ActionArcPhaseAdvance(xt.Action):
|
|
134
|
+
def __init__(self, arc, beam):
|
|
135
|
+
self.arc = arc
|
|
136
|
+
self.beam = beam
|
|
137
|
+
|
|
138
|
+
def run(self):
|
|
139
|
+
tw_arc = self.arc.twiss(self.beam)
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
"table": tw_arc,
|
|
143
|
+
"mux": tw_arc["mux", -1] - tw_arc["mux", 0],
|
|
144
|
+
"muy": tw_arc["muy", -1] - tw_arc["muy", 0],
|
|
145
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def madname_from_pcname(pc):
|
|
5
|
+
name = ".".join(pc.split(".")[2:]).lower()
|
|
6
|
+
if name.startswith("rcb"):
|
|
7
|
+
return "a" + name[1:]
|
|
8
|
+
else:
|
|
9
|
+
return "k" + name[1:]
|
|
10
|
+
|
|
11
|
+
def get_calib_mad(lsa, madname):
|
|
12
|
+
print(madname)
|
|
13
|
+
pcname = lsa.findPCNameByMadStrength(madname)
|
|
14
|
+
if pcname is not None:
|
|
15
|
+
if pcname.split(".")[0] in ["RQD", "RQF", "RB"]:
|
|
16
|
+
pcname = pcname + "B1"
|
|
17
|
+
cal = lsa.getCalibration(pcname)
|
|
18
|
+
if cal is not None:
|
|
19
|
+
return [cal.field, cal.current]
|
|
20
|
+
|
|
21
|
+
class LHCCircuits:
|
|
22
|
+
@classmethod
|
|
23
|
+
def from_lsa(cls):
|
|
24
|
+
import pjlsa
|
|
25
|
+
lsa=pjlsa.LSAClient()
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def from_json(cls, filename):
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
def __init__(self, circuits):
|
|
32
|
+
self.circuits = circuits
|
|
33
|
+
|
|
34
|
+
def to_json(self, filename):
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class LHCCircuit:
|
|
39
|
+
def __init__(
|
|
40
|
+
self,
|
|
41
|
+
name,
|
|
42
|
+
madname,
|
|
43
|
+
calib,
|
|
44
|
+
r1,
|
|
45
|
+
l1,
|
|
46
|
+
c1,
|
|
47
|
+
imax,
|
|
48
|
+
imin,
|
|
49
|
+
vmax,
|
|
50
|
+
vmin,
|
|
51
|
+
ipmax,
|
|
52
|
+
ipmin,
|
|
53
|
+
vpmax,
|
|
54
|
+
vpmin,
|
|
55
|
+
polarity,
|
|
56
|
+
):
|
|
57
|
+
self.name = name
|
|
58
|
+
self.madname = madname
|
|
59
|
+
self.calib = calib
|
|
60
|
+
self.r1 = r1
|
|
61
|
+
self.l1 = l1
|
|
62
|
+
self.c1 = c1
|
|
63
|
+
self.imax = imax
|
|
64
|
+
self.imin = imin
|
|
65
|
+
self.vmax = vmax
|
|
66
|
+
self.vmin = vmin
|
|
67
|
+
self.ipmax = ipmax
|
|
68
|
+
self.ipmin = ipmin
|
|
69
|
+
self.vpmax = vpmax
|
|
70
|
+
self.vpmin = vpmin
|
|
71
|
+
self.polarity = polarity
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class LHCCircuit2in1:
|
|
75
|
+
def __init__(self, circuit1, circuit2, rc):
|
|
76
|
+
self.circuit1 = circuit1
|
|
77
|
+
self.circuit2 = circuit2
|
|
78
|
+
self.rc = rc
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .irs import LHCIR
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LHCIR2(LHCIR):
|
|
5
|
+
name = "ir2"
|
|
6
|
+
knobs = [
|
|
7
|
+
"on_x2h",
|
|
8
|
+
"on_sep2h",
|
|
9
|
+
"on_x2v",
|
|
10
|
+
"on_sep2v",
|
|
11
|
+
"on_a2",
|
|
12
|
+
"on_oh2",
|
|
13
|
+
"on_xip2b2",
|
|
14
|
+
"on_xip2b1",
|
|
15
|
+
"on_o2",
|
|
16
|
+
"on_ov2",
|
|
17
|
+
"on_yip2b1",
|
|
18
|
+
"on_yip2b2",
|
|
19
|
+
]
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
from .irs import LHCIR
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LHCIR7(LHCIR):
|
|
5
|
+
name = "ir7"
|
|
6
|
+
|
|
7
|
+
collimators = [
|
|
8
|
+
"tcp.c6l7.b1",
|
|
9
|
+
"tcp.d6l7.b1",
|
|
10
|
+
"tcp.c6r7.b2",
|
|
11
|
+
"tcp.d6r7.b2",
|
|
12
|
+
"tcsg.a4l7.b1",
|
|
13
|
+
"tcsg.a4l7.b1",
|
|
14
|
+
"tcsg.a4r7.b2",
|
|
15
|
+
"tcsg.a4r7.b2",
|
|
16
|
+
"tcsg.d5r7.b1",
|
|
17
|
+
"tcsg.d5r7.b1",
|
|
18
|
+
"tcsg.d5l7.b2",
|
|
19
|
+
"tcsg.d5l7.b2",
|
|
20
|
+
"tcspm.6r7.b1",
|
|
21
|
+
"tcspm.6r7.b1",
|
|
22
|
+
"tcspm.6l7.b2",
|
|
23
|
+
"tcspm.6l7.b2",
|
|
24
|
+
"tcla.d6r7.b1",
|
|
25
|
+
"tcla.d6r7.b1",
|
|
26
|
+
"tcla.d6l7.b2",
|
|
27
|
+
"tcla.d6l7.b2",
|
|
28
|
+
"tcsg.a5l7.b1",
|
|
29
|
+
"tcsg.a5l7.b1",
|
|
30
|
+
"tcsg.a5r7.b2",
|
|
31
|
+
"tcsg.a5r7.b2",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
def update_from_model(self):
|
|
35
|
+
for beam, tw in enumerate(self.twiss):
|
|
36
|
+
self.params[f"betxip7b{beam+1}"] = tw["betxip"]
|
|
37
|
+
self.params[f"betyip7b{beam+1}"] = tw["betyip"]
|
|
38
|
+
self.params = {
|
|
39
|
+
"betxip7b1": 0.8,
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
"""
|
|
44
|
+
class SinglePassDispersion(xd.Action):
|
|
45
|
+
def __init__(self, line, ele_start, ele_stop, backtrack=False, delta=1e-3):
|
|
46
|
+
self.line = line
|
|
47
|
+
self.ele_start = ele_start
|
|
48
|
+
self.ele_stop = ele_stop
|
|
49
|
+
self.delta = delta
|
|
50
|
+
self.backtrack = backtrack
|
|
51
|
+
self._pp = line.build_particles(delta=delta)
|
|
52
|
+
|
|
53
|
+
def run(self):
|
|
54
|
+
for nn in ["x", "px", "y", "py", "zeta", "delta", "at_element"]:
|
|
55
|
+
setattr(self._pp, nn, 0)
|
|
56
|
+
self._pp.delta = self.delta
|
|
57
|
+
self.line.track(
|
|
58
|
+
self._pp,
|
|
59
|
+
ele_start=self.ele_start,
|
|
60
|
+
ele_stop=self.ele_stop,
|
|
61
|
+
backtrack=self.backtrack,
|
|
62
|
+
)
|
|
63
|
+
return {
|
|
64
|
+
"d" + nn: getattr(self._pp, nn)[0] / self.delta
|
|
65
|
+
for nn in ["x", "px", "y", "py"]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
act_sp1 = SinglePassDispersion(
|
|
70
|
+
lhc.lhcb1, ele_start="tcp.d6l7.b1", ele_stop="tcspm.6r7.b1"
|
|
71
|
+
)
|
|
72
|
+
act_sp2 = SinglePassDispersion(
|
|
73
|
+
lhc.lhcb2, ele_start="tcp.d6r7.b2", ele_stop="tcspm.6l7.b2", backtrack=False
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
dxb1=act_sp1.run()['dx']
|
|
78
|
+
dxb2=act_sp2.run()['dx']
|
|
79
|
+
opt3 = lhc.match(solve=False,
|
|
80
|
+
default_tol={None: 5e-8},
|
|
81
|
+
twiss_init='preserve_start',
|
|
82
|
+
table_for_twiss_init=(tw.lhcb1,tw.lhcb2),
|
|
83
|
+
ele_start=('s.ds.l3.b1','s.ds.l3.b2'),
|
|
84
|
+
ele_stop=('e.ds.r3.b1','e.ds.r3.b2'),
|
|
85
|
+
targets=[
|
|
86
|
+
xt.TargetSet(['alfx','alfy','betx','bety','dx','dpx'],value=tw.lhcb1,line='lhcb1',at=xt.END),
|
|
87
|
+
xt.TargetSet(['alfx','alfy','betx','bety','dx','dpx'],value=tw.lhcb2,line='lhcb2',at=xt.END),
|
|
88
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety0),line='lhcb1',at='tcsg.5l3.b1',tol=1e-1,tag='tcsg0b1'),
|
|
89
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety1),line='lhcb1',at='tcsg.4r3.b1',tol=1e-1,tag='tcsg1b1'),
|
|
90
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety2),line='lhcb1',at='tcsg.a5r3.b1',tol=1e-1,tag='tcsg2b1'),
|
|
91
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety3),line='lhcb1',at='tcsg.b5r3.b1',tol=1e-1,tag='tcsg3b1'),
|
|
92
|
+
|
|
93
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety4),line='lhcb2',at='tcsg.5r3.b2',tol=1e-1,tag='tcsg0b2'),
|
|
94
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety5),line='lhcb2',at='tcsg.4l3.b2',tol=1e-1,tag='tcsg1b2'),
|
|
95
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety6),line='lhcb2',at='tcsg.a5l3.b2',tol=1e-1,tag='tcsg2b2'),
|
|
96
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety7),line='lhcb2',at='tcsg.b5l3.b2',tol=1e-1,tag='tcsg3b2'),
|
|
97
|
+
]+ir3targets+[
|
|
98
|
+
xt.Target(action=act_pa3, tar='mux', value=nomMux, tol=1e-3, tag='mu'),
|
|
99
|
+
xt.Target(action=act_pa4, tar='muy', value=nomMuy, tol=1e-3, tag='mu'),
|
|
100
|
+
],
|
|
101
|
+
vary=(xt.VaryList(list(strDictIR3.keys())))
|
|
102
|
+
)
|
|
103
|
+
opt3.assert_within_tol=False
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
bety0=tw1.lhcb1.rows['tcsg.5l3.b1'].bety[0]
|
|
107
|
+
bety1=tw1.lhcb1.rows['tcsg.4r3.b1'].bety[0]
|
|
108
|
+
bety2=tw1.lhcb1.rows['tcsg.a5r3.b1'].bety[0]
|
|
109
|
+
bety3=tw1.lhcb1.rows['tcsg.b5r3.b1'].bety[0]
|
|
110
|
+
bety4=tw1.lhcb2.rows['tcsg.5r3.b2'].bety[0]
|
|
111
|
+
bety5=tw1.lhcb2.rows['tcsg.4l3.b2'].bety[0]
|
|
112
|
+
bety6=tw1.lhcb2.rows['tcsg.a5l3.b2'].bety[0]
|
|
113
|
+
bety7=tw1.lhcb2.rows['tcsg.b5l3.b2'].bety[0]
|
|
114
|
+
|
|
115
|
+
opt7 = lhc.match(solve=False,
|
|
116
|
+
default_tol={None: 5e-8},
|
|
117
|
+
solver_options=dict(max_rel_penalty_increase=2.),
|
|
118
|
+
twiss_init='preserve_start',
|
|
119
|
+
table_for_twiss_init=(tw.lhcb1,tw.lhcb2),
|
|
120
|
+
ele_start=('s.ds.l7.b1','s.ds.l7.b2'),
|
|
121
|
+
ele_stop=('e.ds.r7.b1','e.ds.r7.b2'),
|
|
122
|
+
targets=[
|
|
123
|
+
xt.TargetSet(['alfx','alfy','betx','bety','dx','dpx'],value=tw.lhcb1,line='lhcb1',at=xt.END),
|
|
124
|
+
xt.TargetSet(['alfx','alfy','betx','bety','dx','dpx'],value=tw.lhcb2,line='lhcb2',at=xt.END),
|
|
125
|
+
xt.Target(action=act_sp1, tar='dx', value=dxb1, tol=1e-2, tag='dx'),
|
|
126
|
+
xt.Target(action=act_sp2, tar='dx', value=dxb2, tol=1e-2, tag='dx'),
|
|
127
|
+
xt.Target('betx',xt.GreaterThan((1-margin)*betx1),line='lhcb1',at='tcp.c6l7.b1',tol=1e-1,tag='tcp'),
|
|
128
|
+
xt.Target('bety',xt.GreaterThan((1-margin)*bety1),line='lhcb1',at='tcp.d6l7.b1',tol=1e-1,tag='tcp'),
|
|
129
|
+
xt.Target('betx',xt.GreaterThan((1-margin)*betx2),line='lhcb2',at='tcp.c6r7.b2',tol=1e-1,tag='tcp'),
|
|
130
|
+
xt.Target('bety',xt.GreaterThan((1-margin)*bety2),line='lhcb2',at='tcp.d6r7.b2',tol=1e-1,tag='tcp'),
|
|
131
|
+
|
|
132
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx3),line='lhcb1',at='tcsg.a4l7.b1',tol=1e-1,tag='tcsga4'),
|
|
133
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety3),line='lhcb1',at='tcsg.a4l7.b1',tol=1e-1,tag='tcsga4'),
|
|
134
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx4),line='lhcb2',at='tcsg.a4r7.b2',tol=1e-1,tag='tcsga4'),
|
|
135
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety4),line='lhcb2',at='tcsg.a4r7.b2',tol=1e-1,tag='tcsga4'),
|
|
136
|
+
|
|
137
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx5),line='lhcb1',at='tcsg.d5r7.b1',tol=1e-1,tag='tcsgd'),
|
|
138
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety5),line='lhcb1',at='tcsg.d5r7.b1',tol=1e-1,tag='tcsgd'),
|
|
139
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx6),line='lhcb2',at='tcsg.d5l7.b2',tol=1e-1,tag='tcsgd'),
|
|
140
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety6),line='lhcb2',at='tcsg.d5l7.b2',tol=1e-1,tag='tcsgd'),
|
|
141
|
+
|
|
142
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx7),line='lhcb1',at='tcspm.6r7.b1',tol=1e-1,tag='tcspm'),
|
|
143
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety7),line='lhcb1',at='tcspm.6r7.b1',tol=1e-1,tag='tcspm'),
|
|
144
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx8),line='lhcb2',at='tcspm.6l7.b2',tol=1e-1,tag='tcspm'),
|
|
145
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety8),line='lhcb2',at='tcspm.6l7.b2',tol=1e-1,tag='tcspm'),
|
|
146
|
+
|
|
147
|
+
xt.Target('betx',xt.LessThan((1+margin)*betx9),line='lhcb1',at='tcla.d6r7.b1',tol=1e-1,tag='tcla'),
|
|
148
|
+
xt.Target('bety',xt.LessThan((1+margin)*bety9),line='lhcb1',at='tcla.d6r7.b1',tol=1e-1,tag='tcla'),
|
|
149
|
+
xt.Target('betx',xt.LessThan((1+margin)*betxA),line='lhcb2',at='tcla.d6l7.b2',tol=1e-1,tag='tcla'),
|
|
150
|
+
xt.Target('bety',xt.LessThan((1+margin)*betyA),line='lhcb2',at='tcla.d6l7.b2',tol=1e-1,tag='tcla'),
|
|
151
|
+
|
|
152
|
+
xt.Target('betx',xt.LessThan((1+margin)*betxB),line='lhcb1',at='tcsg.a5l7.b1',tol=1e-1,tag='tcsga5'),
|
|
153
|
+
xt.Target('bety',xt.LessThan((1+margin)*betyB),line='lhcb1',at='tcsg.a5l7.b1',tol=1e-1,tag='tcsga5'),
|
|
154
|
+
xt.Target('betx',xt.LessThan((1+margin)*betxC),line='lhcb2',at='tcsg.a5r7.b2',tol=1e-1,tag='tcsga5'),
|
|
155
|
+
xt.Target('bety',xt.LessThan((1+margin)*betyC),line='lhcb2',at='tcsg.a5r7.b2',tol=1e-1,tag='tcsga5'),
|
|
156
|
+
],
|
|
157
|
+
vary=(xt.VaryList(list(strDictIR7.keys())))
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
colls_ir3b1=['tcp.6l3.b1','tcsg.5l3.b1','tcsg.4r3.b1','tcsg.a5r3.b1','tcsg.b5r3.b1','tcla.a5r3.b1','tcla.b5r3.b1','tcla.6r3.b1','tcla.7r3.b1']
|
|
162
|
+
colls_ir3b2=['tcp.6r3.b2','tcsg.5r3.b2','tcsg.4l3.b2','tcsg.a5l3.b2','tcsg.b5l3.b2','tcla.a5l3.b2','tcla.b5l3.b2','tcla.6l3.b2','tcla.7l3.b2']
|
|
163
|
+
|
|
164
|
+
ir3targets=[]
|
|
165
|
+
for coll in colls_ir3b1:
|
|
166
|
+
ir3targets.append(xt.TargetSet(['betx','dx'],tol=1e-1,value=tw.lhcb1,line='lhcb1',at=coll))
|
|
167
|
+
for coll in colls_ir3b2:
|
|
168
|
+
ir3targets.append(xt.TargetSet(['betx','dx'],tol=1e-1,value=tw.lhcb2,line='lhcb2',at=coll))
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
knobsRematched12c6b = {
|
|
172
|
+
"kqt4.l7": 0.0012257364160585084,
|
|
173
|
+
"kqt4.r7": 0.0012659632628095638,
|
|
174
|
+
"kqt13.l7b1": -0.0048823483573787445,
|
|
175
|
+
"kqt12.l7b1": -0.004882279788343516,
|
|
176
|
+
"kqtl11.l7b1": 0.0027739663492968103,
|
|
177
|
+
"kqtl10.l7b1": 0.004623538857746193,
|
|
178
|
+
"kqtl9.l7b1": -0.003372747954072591,
|
|
179
|
+
"kqtl8.l7b1": -0.0023127417813640786,
|
|
180
|
+
"kqtl7.l7b1": -0.002011344510772721,
|
|
181
|
+
"kq6.l7b1": 0.0031173363410593766,
|
|
182
|
+
"kq6.r7b1": -0.0031388056161611565,
|
|
183
|
+
"kqtl7.r7b1": 0.0009532375359442739,
|
|
184
|
+
"kqtl8.r7b1": 0.002688438505728887,
|
|
185
|
+
"kqtl9.r7b1": 0.0033416607916765947,
|
|
186
|
+
"kqtl10.r7b1": -0.003461273410884878,
|
|
187
|
+
"kqtl11.r7b1": 0.0010531054411466265,
|
|
188
|
+
"kqt12.r7b1": -0.0027831205556483702,
|
|
189
|
+
"kqt13.r7b1": -0.0013509460856456692,
|
|
190
|
+
"kqt13.l7b2": -0.004192310485204978,
|
|
191
|
+
"kqt12.l7b2": -0.0035271197718106688,
|
|
192
|
+
"kqtl11.l7b2": 0.0008993274235722462,
|
|
193
|
+
"kqtl10.l7b2": -0.0035044843946580337,
|
|
194
|
+
"kqtl9.l7b2": 0.003295485018957867,
|
|
195
|
+
"kqtl8.l7b2": 0.002429071850457167,
|
|
196
|
+
"kqtl7.l7b2": 0.0008310840304967491,
|
|
197
|
+
"kq6.l7b2": -0.0031817725498278727,
|
|
198
|
+
"kq6.r7b2": 0.003183554427942885,
|
|
199
|
+
"kqtl7.r7b2": -0.0012886165853725183,
|
|
200
|
+
"kqtl8.r7b2": -0.0037917967174795034,
|
|
201
|
+
"kqtl9.r7b2": -0.0033703081873609005,
|
|
202
|
+
"kqtl10.r7b2": 0.0049711605825101994,
|
|
203
|
+
"kqtl11.r7b2": 0.002278252114016244,
|
|
204
|
+
"kqt12.r7b2": -0.0048808187874553495,
|
|
205
|
+
"kqt13.r7b2": -0.0048815559298144,
|
|
206
|
+
"kq4.lr7": 0.0011653779946877393,
|
|
207
|
+
"kq5.lr7": -0.001202569087048791,
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
knobsRematched13b_mu = {
|
|
211
|
+
"kqt4.l3": 0.0006887129999999986,
|
|
212
|
+
"kqt4.r3": 0.000688713,
|
|
213
|
+
"kqt5.l3": 0.000972084,
|
|
214
|
+
"kqt5.r3": 0.000972084,
|
|
215
|
+
"kqt13.l3b1": -0.002328955907392481,
|
|
216
|
+
"kqt12.l3b1": 0.002822813556121194,
|
|
217
|
+
"kqtl11.l3b1": 0.0012986138594000976,
|
|
218
|
+
"kqtl10.l3b1": 0.0010616412957247959,
|
|
219
|
+
"kqtl9.l3b1": -0.005223865183101024,
|
|
220
|
+
"kqtl8.l3b1": 0.00033781692792629684,
|
|
221
|
+
"kqtl7.l3b1": -0.000876435629840312,
|
|
222
|
+
"kq6.l3b1": 0.0025894410128743917,
|
|
223
|
+
"kq6.r3b1": -0.002412918519504643,
|
|
224
|
+
"kqtl7.r3b1": 0.0022028677895794004,
|
|
225
|
+
"kqtl8.r3b1": 0.0035691450329306527,
|
|
226
|
+
"kqtl9.r3b1": -7.37775306738355e-05,
|
|
227
|
+
"kqtl10.r3b1": 0.004022882019207013,
|
|
228
|
+
"kqtl11.r3b1": -0.0030302762162364503,
|
|
229
|
+
"kqt12.r3b1": -0.005138992845888184,
|
|
230
|
+
"kqt13.r3b1": -0.001896775114412516,
|
|
231
|
+
"kqt13.l3b2": -0.0025197838172713494,
|
|
232
|
+
"kqt12.l3b2": -0.003785001043390164,
|
|
233
|
+
"kqtl11.l3b2": -0.0032679415485541703,
|
|
234
|
+
"kqtl10.l3b2": 0.004726996198081681,
|
|
235
|
+
"kqtl9.l3b2": -0.0006237278666374633,
|
|
236
|
+
"kqtl8.l3b2": 0.0038112997328762573,
|
|
237
|
+
"kqtl7.l3b2": 0.0005221529209823068,
|
|
238
|
+
"kq6.l3b2": -0.002467855997059401,
|
|
239
|
+
"kq6.r3b2": 0.0025687299038460276,
|
|
240
|
+
"kqtl7.r3b2": 0.0007580546568790491,
|
|
241
|
+
"kqtl8.r3b2": -0.0007870443115947539,
|
|
242
|
+
"kqtl9.r3b2": -0.004254750086155878,
|
|
243
|
+
"kqtl10.r3b2": 0.00041179336225102066,
|
|
244
|
+
"kqtl11.r3b2": 0.0006593584215004978,
|
|
245
|
+
"kqt12.r3b2": -9.48176531256308e-05,
|
|
246
|
+
"kqt13.r3b2": -0.005098976136482916,
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
"""
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .irs import LHCIR
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class LHCIR8(LHCIR):
|
|
5
|
+
name = "ir8"
|
|
6
|
+
knobs = [
|
|
7
|
+
"on_x8h",
|
|
8
|
+
"on_sep8h",
|
|
9
|
+
"on_x8v",
|
|
10
|
+
"on_sep8v",
|
|
11
|
+
"on_o8",
|
|
12
|
+
"on_oh8",
|
|
13
|
+
"on_xip8b2",
|
|
14
|
+
"on_xip8b1",
|
|
15
|
+
"on_a8",
|
|
16
|
+
"on_ov8",
|
|
17
|
+
"on_yip8b1",
|
|
18
|
+
"on_yip8b2",
|
|
19
|
+
]
|