Files
OpticsTools/matchingmanager.py

70 lines
2.6 KiB
Python

class MatchManager:
def __init__(self,parent=None):
self.parent=parent
self.FODO={}
self.defineFODO()
self.updateFODOWidget()
self.parent.UIMFodoList.currentIndexChanged.connect(self.updateFODOWidget)
def getFODOInfo(self,reference):
"""
retrieve if a seciton is matched and if yes get initial fodo values
:param reference:
:return:
"""
if reference == 'Injector':
a = 1
elif reference == 'Linac 1':
a = 1
elif reference == 'Linac 2':
a = 1
elif reference == 'Linac 3':
a = 1
elif reference == 'Aramis Undulator':
a = 1
elif reference == 'Athos Undulator':
a = 1
###########################
##### generic FODO matching
def updateFODOWidget(self):
reference = self.parent.UIMFodoList.currentText()
if not reference in self.FODO.keys():
print('Not Supported')
return
self.parent.UIMFodoPhase.setText('%7.3f' % self.FODO[reference]['mu'])
self.parent.UIMFodoFlip.setChecked(self.FODO[reference]['FlipPol'])
if self.FODO[reference]['Result'] is None:
self.parent.UIMFodoResult.setText('Not matched yet')
else:
self.parent.UIMFodoResult.setText('%7.3e' % self.FODO[reference]['Result'])
def setFODOParameters(self,par):
reference = self.parent.UIMFodoList.currentText()
if not reference in self.FODO.keys():
print('Not Supported')
return None
self.FODO[reference]=par
self.updateFODOWidget()
def getFODOParameters(self):
reference = self.parent.UIMFodoList.currentText()
if not reference in self.FODO.keys():
print('Not Supported')
return None
self.FODO[reference]['mu'] = float(str(self.parent.UIMFodoPhase.text()))
self.FODO[reference]['FlipPol'] = self.parent.UIMFodoFlip.isChecked()
return self.FODO[reference]
def defineFODO(self):
Periodic={}
Periodic['Injector']={'Sequence':'SINSB04','Destination': 'SARBD01',
'Quads':['sinsb04.mqua130.k1','sinsb04.mqua230.k1'],
'Init':[0.722,-0.7156],'FlipPol':False,'mu':0.2,'Matched':False, 'Twiss':None}
Periodic['Linac 1']={'Sequence':'S10CB01','Destination': 'SARBD01',
'Quads':['s10cb01.mqua230.k1','s10cb01.mqua430.k1'],
'Init':[-1.491,1.4905],'FlipPol':False,'mu':0.1883,'Result':None,'Twiss':None}