Working on the design optics for SF+
This commit is contained in:
1 parent
85e73c09d5
commit
85b8e89917
5 files changed
+20
-8
No files matched your search
+2
-1
@@ -77,6 +77,7 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
|
||||
The online model is updated with the updated match values.
|
||||
:return: None
|
||||
"""
|
||||
fullOutput = self.UIFullOutput.isChecked()
|
||||
injector = self.UIMatchInjector.isChecked()
|
||||
aramis = self.UIMatchAramis.isChecked()
|
||||
athos = self.UIMatchAthos.isChecked()
|
||||
@@ -92,7 +93,7 @@ class OpticsTools(QtWidgets.QMainWindow, QtCore.QObject, Ui_OpticsGUI):
|
||||
inittwiss['betay'] = float(str(self.UIInitBetay.text()))
|
||||
inittwiss['alphax'] = float(str(self.UIInitAlphax.text()))
|
||||
inittwiss['alphay'] = float(str(self.UIInitAlphay.text()))
|
||||
twiss = self.match.match(self.model.om, variables = vars, initCond = inittwiss, Injector = injector,Athos = athos, Aramis = aramis, Porthos = porthos)
|
||||
twiss = self.match.match(self.model.om, variables = vars, initCond = inittwiss, Injector = injector,Athos = athos, Aramis = aramis, Porthos = porthos, full = fullOutput)
|
||||
self.updateMatchResult(self.match.matchresult)
|
||||
energy = self.model.calcEnergyProfile(twiss)
|
||||
#enfore the writing of a new lattice so that the magnet settings are in the new lattice
|
||||
|
||||
+5
-5
@@ -82,7 +82,7 @@ class MatchMaker:
|
||||
|
||||
|
||||
|
||||
def match(self, om, variables = None, initCond=None, Injector=True, Athos = True, Aramis = False, Porthos = False):
|
||||
def match(self, om, variables = None, initCond=None, Injector=True, Athos = True, Aramis = False, Porthos = False, full =False):
|
||||
|
||||
self.matchresult.clear()
|
||||
cwd = os.getcwd()
|
||||
@@ -110,13 +110,13 @@ class MatchMaker:
|
||||
print('Matching Injector ...')
|
||||
madx.madx.call('matchInjector.madx')
|
||||
self.updateOnlineModel(om,madx.madx, self.filter['injector'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'),'Injector')
|
||||
self.parseMatchOutput(f.getvalue().split('\n'),'Injector',full=full)
|
||||
if Athos:
|
||||
f.truncate(0)
|
||||
print('Matching Athos ...')
|
||||
madx.madx.call('matchAthos.madx')
|
||||
self.updateOnlineModel(om, madx.madx, self.filter['athos'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Athos')
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Athos',full=full)
|
||||
if Aramis:
|
||||
f.truncate(0)
|
||||
print('Matching Aramis ...')
|
||||
@@ -128,7 +128,7 @@ class MatchMaker:
|
||||
madx.madx.call('initTwiss.madx')
|
||||
madx.madx.call('matchAramis.madx')
|
||||
self.updateOnlineModel(om, madx.madx, self.filter['aramis'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Aramis')
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Aramis',full=full)
|
||||
|
||||
if Porthos:
|
||||
f.truncate(0)
|
||||
@@ -141,7 +141,7 @@ class MatchMaker:
|
||||
madx.madx.call('initTwiss.madx')
|
||||
madx.madx.call('matchPorthos.madx')
|
||||
self.updateOnlineModel(om, madx.madx, self.filter['porthos'])
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Porthos')
|
||||
self.parseMatchOutput(f.getvalue().split('\n'), 'Porthos',full=full)
|
||||
os.chdir(cwd)
|
||||
return madx.madx.table.twiss
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ class Model:
|
||||
|
||||
|
||||
def doTrack(self, start,end, refloc, twiss_in, plot = True):
|
||||
print(twiss_in)
|
||||
#print(twiss_in)
|
||||
twiss0 = {converttwiss[key]:twiss_in[key] for key in twiss_in.keys()} # follows the madx format
|
||||
self.setBranch(end.upper())
|
||||
print("Tracking:",refloc[0:7],start)
|
||||
@@ -237,7 +237,7 @@ class Model:
|
||||
|
||||
|
||||
def doBackTrack(self,start=None,end=None,twiss0=None):
|
||||
print('Backtracking 1:',twiss0)
|
||||
#print('Backtracking 1:',twiss0)
|
||||
twiss0['alfx'] = -twiss0['alfx'] # revert particle trajectories
|
||||
twiss0['alfy'] = -twiss0['alfy']
|
||||
twiss0['dpx'] = -twiss0['dpx']
|
||||
|
||||
@@ -313,6 +313,9 @@ class Ui_OpticsGUI(object):
|
||||
self.UIMatchOpticsSelect.setObjectName("UIMatchOpticsSelect")
|
||||
self.horizontalLayout.addWidget(self.UIMatchOpticsSelect)
|
||||
self.verticalLayout_3.addLayout(self.horizontalLayout)
|
||||
self.UIFullOutput = QtWidgets.QCheckBox(self.widget)
|
||||
self.UIFullOutput.setObjectName("UIFullOutput")
|
||||
self.verticalLayout_3.addWidget(self.UIFullOutput)
|
||||
self.matchbranches = QtWidgets.QGroupBox(self.widget)
|
||||
font = QtGui.QFont()
|
||||
font.setBold(True)
|
||||
@@ -763,6 +766,7 @@ class Ui_OpticsGUI(object):
|
||||
self.label_13.setText(_translate("OpticsGUI", "Status"))
|
||||
self.UIMatchSelected.setText(_translate("OpticsGUI", "Match Selected"))
|
||||
self.label_31.setText(_translate("OpticsGUI", "Matched Optics"))
|
||||
self.UIFullOutput.setText(_translate("OpticsGUI", "Full output of matching script"))
|
||||
self.matchbranches.setTitle(_translate("OpticsGUI", "Branches"))
|
||||
self.UIMatchInjector.setText(_translate("OpticsGUI", "Injector"))
|
||||
self.UIMatchPorthos.setText(_translate("OpticsGUI", "Porthos"))
|
||||
|
||||
@@ -500,6 +500,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="UIFullOutput">
|
||||
<property name="text">
|
||||
<string>Full output of matching script</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="matchbranches">
|
||||
<property name="font">
|
||||
|
||||
Reference in new issue
Block a user