From 39ae60b9ecaec39c8febf7fc6d2a42af080bc2c0 Mon Sep 17 00:00:00 2001 From: Sven Date: Mon, 12 Jan 2026 09:59:07 +0100 Subject: [PATCH] Initial tracking done, needs check for other twiss parameters in user defined --- OpticsTools.py | 2 ++ issues.txt | 2 +- model.py | 15 ++++++--------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/OpticsTools.py b/OpticsTools.py index 089c67a..6953beb 100644 --- a/OpticsTools.py +++ b/OpticsTools.py @@ -79,6 +79,8 @@ class OpticsTools(QtWidgets.QMainWindow, Ui_OpticsGUI): porthos = self.UIMatchPorthos.isChecked() twiss = self.match.match(self.model.om,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) diff --git a/issues.txt b/issues.txt index b36c72d..f560373 100644 --- a/issues.txt +++ b/issues.txt @@ -4,7 +4,7 @@ 4) Save matched values (e.g. automatically) 5) Load Reference 6) filter for curent, planned and final phase for matching scripts - +7) support for start twiss for tracking diff --git a/model.py b/model.py index f34028a..d241073 100644 --- a/model.py +++ b/model.py @@ -6,7 +6,7 @@ from onlinemodel.core import Facility from onlinemodel.madx import CMadX #from sipbuild.generator.outputs.formatters import variable -converttwiss= {'betax':'betx','betay':'bety','alphax':'alfx','alphay':'alfy', +converttwiss= {'betx':'betx','bety':'bety','alfx':'alfx','alfy':'alfy', 'etax':'dx','etay':'dy','etapx':'dpx','etapy':'dpy','mux':'mux','muy':'muy', 'x':'x','y':'y','px':'px','py':'py','energy':'energy'} @@ -204,15 +204,12 @@ class Model: def doTrack(self, start,end, refloc, twiss_in, plot = True): - twiss0 = {converttwiss[key]:twiss_in[key] for key in twiss_in.keys()} + print(twiss_in) + twiss0 = {converttwiss[key]:twiss_in[key] for key in twiss_in.keys()} # follows the madx format self.setBranch(end.upper()) - if not refloc == start: - twiss0 = self.doBackTrack(refloc,start,twiss0) - print('Back Tracking Done') - for key in twiss_in.keys(): - if converttwiss[key] in twiss0.keys(): - self.startTwiss[key+'0'] = twiss0[converttwiss[key]] -# self.madx.updateVariables(twiss0) + print("Tracking:",refloc[0:7],start) + if not refloc[0:7] == start: + twiss0 = self.doBackTrack(refloc,start,twiss0) # track backwards to get new initial twiss values twiss = self.madx.track('swissfel',start+'$START',end+'$END',twiss0) energy = self.calcEnergyProfile(twiss) if plot: