Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 29 additions & 29 deletions GUI/ImpactGUI.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
#!/usr/bin/env python3
import sys;
if not "./src/" in sys.path:
sys.path.append("./src/")
if not 'ImpactMainWindow' in sys.modules:
ImpactMainWindow = __import__('ImpactMainWindow')
else:
eval('import ImpactMainWindow')
ImpactMainWindow = eval('reload(ImpactMainWindow)')
root = ImpactMainWindow.ImpactMainWindow()
ImpactMainWindow.MyMenu(root)
root.update()
w = root.winfo_width()
h = root.winfo_height()
ws = root.winfo_screenwidth() # width of the screen
hs = root.winfo_screenheight() # height of the screen
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)
root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.resizable(width=True, height=True)
#root.protocol("WM_DELETE_WINDOW", quitConfirm)
root.mainloop()
root.console.stop()
#!/usr/bin/env python3

import sys;
if not "./src/" in sys.path:
sys.path.append("./src/")
if not 'ImpactMainWindow' in sys.modules:
ImpactMainWindow = __import__('ImpactMainWindow')
else:
eval('import ImpactMainWindow')
ImpactMainWindow = eval('reload(ImpactMainWindow)')

root = ImpactMainWindow.ImpactMainWindow()
ImpactMainWindow.MyMenu(root)

root.update()
w = root.winfo_width()
h = root.winfo_height()
ws = root.winfo_screenwidth() # width of the screen
hs = root.winfo_screenheight() # height of the screen
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)

root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.resizable(width=True, height=True)
#root.protocol("WM_DELETE_WINDOW", quitConfirm)


root.mainloop()
root.console.stop()
20 changes: 10 additions & 10 deletions GUI/Readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
ImpactGUI is a python GUI for the ImpactT and ImpactZ codes.
It can be used on Windows, MAC and Linux/Unix systems.
To use the ImpactGUI, one needs to install
Pyhon3 Tkinter, Numpy, Scipy and Matplotlib.
To run the Impact code under the GUI, one can either put the executables
of ImpactT (ImpactTexe) and ImpactZ (ImpactZexe) under the
/src directory or use the Advanced Setting menue, exe button to
load the executable into the GUI.
The input files for running the Impact code can be either input
by hand or by using the Load button under the File menue.
ImpactGUI is a python GUI for the ImpactT and ImpactZ codes.
It can be used on Windows, MAC and Linux/Unix systems.
To use the ImpactGUI, one needs to install
Pyhon3 Tkinter, Numpy, Scipy and Matplotlib.
To run the Impact code under the GUI, one can either put the executables
of ImpactT (ImpactTexe) and ImpactZ (ImpactZexe) under the
/src directory or use the Advanced Setting menue, exe button to
load the executable into the GUI.
The input files for running the Impact code can be either input
by hand or by using the Load button under the File menue.
1,202 changes: 601 additions & 601 deletions GUI/help/ImpactZv1Readme3.txt

Large diffs are not rendered by default.

58 changes: 28 additions & 30 deletions GUI/iGUI.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
def runGUI():

import sys;
if not "./src/" in sys.path:
sys.path.append("./src/")
if not 'ImpactMainWindow' in sys.modules:
ImpactMainWindow = __import__('ImpactMainWindow')
else:
import ImpactMainWindow
#ImpactMainWindow = eval('reload(ImpactMainWindow)')
root = ImpactMainWindow.ImpactMainWindow()
ImpactMainWindow.MyMenu(root)

root.update()
w = root.winfo_width()
h = root.winfo_height()
ws = root.winfo_screenwidth() # width of the screen
hs = root.winfo_screenheight() # height of the screen
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)

root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.resizable(width=True, height=True)
root.protocol("WM_DELETE_WINDOW", root.exit)

root.mainloop()
root.console.stop()
return root.beam,root.lattice


def runGUI():

import sys;
if not "./src/" in sys.path:
sys.path.append("./src/")
if not 'ImpactMainWindow' in sys.modules:
ImpactMainWindow = __import__('ImpactMainWindow')
else:
import ImpactMainWindow
#ImpactMainWindow = eval('reload(ImpactMainWindow)')
root = ImpactMainWindow.ImpactMainWindow()
ImpactMainWindow.MyMenu(root)

root.update()
w = root.winfo_width()
h = root.winfo_height()
ws = root.winfo_screenwidth() # width of the screen
hs = root.winfo_screenheight() # height of the screen
x = (ws/2) - (w/2)
y = (hs/2) - (h/2)

root.geometry('%dx%d+%d+%d' % (w, h, x, y))
root.resizable(width=True, height=True)
root.protocol("WM_DELETE_WINDOW", root.exit)

root.mainloop()
root.console.stop()
return root.beam,root.lattice
146 changes: 73 additions & 73 deletions GUI/src/ConvertFunc.py
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
# convert from the Trace3d twiss parameter to the IMPACT input distribution parameters.
# Here, the TRACE3d units are, alpha, beta (m/rad), emittance (mm-mrad, rms, unnormalized)
# alpha_z,beta_z (deg/keV), emittance (deg-keV,rms)
#frq(Hz),mass(eV��,kine(eV)
import math
def Twiss2Sigma(alpha,beta,emittance,freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale
emittance = emittance *1.0e-6 # unnormalized emittance
sig1=math.sqrt(beta*emittance/(1.0+alpha**2))
sig2=math.sqrt(emittance/beta)
rho=alpha/math.sqrt(1.0+alpha**2)
sig1 = sig1 / xl
sig2 = sig2 * Egamma*Ebeta
#gammabeta is needed because <x'^2>=emittance*gamma instead of <(px/mc)^2>
return sig1, sig2, rho
def Twiss2SigmaZ(alpha,beta,emittance,freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale
beta=1000.0*beta
eps=1.0e-3*emittance
sig1=math.sqrt(beta*eps/(1.0+alpha**2))/(180.0/math.pi)
sig2=math.sqrt(eps/beta)/mass*1.0e6
rho=-alpha/math.sqrt(1.0+alpha**2)
return sig1, sig2, rho
def Sigma2Twiss(sig1, sig2, rho, freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale
sig1 = sig1 * xl
#gammabeta is needed because <x'^2>=emittance*gamma instead of <(px/mc)^2>
sig2 = sig2 / (Egamma*Ebeta)
alpha = math.sqrt(rho**2/(1-rho**2)) * (1 if rho>0 else -1)
beta = sig1/sig2 * math.sqrt(1+alpha**2)
emittance = sig1*sig2 * math.sqrt(1+alpha**2)
emittance = emittance / 1.0e-6 #mm*mrad
return alpha,beta,emittance
def Sigma2TwissZ(sig1, sig2, rho, freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale
sig1 = sig1*(180.0/math.pi)
#gammabeta is needed because <x'^2>=emittance*gamma instead of <(px/mc)^2>
sig2 = sig2 *mass/1.0e6
alpha = math.sqrt(rho**2/(1-rho**2)) * (1 if rho>0 else -1)
beta = sig1/sig2 * math.sqrt(1+alpha**2)
emittance = sig1*sig2 * math.sqrt(1+alpha**2)
beta = beta / 1000.0 #deg/keV
emittance = emittance / 1.0e-3 #deg*keV
return alpha,beta,emittance
# convert from the Trace3d twiss parameter to the IMPACT input distribution parameters.
# Here, the TRACE3d units are, alpha, beta (m/rad), emittance (mm-mrad, rms, unnormalized)
# alpha_z,beta_z (deg/keV), emittance (deg-keV,rms)
#frq(Hz),mass(eV),kine(eV)


import math

def Twiss2Sigma(alpha,beta,emittance,freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale

emittance = emittance *1.0e-6 # unnormalized emittance

sig1=math.sqrt(beta*emittance/(1.0+alpha**2))
sig2=math.sqrt(emittance/beta)
rho=alpha/math.sqrt(1.0+alpha**2)

sig1 = sig1 / xl
sig2 = sig2 * Egamma*Ebeta

#gammabeta is needed because <x'^2>=emittance*gamma instead of <(px/mc)^2>

return sig1, sig2, rho

def Twiss2SigmaZ(alpha,beta,emittance,freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale

beta=1000.0*beta
eps=1.0e-3*emittance
sig1=math.sqrt(beta*eps/(1.0+alpha**2))/(180.0/math.pi)
sig2=math.sqrt(eps/beta)/mass*1.0e6
rho=-alpha/math.sqrt(1.0+alpha**2)

return sig1, sig2, rho

def Sigma2Twiss(sig1, sig2, rho, freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale

sig1 = sig1 * xl
#gammabeta is needed because <x'^2>=emittance*gamma instead of <(px/mc)^2>
sig2 = sig2 / (Egamma*Ebeta)

alpha = math.sqrt(rho**2/(1-rho**2)) * (1 if rho>0 else -1)
beta = sig1/sig2 * math.sqrt(1+alpha**2)
emittance = sig1*sig2 * math.sqrt(1+alpha**2)

emittance = emittance / 1.0e-6 #mm*mrad

return alpha,beta,emittance

def Sigma2TwissZ(sig1, sig2, rho, freq,mass,kine):
Egamma = 1 + kine/mass
Ebeta = math.sqrt(1.0-1.0/Egamma/Egamma)
xl=2.99792458e8/(2.0*math.pi*freq) # Length scale

sig1 = sig1*(180.0/math.pi)
#gammabeta is needed because <x'^2>=emittance*gamma instead of <(px/mc)^2>
sig2 = sig2 *mass/1.0e6

alpha = math.sqrt(rho**2/(1-rho**2)) * (1 if rho>0 else -1)
beta = sig1/sig2 * math.sqrt(1+alpha**2)
emittance = sig1*sig2 * math.sqrt(1+alpha**2)

beta = beta / 1000.0 #deg/keV
emittance = emittance / 1.0e-3 #deg*keV

return alpha,beta,emittance
106 changes: 53 additions & 53 deletions GUI/src/ImpactFile.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
def conciseReadInput(inputFileName):
try:
fin = open(inputFileName,'r')
dataList = fin.readlines()
fin.close()
except:
print(( " ERROR! Can't open file '" + inputFileName + "'"))
return False
i=0
while i < len(dataList):
if dataList[i].lstrip()=='' or dataList[i].lstrip().startswith('!'):
del dataList[i]
i=i-1
else:
index = dataList[i].lstrip().find('!')
if index==-1:
dataList[i]=dataList[i].strip()+'\n'
else:
dataList[i]=dataList[i].lstrip()[:index].rstrip()+'\n'
i=i+1
dataList = [line.split() for line in dataList ]
for i in range(0,len(dataList)):
for j in range(0,len(dataList[i])):
dataList[i][j] = DtoE(dataList[i][j])
return dataList
def conciseWriteInput(dataList,outputFileName):
try:
fin = open(outputFileName,'w')
except:
print(( " ERROR! Can't open file '" + outputFileName + "'"))
return False
for line in dataList:
for elem in line:
ImpactInput.writelines(elem+' ')
ImpactInput.writelines('\n')
return
def DtoE(word):
if 'D' in word or 'd' in word:
try:
temp = float(word.replace('D','E',1).replace('d','e',1))
return str(temp)
except:
return word
else:
return word

def conciseReadInput(inputFileName):
try:
fin = open(inputFileName,'r')
dataList = fin.readlines()
fin.close()
except:
print(( " ERROR! Can't open file '" + inputFileName + "'"))
return False

i=0
while i < len(dataList):
if dataList[i].lstrip()=='' or dataList[i].lstrip().startswith('!'):
del dataList[i]
i=i-1
else:
index = dataList[i].lstrip().find('!')
if index==-1:
dataList[i]=dataList[i].strip()+'\n'
else:
dataList[i]=dataList[i].lstrip()[:index].rstrip()+'\n'
i=i+1
dataList = [line.split() for line in dataList ]

for i in range(0,len(dataList)):
for j in range(0,len(dataList[i])):
dataList[i][j] = DtoE(dataList[i][j])
return dataList


def conciseWriteInput(dataList,outputFileName):
try:
fin = open(outputFileName,'w')
except:
print(( " ERROR! Can't open file '" + outputFileName + "'"))
return False

for line in dataList:
for elem in line:
ImpactInput.writelines(elem+' ')
ImpactInput.writelines('\n')
return


def DtoE(word):
if 'D' in word or 'd' in word:
try:
temp = float(word.replace('D','E',1).replace('d','e',1))
return str(temp)
except:
return word
else:
return word
Loading