From 85b8e899177a12fd89832aa3dec0260a5ec7bb70 Mon Sep 17 00:00:00 2001 From: Sven Date: Wed, 16 Sep 2026 11:31:42 +0200 Subject: [PATCH] Working on the design optics for SF+ --- OpticsTools.py | 3 ++- matchmaker.py | 10 +++++----- model.py | 4 ++-- ui/OpticsToolsGui.py | 4 ++++ ui/OpticsToolsGui.ui | 7 +++++++ 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/OpticsTools.py b/OpticsTools.py index c55515f..1a04c69 100644 --- a/OpticsTools.py +++ b/OpticsTools.py @@ -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 diff --git a/matchmaker.py b/matchmaker.py index aa04137..75489ec 100644 --- a/matchmaker.py +++ b/matchmaker.py @@ -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 diff --git a/model.py b/model.py index e7f8727..f18415d 100644 --- a/model.py +++ b/model.py @@ -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'] diff --git a/ui/OpticsToolsGui.py b/ui/OpticsToolsGui.py index 1e737c4..ce6453a 100644 --- a/ui/OpticsToolsGui.py +++ b/ui/OpticsToolsGui.py @@ -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")) diff --git a/ui/OpticsToolsGui.ui b/ui/OpticsToolsGui.ui index 21f48ea..f700ad3 100644 --- a/ui/OpticsToolsGui.ui +++ b/ui/OpticsToolsGui.ui @@ -500,6 +500,13 @@ + + + + Full output of matching script + + +