Allow update of quads defined in the matching script.

This commit is contained in:
2026-01-20 17:22:58 +01:00
parent 790c50cd0d
commit d168cd2a69
3 changed files with 22 additions and 12 deletions

View File

@@ -4,8 +4,6 @@ Twiss0: beta0,betx=10,alfx=0,bety=10,alfy=0; ! location:swissfel$start
TwissM1: beta0,betx=8.72,alfx=1,bety=8.72,alfy=1; ! location:sinsb04.mqua230$end
TwissM2: beta0, betx = 11.1557, alfx = -1.17, bety = 50, alfy = 0.; ! label: After BC1 location:sindi02.mqua020$start
Twisssep: beta0,betx=10,alfx=-0.2,bety=20,alfy=1.0; ! label: Septum location:s20sy02$start
TwissAT1: beta0,betx=34.45,alfx=1,bety=34.45,alfy=1; ! label: Switchyard - Drift location:satsy02.mqua230
TwissAT2: beta0,betx=5,alfx=1.77,bety=4,alfy=-1.04; ! label: Switchyard - Double Bend location:satsy03.mqua110
TwissAT3: beta0,betx=14,alfx=0.7,bety=14,alfy=0.7; ! label: Beam Stopper location:satcb01.mqua430$end
@@ -13,4 +11,8 @@ twissee: beta0,betx=7,bety=30,alfx=0.5,alfy=1.5; ! label: EEHG location:satma01.
twisspor: beta0, betx=3.9036,alfx=-0.05021,bety=37.6374,alfy=4.4433; ! label: Porthos Septum location:s30cb15$end
twissARECOL:beta0, betx = 2.304, alfx = -1.4045, bety = 25.929, alfy = -6.363; ! label: Aramis ECOL location:sarma01.mqua010$start
! variables
ECOLasBC = 0; ! Description: Flag to configure Aramis Energy collimator as a bunch compressor
ECOLasBC = 0; ! Description: Flag to configure Aramis Energy collimator as a bunch compressor
! filters for updates
filter1 = 's[i1].*k[12]|s20sy01.*k1'; ! filter: Injector
filter2 = 'sat.*mqua.*k1|sat.*msex.*k2|s20sy02.*m[kq]'; ! filter: Athos
filter3 = 's[3a][0r].*k[12]|s20bc.*k1|s20ma.*k1|s20cb.*k1'; ! filter: Aramis

View File

@@ -2,16 +2,12 @@
5) Load Reference -> initial matching condition
4) Save aver matching -> save initial twiss conditions
6) filter for current, planned and final phase for matching scripts
1) Check reference settings directory, depending on online and offline mode
2) switch between references
3) Allo filter to update quadrupoles to be part of the match scripts and not globally written in the code
#) allow for some progress indication of matching
3) Match for sextupoles!

View File

@@ -15,6 +15,7 @@ class MatchMaker:
self.scriptdir = None
self.signal=signal
self.matchresult=[]
self.filter={}
def initScripts(self,target):
self.scriptdir = self.matchlist[target]
@@ -31,6 +32,11 @@ class MatchMaker:
file = self.scriptdir+'/initTwiss.madx'
self.referencePoints.clear()
self.variables.clear()
self.filter.clear()
# default values
self.filter['injector']='s[i1].*k[12]|s20cb.*k1|s20sy01.*k1'
self.filter['athos']='sat.*mqua.*k1|sat.*msex.*k2|s20sy02.*m[kq]'
self.filter['aramis'] = 's[3a][0r].*k[12]|s20sy03.*k1'
with open(file,'r') as f:
lines = f.readlines()
for line in lines:
@@ -52,6 +58,12 @@ class MatchMaker:
val = float(flds[1].split(';')[0].strip())
self.variables[name] = {'Value':val,'Description':description}
print('Found Variable',name,'with value',val)
if 'filter:' in line:
tag = line.split('filter:')
location = tag[1].strip()
filterexo = tag[0].split('=')[1].split(';')[0].replace("'","").strip()
self.filter[location.lower()]=filterexo
print('Found Filter', filterexo, 'for location', location)
print('##### Reference Twiss values parsed')
@@ -77,13 +89,13 @@ class MatchMaker:
if Injector:
print('Matching Injector ...')
madx.madx.call('matchInjector.madx')
self.updateOnlineModel(om,madx.madx, 's[i1].*k[12]|s20cb.*k1|s20sy01.*k1')
self.updateOnlineModel(om,madx.madx, self.filter['injector'])
self.parseMatchOutput(f.getvalue().split('\n'),'Injector')
if Athos:
f.truncate(0)
print('Matching Athos ...')
madx.madx.call('matchAthos.madx')
self.updateOnlineModel(om, madx.madx, 'sat.*mqua.*k1|sat.*msex.*k2|s20sy02.*m[kq]')
self.updateOnlineModel(om, madx.madx, self.filter['athos'])
self.parseMatchOutput(f.getvalue().split('\n'), 'Athos')
if Aramis:
f.truncate(0)
@@ -95,7 +107,7 @@ class MatchMaker:
madx.commonHeader('SwissFEL', '#s/#e', None) # sets header
madx.madx.call('initTwiss.madx')
madx.madx.call('matchAramis.madx')
self.updateOnlineModel(om, madx.madx, 's[3a][0r].*k[12]|s20sy03.*k1')
self.updateOnlineModel(om, madx.madx, self.filter['aramis'])
self.parseMatchOutput(f.getvalue().split('\n'), 'Aramis')
os.chdir(cwd)