140 lines
7.6 KiB
Python
140 lines
7.6 KiB
Python
import json
|
|
|
|
|
|
def MatchStep(ref,id,end, dest,sequence=None,saveTwiss=None):
|
|
match={'Reference':ref,'MatchID':id,'End':end, 'Destination':dest,'Sequence':sequence,'Save':saveTwiss}
|
|
return match
|
|
|
|
def MatchReference(loc,twiss,limit=None): # limit 1 -> smaller than, 2 -> larger than (default is euqal)
|
|
match ={'Location': loc, 'Twiss': twiss}
|
|
if not limit is None:
|
|
match['Limit'] = limit
|
|
return match
|
|
|
|
|
|
def MatchParameter(var0,tar0):
|
|
return {'Variable':var0,'Target':tar0}
|
|
|
|
path ="Settings/"
|
|
label='Reference'
|
|
|
|
order = []
|
|
# order of elements:
|
|
# - Match starting point with Twiss, None has no initial condition and starts with #s
|
|
# - ID to find additional parameteters
|
|
# - Last section in tracking/matching. If none it tracks to the end (#e)
|
|
# - destination: selection of branch by giving a unique section name (e.g. SARBD01 for Aramis)
|
|
# - sequence: sequence to use. If it is a list of sequence then a temporary sequence is used. Default to swissfel
|
|
# - flag to last twiss parameters, needed for other routines to refer to.
|
|
|
|
order.append(MatchStep('Start', 'Laser Heater','SINLH02','SATBD01'))
|
|
order.append(MatchStep(None, 'SINSB04', None,'SATBD01','SINSB04',True))
|
|
order.append(MatchStep('Laser Heater', 'Match to SINSB04','SINSB04','SATBD01'))
|
|
order.append(MatchStep('Laser Heater', 'Bunch Compressor 1','SINDI02','SATBD01'))
|
|
order.append(MatchStep(None, 'Linac 1', None,'SATBD01','S10CB02',True))
|
|
order.append(MatchStep('Bunch Compressor 1', 'Match to Linac 1','S10CB02','SATBD01'))
|
|
order.append(MatchStep('Bunch Compressor 1', 'End of Linac 1','S10BC01','SATBD01'))
|
|
order.append(MatchStep('Bunch Compressor 1', 'Bunch Compressor 2','S10MA01','SATBD01'))
|
|
order.append(MatchStep(None, 'Linac 2', None,'SATBD01',['S20CB01','S20CB02'],True))
|
|
order.append(MatchStep('Bunch Compressor 2', 'Match to Linac 2','S20CB04','SATBD01'))
|
|
order.append(MatchStep('Bunch Compressor 2', 'Match to Switchyard','S20SY02','SATBD01'))
|
|
order.append(MatchStep('Switchyard', 'Resonant Kicker','S20SY02','SATBD01'))
|
|
#order.append(MatchStep('Switchyard', 'Switchyard','SATSY03','SATBD01'))
|
|
|
|
# list of references with fixed twiss parameters
|
|
reference={}
|
|
reference['Start'] = MatchReference('start',{'betax':29.971,'alphax':0.003,'betay':26.00,'alphay':-0.288})
|
|
reference['Laser Heater'] = MatchReference('sinlh02.mqua410$start',{'betax': 11.2, 'alphax': 3.2,'betay': 0.8, 'alphay': 0.75,})
|
|
reference['Bunch Compressor 1'] = MatchReference('sindi02.mqua020$start',{'betax': 11.1557, 'alphax': -1.17,'betay': 50, 'alphay': 0.})
|
|
reference['Bunch Compressor 2'] = MatchReference('s10ma01.mqua020$start',{'betax': 6.14, 'alphax': -0.83,'betay': 22.86, 'alphay': -1.18})
|
|
reference['Switchyard'] = MatchReference('s20sy02$start',{'betax': 48.26, 'alphax': 7.322,'betay': 14.293, 'alphay': -3.513})
|
|
reference['Linac3'] = MatchReference('s30cb10.mqua430$start',{'betax': 8.83,'alphax': 0.548,'betay': 30.44,'alphay': -1.866})
|
|
reference['Aramis Stopper'] = MatchReference('sarma01.mqua010$start',{'betax': 2.304, 'alphax': -1.4045, 'betay': 25.929, 'alphay': -6.363})
|
|
reference['Athos HERO'] = MatchReference('satdi01.mqua250$start',{'betax': 35.76, 'alphax': -1.166,'betay': 24.087, 'alphay': 0.648})
|
|
reference['Athos Deflector'] = MatchReference('satbd01.mqua010$start',{'betax': 50, 'alphax': 0,'betay': 50, 'alphay': 0})
|
|
|
|
|
|
|
|
|
|
parameter={}
|
|
var = ['SINLH01-MQUA020', 'SINLH01-MQUA040','SINLH01-MQUA050','SINLH01-MQUA070','SINLH02-MQUA010']
|
|
tar = [reference['Laser Heater']]
|
|
parameter['Laser Heater'] = MatchParameter(var,tar)
|
|
|
|
var = ['SINSB04-MQUA130','SINSB04-MQUA230']
|
|
tar =[MatchReference('#e',{'MUX':0.2,'MUY':0.2})]
|
|
parameter['SINSB04'] = MatchParameter(var,tar)
|
|
|
|
var = ['SINLH02-MQUA410','SINLH03-MQUA030','SINLH03-MQUA040','SINLH03-MQUA060','SINLH03-MQUA080','SINSB03-MQUA130']
|
|
tar =[{'Location':'sinsb04$start','SavedID':'SINSB04'}]
|
|
parameter['Match to SINSB04']=MatchParameter(var,tar)
|
|
|
|
var = ['SINBC01-MQUA020','SINBC01-MQUA050','SINBC01-MQUA070','SINBC01-MQUA090','SINBC01-MQUA110','SINDI01-MQUA020','SINDI01-MQUA070']
|
|
tar =[reference['Bunch Compressor 1'],
|
|
MatchReference('sinbc02.mbnd400',{'betax':5.1,'betay':100},1),
|
|
MatchReference('sinbc01.mqua110$end',{'betax':100},1)]
|
|
parameter['Bunch Compressor 1']=MatchParameter(var, tar)
|
|
|
|
var = ['S10CB02-MQUA230','S10CB02-MQUA430']
|
|
tar = [MatchReference('#e',{'MUX':0.1883,'MUY':0.1883})]
|
|
parameter['Linac 1'] = MatchParameter(var, tar)
|
|
|
|
|
|
var = ['S10CB01-MQUA230','S10CB01-MQUA430','SINDI02-MQUA020','SINDI02-MQUA030','SINDI02-MQUA050','SINDI02-MQUA060','SINDI02-MQUA090']
|
|
tar =[{'Location':'s10cb02$start','SavedID':'Linac 1'}]
|
|
parameter['Match to Linac 1']=MatchParameter(var,tar)
|
|
|
|
|
|
var = ['S10CB07-MQUA430','S10CB08-MQUA230','S10CB08-MQUA430','S10CB09-MQUA230']
|
|
tar = [MatchReference('s10bc01.mqua020$start',{'betax':4.88,'betay':16.11,'alphax':0.5546,'alphay':-1.81})]
|
|
parameter['End of Linac 1']=MatchParameter(var, tar)
|
|
|
|
|
|
var = ['S10BC01-MQUA020','S10BC01-MQUA040','S10BC01-MQUA060','S10BC01-MQUA080','S10BC01-MQUA100']
|
|
tar = [reference['Bunch Compressor 2']]
|
|
parameter['Bunch Compressor 2']=MatchParameter(var,tar)
|
|
|
|
var = ['S20CB01-MQUA430','S20CB02-MQUA430']
|
|
tar = [MatchReference('#e', {'MUX': 0.2, 'MUY': 0.2})]
|
|
parameter['Linac 2'] = MatchParameter(var, tar)
|
|
|
|
|
|
var = ['S10MA01-MQUA020','S10MA01-MQUA050','S10MA01-MQUA070','S10MA01-MQUA110','S10MA01-MQUA130']
|
|
tar =[{'Location':'s20cb01$start','SavedID':'Linac 2'}]
|
|
parameter['Match to Linac 2']=MatchParameter(var, tar)
|
|
|
|
var = ['S20SY01-MQUA020','S20SY01-MQUA030','S20SY01-MQUA050','S20SY01-MQUA080']
|
|
tar = [reference['Switchyard']]
|
|
parameter['Match to Switchyard']=MatchParameter(var, tar)
|
|
|
|
|
|
var = ['S20SY02-MQUA070','S20SY02-MQUA100','S20SY02-MQUA140','S20SY02-MQUA180','S20SY02-MKDC010','S20SY02-MKAC020','S20SY02-MKDC030','S20SY02-MKAC040','S20SY02-MKDC050']
|
|
tar=[{'Script':'Scripts/switchyard_kicker.madx'}]
|
|
parameter['Resonant Kicker']=MatchParameter(var, tar)
|
|
|
|
dependence={}
|
|
dependence['SINSB04-MQUA230']=['SINSB03-MQUA230']
|
|
dependence['S10CB02-MQUA230']=['S10DI01-MQUA120'] + ['S10CB%2.2d-MQUA430' % i for i in range(3,9)]
|
|
dependence['S10CB02-MQUA430']=['S10CB%2.2d-MQUA230' % i for i in range(3,9)]
|
|
dependence['S20CB01-MQUA430']=['S20CB03-MQUA430']
|
|
dependence['SATSY01-MQUA090']=['SATSY01-MQUA210']
|
|
dependence['SATSY01-MQUA070']=['SATSY01-MQUA230']
|
|
dependence['SATSY01-MQUA040']=['SATSY01-MQUA260']
|
|
|
|
|
|
reference={}
|
|
reference['Start'] = MatchReference('start',{'betax':29.971,'alphax':0.003,'betay':26.00,'alphay':-0.288})
|
|
reference['Laser Heater'] = MatchReference('sinlh02.mqua410$start',{'betax': 11.2, 'alphax': 3.2,'betay': 0.8, 'alphay': 0.75,})
|
|
reference['Bunch Compressor 1'] = MatchReference('sindi02.mqua020$start',{'betax': 11.1557, 'alphax': -1.17,'betay': 50, 'alphay': 0.})
|
|
reference['Bunch Compressor 2'] = MatchReference('s10ma01.mqua020$start',{'betax': 6.14, 'alphax': -0.83,'betay': 22.86, 'alphay': -1.18})
|
|
reference['Switchyard'] = MatchReference('s20sy02$start',{'betax': 48.26, 'alphax': 7.322,'betay': 14.293, 'alphay': -3.513})
|
|
reference['Linac3'] = MatchReference('s30cb10.mqua430$start',{'betax': 8.83,'alphax': 0.548,'betay': 30.44,'alphay': -1.866})
|
|
reference['Aramis Stopper'] = MatchReference('sarma01.mqua010$start',{'betax': 2.304, 'alphax': -1.4045, 'betay': 25.929, 'alphay': -6.363})
|
|
reference['Athos HERO'] = MatchReference('satdi01.mqua250$start',{'betax': 35.76, 'alphax': -1.166,'betay': 24.087, 'alphay': 0.648})
|
|
reference['Athos Deflector'] = MatchReference('satbd01.mqua010$start',{'betax': 50, 'alphax': 0,'betay': 50, 'alphay': 0})
|
|
|
|
|
|
settings={'Label':label,'Order':order,'Dependence':dependence,'Reference':reference,'Parameter':parameter}
|
|
|
|
with open(path+label+'.json', 'w', encoding='utf-8') as f:
|
|
json.dump(settings, f, ensure_ascii=False, indent=4) |