91 lines
3.9 KiB
Python
91 lines
3.9 KiB
Python
import json
|
|
|
|
varypar={'min:':-1e-6,'max:':1e-6,'preset':0}
|
|
|
|
def MatchStep(ref,id,end, dest,sequence='SwissFEL',saveTwiss=None):
|
|
match={'Reference':ref,'MatchID':id,'End':end, 'Destination':dest,'Sequence':sequence,'Save':saveTwiss}
|
|
return match
|
|
|
|
def MatchParameter(var0,tar0):
|
|
var={key: varypar for key in var0}
|
|
tar= tar0
|
|
return {'Variable':var,'Target':tar}
|
|
|
|
def MatchReference(loc,twiss):
|
|
match ={'Location': loc, 'Twiss': twiss}
|
|
return match
|
|
|
|
|
|
|
|
#def MatchTar(tar_in)
|
|
# tar_out={}
|
|
# for tar in tar_in:
|
|
# if 'Reference' in tar.key():
|
|
# res=self.getReferenceByTag(tar['Reference'])
|
|
# tar_out[res['Location']]=res['Twiss']
|
|
# return tar_out
|
|
|
|
|
|
|
|
#def MatchFixed(var0,start,cond):
|
|
# var = {key: varypar for key in var0}
|
|
# match={'Variable':var,'Start':start,'Constraint':cond}
|
|
# return match
|
|
|
|
|
|
|
|
|
|
#def MatchPeriodic(seq,var,tar,save):
|
|
# match={'Sequence':seq,'Variable':var,'Target':tar,'Save':save}
|
|
# return match
|
|
|
|
#def MatchCondition(par,val,loc,cond):
|
|
# match={'Parameter':par,'Value':val,'Location':loc,'Condition':cond}
|
|
# return match
|
|
|
|
|
|
|
|
|
|
path ="Settings/"
|
|
label='Reference'
|
|
|
|
order = []
|
|
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','SATBD04'))
|
|
#order.append(MatchStep('Laser Heater', 'Bunch Compressor 1','Fixed','Athos'))
|
|
#order.append(MatchStep('Bunch Compressor 1', 'Linac 1','Periodic','Athos'))
|
|
#order.append(MatchStep('Bunch Compressor 1', 'Match to Linac 1','Dependent','Athos'))
|
|
#order.append(MatchStep('Bunch Compressor 1', 'Bunch Compressor 2','Fixed','Athos'))
|
|
|
|
parameter={}
|
|
var = ['SINLH01-MQUA020', 'SINLH01-MQUA040','SINLH01-MQUA050','SINLH01-MQUA070','SINLH02-MQUA010']
|
|
parameter['Laser Heater'] = MatchParameter(var,[{'Reference':'Laser Heater'}])
|
|
var = ['SINSB04-MQUA130','SINSB04-MQUA230']
|
|
parameter['SINSB04'] = MatchParameter(var,[{'Fixed':{'Location':'#e','Twiss':{'MUX':0.2,'MUY':0.2}}}])
|
|
var = ['SINLH02-MQUA410','SINLH03-MQUA030','SINLH03-MQUA040','SINLH03-MQUA060','SINLH03-MQUA080','SINSB03-MQUA130']
|
|
parameter['Match to SINSB04']=MatchParameter(var,[{'Save':{'Location':'sinsb04$start','SaveID':'SINSB04'}}])
|
|
|
|
|
|
dependence={}
|
|
dependence['SINSB04-MQUA230']=['SINSB03-MQUA230']
|
|
dependence['S10CB01-MQUA230']=['S20CB02-MQUA230','S10DI01-MQUA120'] + ['S20CB%2.2d-MQUA430' %i for i in range(3,9)]
|
|
dependence['S10CB01-MQUA430']=['S20CB02-MQUA430'] + ['S20CB%2.2d-MQUA230' %i for i in range(3,9)]
|
|
|
|
|
|
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.mqua070$start',{'betax': 12.99, 'alphax': 3.7011,'betay': 46.339, 'alphay': -6.501})
|
|
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) |