Initial tracking done, needs check for other twiss parameters in user defined
This commit is contained in:
@@ -48,6 +48,7 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
self.sandbox.updateSandbox()
|
||||
self.reference = ReferenceManager(parent=self)
|
||||
self.reference.initReferencePoints(self.match)
|
||||
self.updateMatchVariables()
|
||||
|
||||
title = "SwissFEL Optics Tools - Lattice %s (Phase %d)" % (self.model.getLatticeVersion(),phase)
|
||||
if office:
|
||||
@@ -77,11 +78,20 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
aramis = self.UIMatchAramis.isChecked()
|
||||
athos = self.UIMatchAthos.isChecked()
|
||||
porthos = self.UIMatchPorthos.isChecked()
|
||||
twiss = self.match.match(self.model.om,Injector = injector,Athos = athos, Aramis = aramis, Porthos = porthos)
|
||||
if self.UIInitAllMagnets.isChecked():
|
||||
self.model.initializeMagnets()
|
||||
if self.UIModifyKnobs.isChecked():
|
||||
vars = self.getMatchVariables()
|
||||
else:
|
||||
vars = None
|
||||
twiss = self.match.match(self.model.om, variables = vars, Injector = injector,Athos = athos, Aramis = aramis, Porthos = porthos)
|
||||
energy = self.model.calcEnergyProfile(twiss)
|
||||
#enfore the writing of a new lattice so that the magnet settings are in the new lattice
|
||||
self.model.forceLat = True
|
||||
self.plot.newData(twiss, energy)
|
||||
if self.UISaveMatchSettings.isChecked():
|
||||
fileName = self.match.scriptdir+'/settings.json'
|
||||
self.saveSettingsdirect(fileName)
|
||||
|
||||
|
||||
def updateMatchingCase(self):
|
||||
@@ -106,6 +116,26 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI):
|
||||
widget.setChecked(state)
|
||||
widget.setEnabled(state)
|
||||
|
||||
def updateMatchVariables(self):
|
||||
|
||||
nrow = len(self.match.variables.keys())
|
||||
self.UIMatchKnobs.setRowCount(nrow)
|
||||
for irow,key in enumerate(self.match.variables.keys()):
|
||||
self.UIMatchKnobs.setItem(irow, 0, QtWidgets.QTableWidgetItem(key))
|
||||
self.UIMatchKnobs.setItem(irow, 1, QtWidgets.QTableWidgetItem('%f' % self.match.variables[key]['Value']))
|
||||
self.UIMatchKnobs.item(irow, 0).setToolTip(self.match.variables[key]['Description'])
|
||||
self.UIMatchKnobs.resizeColumnsToContents()
|
||||
|
||||
def getMatchVariables(self):
|
||||
variables={}
|
||||
nrow = self.UIMatchKnobs.rowCount()
|
||||
for irow in range(nrow):
|
||||
name = str(self.UIMatchKnobs.item(irow,0).text())
|
||||
val = float(str(self.UIMatchKnobs.item(irow, 1).text()))
|
||||
variables[name]={'Val':val}
|
||||
return variables
|
||||
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.plot.close()
|
||||
event.accept()
|
||||
|
||||
Reference in New Issue
Block a user