Commit 90d47e5a authored by reiche's avatar reiche
Browse files

Update to Lattice 10.4.7

parent 80aa2bf0
......@@ -229,7 +229,12 @@ import math
# 6) Move CDR in S20SY03 to SARCL01
# Layout 10.4.5
# 1) Adding Undulator SATUN08
# 1) Complete Undulator installation in Athos
# 2) Installation of the dechirper girder in SATDI01 for current layout
# 3) Keep last girders in SATDI01 for final layout
# 4) Till the modulator is not installed the BPM and Quad before the SATDI dechirper are not enabled
# 5) The first bpm and quad on the girder after the SATDI dechirper are disabled and the names are moved to the BPM and quad directly after the dechirper
# 6) Added first draft for FCC experiment beam line at Porthos
class SwissFEL:
def __init__(self,alt=0):
......@@ -536,6 +541,30 @@ class SwissFEL:
TM.define('MKBR',indict)
# FCC experiment
indict={'Type':'Vacuum','Length':0.1,'Tag':'FCRY','Baugruppe': 'FCC-Crystal'}
TM.define('FCC-Crystal',indict)
indict={'Type':'Vacuum','Length':0.1,'Tag':'FTAR','Baugruppe': 'FCC-Target'}
TM.define('FCC-Target',indict)
indict={'Type':'Dipole','Length':0.8,'cor':0,'Baugruppe':'AFSC'}
TM.define('AFSC',indict)
indict={'Type':'RF','Length': 1.2,'LengthRes':1.4,'Band':'S','Baugruppe':'S-BAND-ACC-FCC'}
TM.define('FCC-RF-ACC',indict)
indict={'Type':'Solenoid','Length':0.5,'Baugruppe':'WFFCC'}
TM.define('WFFCC',indict)
indict={'Type':'Solenoid','Length':0.02,'Baugruppe':'WFAMD'}
TM.define('WFAMD',indict)
indict={'Type':'Diagnostic','Length':0.20,'Baugruppe':'DBPM-FCC'}
TM.define('DBPM-FCC',indict)
indict={'Type':'Diagnostic','Length':0.20,'Tag':'DSCR','Baugruppe':'DSCR-FCC'}
TM.define('DSCR-FCC',indict)
indict={'Type':'Diagnostic','Length':0.20,'Tag':'DSCR','Baugruppe':'DSCR-SPEC-FCC'}
TM.define('DSCR-SPEC-FCC',indict)
indict={'Type':'Dipole','Length':0.5,'Baugruppe':'SHA-SPEC'}
TM.define('SHA-FCC',indict)
indict={'Type':'Vacuum','Length':1,'Tag':'SDMP','Baugruppe':'BEAM-DUMP-FCC'}
TM.define('Beam-Dump-FCC',indict)
def Lines(self,TM):
# defines common lines in the lattice
......@@ -1049,36 +1078,38 @@ class SwissFEL:
CB14.append(TM.generate('DBPM-C16',420),4.33,'relative')
CB14.append(TM.generate('QFD',430),0.049,'relative')
CB14.append(TM.generate('COL-TR-16',440),0.019,'relative')
if self.alt < 3:
CB15=OMType.LineContainer('CB15', 9.1)
CB15.append(TM.generate('COL-Dechirper-H',100),1-0.315,'relative')
CB15.append(TM.generate('COL-Dechirper-V',200),1+0.315-0.465,'relative')
CB15.append(TM.generate('DBPM-C16',420),4.465+0.465,'relative')
CB15.append(TM.generate('QFD',430),0.049,'relative')
CB16=OMType.LineContainer('CB16', 1.3)
else:
CB15=OMType.LineContainer('CB15', 9.3)
CB15.append(TM.generate('RESKICKDC',10,{'design_kick':0}),0.285,'relative')
CB15.append(TM.generate('RESKICKAC',20,{'design_kick':0}),0.0,'relative')
CB15.append(TM.generate('RESKICKDC',30,{'design_kick':0}),0.0,'relative')
CB15.append(TM.generate('RESKICKAC',40,{'design_kick':0}),0.0,'relative')
CB15.append(TM.generate('RESKICKDC',50,{'design_kick':0}),0.0,'relative')
CB15.append(TM.generate('SFC',60),0.080,'relative')
CB15.append(TM.generate('QFA',70),0.105,'relative')
CB15.append(TM.generate('DBPM-C38',80),1.33-0.12,'relative')
CB15.append(TM.generate('SFC',90),0.08,'relative')
CB15.append(TM.generate('QFA',100),0.105,'relative')
CB15.append(TM.generate('DBPM-C38',120),1.33-0.12,'relative')
CB15.append(TM.generate('SFC',130),0.08,'relative')
CB15.append(TM.generate('QFA',140),0.105,'relative')
CB15.append(TM.generate('DBPM-C38',150),1.18-0.24,'relative')
CB15.append(TM.generate('DWSC-C38',160),0.12,'relative')
CB15.append(TM.generate('SFC',170),0.08,'relative')
CB15.append(TM.generate('QFA',180),0.105,'relative')
CB16=OMType.LineContainer('CB16', 1.3)
CB16.append(TM.generate('AFDL',100,{'angle':0,'design_angle':-2,'e1':0.5,'e2':0.5,'branch':True}),0.300,'relative')
CB15=OMType.LineContainer('CB15', 9.1)
CB15.append(TM.generate('COL-Dechirper-H',100),1-0.315,'relative')
CB15.append(TM.generate('COL-Dechirper-V',200),1+0.315-0.465,'relative')
CB15.append(TM.generate('DBPM-C16',420),4.465+0.465,'relative')
CB15.append(TM.generate('QFD',430),0.049,'relative')
CB16=OMType.LineContainer('CB16', 1.3)
if self.alt > 1:
CB16.append(TM.generate('AFBC4',100,{'angle':0,'design_angle':-2,'e1':0.5,'e2':0.5,'branch':True}),0.300,'relative')
CB16.append(TM.generate('MKBR',101),0.,'relative')
# else:
# CB15=OMType.LineContainer('CB15', 9.3)
# CB15.append(TM.generate('RESKICKDC',10,{'design_kick':0}),0.285,'relative')
# CB15.append(TM.generate('RESKICKAC',20,{'design_kick':0}),0.0,'relative')
# CB15.append(TM.generate('RESKICKDC',30,{'design_kick':0}),0.0,'relative')
# CB15.append(TM.generate('RESKICKAC',40,{'design_kick':0}),0.0,'relative')
# CB15.append(TM.generate('RESKICKDC',50,{'design_kick':0}),0.0,'relative')
# CB15.append(TM.generate('SFC',60),0.080,'relative')
# CB15.append(TM.generate('QFA',70),0.105,'relative')
# CB15.append(TM.generate('DBPM-C38',80),1.33-0.12,'relative')
# CB15.append(TM.generate('SFC',90),0.08,'relative')
# CB15.append(TM.generate('QFA',100),0.105,'relative')
# CB15.append(TM.generate('DBPM-C38',120),1.33-0.12,'relative')
# CB15.append(TM.generate('SFC',130),0.08,'relative')
# CB15.append(TM.generate('QFA',140),0.105,'relative')
# CB15.append(TM.generate('DBPM-C38',150),1.18-0.24,'relative')
# CB15.append(TM.generate('DWSC-C38',160),0.12,'relative')
# CB15.append(TM.generate('SFC',170),0.08,'relative')
# CB15.append(TM.generate('QFA',180),0.105,'relative')
# CB16=OMType.LineContainer('CB16', 1.3)
L3Line =[CB01,CB02,CB03,CB04,CB05,CB06,CB07,CB08,CB09,CB10,CB11,CB12,CB13,CB14,CB15,CB16]
Linac30=OMType.LineContainer('30')
Linac30.append(L3Line)
......@@ -1370,7 +1401,7 @@ class SwissFEL:
DI01=OMType.LineContainer('DI01', 18.52)
# Girder 1
if self.alt>1:
if self.alt>1: # temporarily changing this to planned, was before self.alt>1
DI01.append(TM.generate('DBCM-IR',10),0.4,'relative')
DI01.append(TM.generate('DICT-C16',20),0.46,'relative')
DI01.append(TM.generate('QFD',25),0.15,'relative')
......@@ -1397,40 +1428,32 @@ class SwissFEL:
DI01.append(TM.generate('DWSC-C16',65),0.12,'relative')
DI01.append(TM.generate('DBAM-FS16',70),0.1+0.06+0.02+0.23,'relative')
# girder 2
if self.alt > 0:
if self.alt > 1:
DI01.append(TM.generate('QFD',80),2.15-1.563-0.397-0.02,'relative')
DI01.append(TM.generate('DBPM-C16',90),0.063,'relative')
DI01.append(TM.generate('COL-Dechirper-H',100,{'gap':2e-3}),0.5+0.087,'relative')
DI01.append(TM.generate('COL-Dechirper-V',200,{'gap':2e-3}),0.5+0.35,'relative')
DI01.append(TM.generate('DBPM-C16',210),0.5+0.019+0.115+0.327-0.437,'relative')
DI01.append(TM.generate('QFD',230),0.081,'relative')
else:
DI01.append(TM.generate('DBPM-C16',210),0.5+0.019+2+3.58-0.23-0.255,'relative')
DI01.append(TM.generate('QFD',220),0.1-0.019,'relative')
DI01.append(TM.generate('QFD',230),1.25,'relative')
# girder 3
DI01.append(TM.generate('COL-Dechirper-H',100,{'gap':2e-3}),0.7+0.087+0.2186+0.1644,'relative')
DI01.append(TM.generate('COL-Dechirper-V',200,{'gap':2e-3}),0.5+0.35,'relative')
DI01.append(TM.generate('DBPM-C16',210),0.5+0.019+0.115+0.327-0.437,'relative')
DI01.append(TM.generate('QFD',220),0.081,'relative')
# DI01.append(TM.generate('DBPM-C16',222),0.5+0.019+2+3.58-0.23-0.255-4.975,'relative')
# DI01.append(TM.generate('QFD',225),0.1-0.019,'relative')
DI01.append(TM.generate('QFD',230),1.25+0.7+0.37,'relative')
DI01.append(TM.generate('DBPM-C16',240),1.05-0.001,'relative')
DI01.append(TM.generate('QFD',250),0.101,'relative')
DI01.append(TM.generate('QFD',260),1.25,'relative')
DI01.append(TM.generate('DBPM-C16',270),1.05-0.021,'relative')
DI01.append(TM.generate('QFD',280),0.121,'relative')
if self.alt > 1:
DI01.append(TM.generate('DBPM-C16',240),1.2-0.001-0.327,'relative')
DI01.append(TM.generate('QFD',250),0.101,'relative')
DI01.append(TM.generate('QFD',260),1.4,'relative')
DI01.append(TM.generate('DBPM-C16',270),1.2-0.021+0.117-0.2,'relative')
DI01.append(TM.generate('QFD',280),0.121-0.117,'relative')
DI01.append(TM.generate('DWSC-C16',290),2,'relative')
DI01.append(TM.generate('QFD',300),0.4-0.137,'relative')
DI01.append(TM.generate('DBPM-C16',310),0.04,'relative')
DI01.append(TM.generate('DWSC-C16',290),0.1+0.729,'relative')
DI01.append(TM.generate('QFD',300),0.163+0.137+0.85-0.237-0.729,'relative')
else:
if self.alt == 0:
DI01.append(TM.generate('DBPM-C16',240),1.05-0.001,'relative')
else:
DI01.append(TM.generate('DBPM-C16',240),1.05-0.001+2.57,'relative')
DI01.append(TM.generate('QFD',250),0.101,'relative')
DI01.append(TM.generate('QFD',260),1.25,'relative')
DI01.append(TM.generate('DBPM-C16',270),1.05-0.021,'relative')
DI01.append(TM.generate('QFD',280),0.121,'relative')
DI01.append(TM.generate('QFD',300),0.163+0.137+0.85,'relative')
DI01.append(TM.generate('DBPM-C16',310),0.04,'relative')
DI01.append(TM.generate('DBPM-C16',310),0.04,'relative')
# needs a wire scanner here
CB01=OMType.LineContainer('CB01',9.8)
CB02=OMType.LineContainer('CL02',9.8)
......@@ -1541,13 +1564,8 @@ class SwissFEL:
UN05.append(TM.generate('DBPM-C5',410),0.18+0.00775,'relative')
UN05.append(TM.generate('QFF',420),0.06025-0.00775+0.005,'relative')
if self.alt < 1:
UN06=TM.generate('UE38-Cell-Empty',0,{'Name':'UN06'})
UN07=TM.generate('UE38-Cell-Empty',0,{'Name':'UN07'})
else:
UN06=TM.generate('UE38-Cell',0,{'Name':'UN06'})
UN07=TM.generate('UE38-Cell',0,{'Name':'UN07'})
UN06=TM.generate('UE38-Cell',0,{'Name':'UN06'})
UN07=TM.generate('UE38-Cell',0,{'Name':'UN07'})
UN08=TM.generate('UE38-Cell',0,{'Name':'UN08'})
UN09=TM.generate('UE38-Cell',0,{'Name':'UN09'})
UN10=TM.generate('UE38-Cell',0,{'Name':'UN10'})
......@@ -1635,57 +1653,108 @@ class SwissFEL:
#
# Porthos Branch
# Porthos Branch for FCC experiment
#
dx=0
SY01=OMType.LineContainer('SY01', 0)
SY01.append(OMType.Alignment({'dy':0.01,'Tag':'ALIG','index':1}))
SY01.append(TM.generate('QFM',10),4,'relative')
SY01.append(TM.generate('QFM',20),5,'relative')
SY01.append(TM.generate('QFM',21),1,'relative')
SY01.append(TM.generate('DBPM-C16',25),0.1,'relative')
SY01.append(TM.generate('QFM',29),0,'relative')
SY01.append(TM.generate('QFM',30),1,'relative')
SY01.append(TM.generate('QFM',40),5,'relative')
SY01.append(TM.generate('AFBC4',100,{'angle':-2,'design_angle':-2,'e1':0.5,'e2':0.5}),4,'relative')
SY02=OMType.LineContainer('SY02', 6.9)
SY02.append(TM.generate('QFM',10),0.2,'relative')
SY02.append(TM.generate('AFL',100,{'angle':0.10800,'design_angle':0.10800,'e1':0,'e2':1.,'Tilt':math.asin(1)}),0.2,'relative')
SY02.append(TM.generate('QFM',110),1.29-0.45,'relative')
SY02.append(TM.generate('QFM',120),2.1,'relative')
SY02.append(TM.generate('AFL',200,{'angle':-0.10800,'design_angle':-0.10800,'e1':1,'e2':0.,'Tilt':math.asin(1)}),1.29-0.45,'relative')
SY03=OMType.LineContainer('SY03', 22.044)
dx=3.5388
SY03.append(TM.generate('QFM',10),0.1,'relative')
SY03.append(TM.generate('QFM',20),dx,'relative')
SY03.append(TM.generate('QFM',30),dx,'relative')
SY03.append(TM.generate('QFM',40),dx,'relative')
SY03.append(TM.generate('QFM',50),dx,'relative')
SY03.append(TM.generate('QFM',60),dx,'relative')
if self.alt >1:
SY01=OMType.LineContainer('SY01', 0)
# SY01.append(OMType.Alignment({'dy':0.01,'Tag':'ALIG','index':1}))
SY01.append(TM.generate('DBPM-C16',10),3.8,'relative')
SY01.append(TM.generate('QFM',20),0.1,'relative')
SY01.append(TM.generate('SFQFM',30),0.1,'relative')
SY01.append(TM.generate('QFM',40),3.6,'relative')
SY01.append(TM.generate('SFQFM',50),0.1,'relative')
SY01.append(TM.generate('DBPM-C16',60),0.6,'relative')
SY01.append(TM.generate('QFM',70),0.9,'relative')
SY01.append(TM.generate('SFQFM',80),0.1,'relative')
SY01.append(TM.generate('QFM',90),3.6,'relative')
SY01.append(TM.generate('SFQFM',100),0.1,'relative')
SY01.append(TM.generate('AFBC4',200,{'angle':-2,'design_angle':-2,'e1':0.5,'e2':0.5}),3.6,'relative')
SY02=OMType.LineContainer('SY02', 8.6+0.237)
SY02.append(TM.generate('QFM',10),0.2,'relative')
SY02.append(TM.generate('SFQFM',20),0.1,'relative')
SY02.append(TM.generate('DBPM-C16',30),0.9,'relative')
SY02.append(TM.generate('QFM',40),0.1,'relative')
SY02.append(TM.generate('SFQFM',50),0.1,'relative')
SY02.append(TM.generate('QFM',60),1.1,'relative')
SY02.append(TM.generate('DBPM-C16',70),1.3,'relative')
SY02.append(TM.generate('QFM',80),0.1,'relative')
SY02.append(TM.generate('SFQFM',90),0.1,'relative')
SY02.append(TM.generate('DBPM-C16',100),0.6,'relative')
SY02.append(TM.generate('DSCR-OV16',170),0.1,'relative')
FC01=OMType.LineContainer('FC01', 10.)
FC01.append(TM.generate('FCC-Crystal',10),0.1,'relative')
FC01.append(TM.generate('AFSC',100,{'angle':0,'design_angle':0,'e1':0.5,'e2':0.5}),0.1,'relative')
FC01.append(TM.generate('FCC-Target',110),1.2,'absolute')
FC01.append(TM.generate('WFAMD',120),1.3,'absolute')
FC01.append(TM.generate('FCC-RF-ACC',200),1.35,'absolute')
FC01.append(TM.generate('WFFCC',210),1.45,'absolute')
FC01.append(TM.generate('WFFCC',220),2.15,'absolute')
FC01.append(TM.generate('FCC-RF-ACC',300),2.75,'absolute')
FC01.append(TM.generate('WFFCC',310),2.85,'absolute')
FC01.append(TM.generate('WFFCC',320),3.55,'absolute')
FC01.append(TM.generate('DBPM-FCC',330),4.25,'absolute')
FC01.append(TM.generate('DSCR-FCC',340),0.1,'relative')
FC01.append(TM.generate('SHA-FCC',400,{'angle':0,'design_angle':0,'e1':0.5,'e2':0.5}),0.1,'relative')
FC01.append(TM.generate('DSCR-SPEC-FCC',410),0.7,'relative')
FC01.append(TM.generate('Beam-Dump-FCC',420),0.2,'relative')
if self.alt > 10:
dx=0
SY01=OMType.LineContainer('SY01', 0)
SY01.append(OMType.Alignment({'dy':0.01,'Tag':'ALIG','index':1}))
SY01.append(TM.generate('QFM',10),4,'relative')
SY01.append(TM.generate('QFM',20),5,'relative')
SY01.append(TM.generate('QFM',21),1,'relative')
SY01.append(TM.generate('DBPM-C16',25),0.1,'relative')
SY01.append(TM.generate('QFM',29),0,'relative')
SY01.append(TM.generate('QFM',30),1,'relative')
SY01.append(TM.generate('QFM',40),5,'relative')
SY01.append(TM.generate('AFBC4',100,{'angle':-2,'design_angle':-2,'e1':0.5,'e2':0.5}),4,'relative')
SY02=OMType.LineContainer('SY02', 6.9)
SY02.append(TM.generate('QFM',10),0.2,'relative')
SY02.append(TM.generate('AFL',100,{'angle':0.10800,'design_angle':0.10800,'e1':0,'e2':1.,'Tilt':math.asin(1)}),0.2,'relative')
SY02.append(TM.generate('QFM',110),1.29-0.45,'relative')
SY02.append(TM.generate('QFM',120),2.1,'relative')
SY02.append(TM.generate('AFL',200,{'angle':-0.10800,'design_angle':-0.10800,'e1':1,'e2':0.,'Tilt':math.asin(1)}),1.29-0.45,'relative')
SY03=OMType.LineContainer('SY03', 22.044)
dx=3.5388
SY03.append(TM.generate('QFM',10),0.1,'relative')
SY03.append(TM.generate('QFM',20),dx,'relative')
SY03.append(TM.generate('QFM',30),dx,'relative')
SY03.append(TM.generate('QFM',40),dx,'relative')
SY03.append(TM.generate('QFM',50),dx,'relative')
SY03.append(TM.generate('QFM',60),dx,'relative')
SY04=OMType.LineContainer('SY04', 24.9)
SY04.append(TM.generate('AFBC4',100,{'angle':2,'design_angle':2,'e1':0.5,'e2':0.5}),0.2,'relative')
SY04.append(TM.generate('QFM',110),4,'relative')
SY04.append(TM.generate('QFM',120),4,'relative')
SY04.append(TM.generate('DBPM-C16',125),1,'relative')
SY04.append(TM.generate('QFM',130),0.9,'relative')
SY04.append(TM.generate('QFM',140),4,'relative')
SY04.append(TM.generate('AFBC4',200,{'angle':2,'design_angle':2,'e1':0.5,'e2':0.5}),4,'relative')
SY04=OMType.LineContainer('SY04', 24.9)
SY04.append(TM.generate('AFBC4',100,{'angle':2,'design_angle':2,'e1':0.5,'e2':0.5}),0.2,'relative')
SY04.append(TM.generate('QFM',110),4,'relative')
SY04.append(TM.generate('QFM',120),4,'relative')
SY04.append(TM.generate('DBPM-C16',125),1,'relative')
SY04.append(TM.generate('QFM',130),0.9,'relative')
SY04.append(TM.generate('QFM',140),4,'relative')
SY04.append(TM.generate('AFBC4',200,{'angle':2,'design_angle':2,'e1':0.5,'e2':0.5}),4,'relative')
# straight layout constraints:
# total length frm straight ahead to dump dipole: 160 m
# distance between end of undulator to dump dipole: 25 m
SY05=OMType.LineContainer('SY05', 22.4)
SY05.append(TM.generate('QFM',10),0.5,'relative')
SY05.append(TM.generate('QFM',20),10,'relative')
SY05.append(TM.generate('QFM',30),10,'relative')
SY05=OMType.LineContainer('SY05', 22.4)
SY05.append(TM.generate('QFM',10),0.5,'relative')
SY05.append(TM.generate('QFM',20),10,'relative')
SY05.append(TM.generate('QFM',30),10,'relative')
PoLine=[SY01,SY02,SY03,SY04,SY05]
PoLine=[]
if self.alt > 1:
PoLine=[SY01,SY02,FC01]
Porthos=OMType.LineContainer('PO')
Porthos.append(PoLine)
......@@ -1708,7 +1777,7 @@ class SwissFEL:
# BranchIndex=-1 -> added to the end of the parent line
# BranchIndex=0 -> Beamline is the root element
if self.alt < 3:
if self.alt < 2:
PartsList=[[Injector, -1, 0,'SwissFEL Injector'], #0
[Linac, 0,-1,'SwissFEL Linac'], #1
[Aramis, 1,-1,'Aramis beamline'], #2
......
This diff is collapsed.
This diff is collapsed.
......@@ -20,6 +20,7 @@ class Dechirper:
def getWake(self,gap, element='', writeSDDS=''):
# emperical length of single particle wake
print('Calculating Dechirper Wake for gap: %e m' % gap)
s0 = 0.5e-3
if 'SINSB05' in element:
s0 = 10e-3
......
......@@ -30,13 +30,13 @@ class Elegant(ElegantLattice):
def writeInputDeck(self, path,name, dist):
def writeInputDeck(self, path, name, dist):
self.charge=dist.q
filename='%s/%s.ele' % (path,name)
self.fid=open(filename,'w')
self.fid.write('&run_setup\n')
self.fid.write('\tlattice\t\t=%s/%s.lat,\n' % (path,name))
self.fid.write('\tlattice\t\t= %s.lat,\n' % (name))
self.fid.write('\tuse_beamline\t= SwissFEL,\n')
self.fid.write('\trootname\t= %s,\n' % name)
self.fid.write('\toutput\t\t= %s.out,\n')
......@@ -52,7 +52,10 @@ class Elegant(ElegantLattice):
self.fid.write('\tconcat_order\t= 0,\n')
self.fid.write('\tprint_statistics\t= 0,\n')
self.fid.write('\trandom_number_seed\t= 9876543210,\n')
self.fid.write('\tp_central\t= %f,\n' % dist.p0)
if self.p0 is None:
self.fid.write('\tp_central\t= %f,\n' % dist.p0)
else:
self.fid.write('\tp_central\t= %f,\n' % self.p0)
self.fid.write('\ttracking_updates\t= 1\n')
self.fid.write('\talways_change_p0\t= 1\n')
self.fid.write('&end\n\n')
......@@ -75,10 +78,11 @@ class Elegant(ElegantLattice):
self.fid.write('&end\n\n')
if dist.loaded:
dpath=dist.sddsfile.split('/')
self.fid.write('&sdds_beam\n')
self.fid.write('\tinput_type= "elegant",\n')
self.fid.write('\tsample_interval\t= %d,\n' % self.distsample)
self.fid.write('\tinput = %s,\n' % dist.sddsfile)
self.fid.write('\tinput = %s,\n' % dpath[-1])
self.fid.write('\treuse_bunch\t= 0 \n')
self.fid.write('&end\n\n')
else:
......
......@@ -11,6 +11,7 @@ class ElegantLattice(ApplicationTemplate):
ApplicationTemplate.__init__(self)
self.seq=[]
self.p0=None
self.fid=0
self.lsc=0 # flag whether lsc is enabled
self.lscbins=100 # number of bins for lsc calculation
......@@ -28,12 +29,14 @@ class ElegantLattice(ApplicationTemplate):
def openLatticeStream(self,path,name):
filename='%s/%s.lat' % (path,name)
self.path=path
# self.path=path
self.path='.'
self.savepath=path
self.seq=[]
self.fid=open(filename,'w')
self.driftcount=1
self.write('Q: CHARGE, TOTAL=%e\n' % self.charge)
self.write('ALTER: MALIGN\n')
self.write('ALTER: CENTER, DELTA=1\n') # put the beam on the right energy
def closeLatticeStream(self):
......@@ -106,7 +109,10 @@ class ElegantLattice(ApplicationTemplate):
return name
def writeMarker(self,ele):
self.write('%s: MARK \n' % (ele.Name))
if 'ALIG' in ele.Name and 'dy' in ele.__dict__.keys():
self.write('%s: MALIGN, DY=-%f \n' % (ele.Name,ele.dy))
else:
self.write('%s: MARK \n' % (ele.Name))
self.seq.append(ele.Name)
......@@ -242,14 +248,14 @@ class ElegantLattice(ApplicationTemplate):
self.seq.append("%s.lsc" % ele.Name)
self.write("%s.b: CSRCSBEND, L=%f, ANGLE=%f, &\n" % (ele.Name,Lpath,angradcor))
self.write("\tE1=%f, E2=%f, TILT=%f, &\n" % (ele.e1*angrad,ele.e2*angrad,ele.Tilt))
self.write("\tHGAP=0.015, NONLINEAR=1, N_KICKS=10,INTEGRATION_ORDER=4, &\n")
self.write("\tHGAP=0.015, FINT=0.5, NONLINEAR=1, N_KICKS=10,INTEGRATION_ORDER=4, &\n")
self.write("\tBINS=%d,SG_HALFWIDTH=2, ISR=%d, SYNCH_RAD=%d, CSR=%d\n" % (self.csrbins,self.csr,self.csr,self.csr))
self.write("%s: LINE=(%s.lsc,%s.b)\n" % (ele.Name,ele.Name,ele.Name))
self.seq.append(ele.Name)
else:
self.write("%s: CSRCSBEND, L=%f, ANGLE=%f, &\n" % (ele.Name,Lpath,angradcor))
self.write("\tE1=%f, E2=%f, TILT=%f, &\n" % (ele.e1*angrad,ele.e2*angrad,ele.Tilt))
self.write("\tHGAP=0.000, NONLINEAR=1, N_KICKS=10,INTEGRATION_ORDER=4, &\n")
self.write("\tHGAP=0.015, FINT=0.5, NONLINEAR=1, N_KICKS=10,INTEGRATION_ORDER=4, &\n")
self.write("\tBINS=%d,SG_HALFWIDTH=2, ISR=%d, SYNCH_RAD=%d, CSR=%d\n" % (self.csrbins,self.csr,self.csr,self.csr))
self.seq.append(ele.Name)
if abs(angrad)>0:
......@@ -280,7 +286,8 @@ class ElegantLattice(ApplicationTemplate):
# add dechirper here
if 'UDCP' in ele.Name:
wake=Dechirper()
wake.getWake(ele.gap, ele.Name,self.path)
wake.getWake(ele.gap, ele.Name,self.savepath)
print('Write wakefile for %s with gap: %f mm' % (ele.Name,ele.gap*1e3))
self.write('%s_LW : WAKE, INPUTFILE = "%s/wake_%s.sdds", CHANGE_P0 = 1, &\n' % (ele.Name,self.path,ele.Name))
self.write('\t TCOLUMN="t",WCOLUMN="W", INTERPOLATE=1, FACTOR = %f, N_BINS=%d, SMOOTHING=1 \n'% (ele.getLength(),self.wakebins))
self.seq.append('%s_LW' % ele.Name)
......@@ -334,7 +341,7 @@ class ElegantLattice(ApplicationTemplate):
if ele.Tag=="RACC":
if not (ele.Band in self.wakes.keys()):
wake=Wakes()
wake.getWake(ele.Band,self.path)
wake.getWake(ele.Band,self.savepath)
self.wakes[ele.Band]=1
self.write('%s : RFCW, FREQ=%f, CELL_LENGTH=1.0, &\n' % (ele.Name,ele.Frequency))
self.write('\t L=%f, VOLT=%e, PHASE= %f, &\n' % (ele.getLength(),ele.Gradient*ele.getLength(),ele.Phase))
......
......@@ -16,8 +16,12 @@ class HolyList(ApplicationTemplate):
self.catalogue={} # dictionary with all elements
self.magcat={}
self.baugruppe={}
self.ws = self.w.add_sheet('SwissFEL') # name of main tab
self.wbend = self.w.add_sheet('SwissFEL Dipoles') # name of extra tab describing the dipoles
self.wbbg= self.w.add_sheet('Baugruppen') # name of extra tab describing the dipoles
# format of the excel sheet
font0 = xlwt.Font()
......@@ -43,6 +47,9 @@ class HolyList(ApplicationTemplate):
self.ws.col(14).width = 3300
self.wbend.col(0).width = 5500
self.wbbg.col(0).width = 5500
self.wbbg.col(1).width = 35500
title=('Domain','Prefix','Suffix','Index','s (m)','z (m)','x (m)','y (m)','L (m)','Reference','Group','Baugruppe','Roll','PS-Ch.','Phase')
i=0
......@@ -60,6 +67,16 @@ class HolyList(ApplicationTemplate):
self.bendrow=1
self.setRef(-0.1,-0.1)
title=('BAUGRUPPE','DESCRIPTION')
i=0
for name in title:
self.wbbg.write(0, i, name,style0)
i=i+1
self.bgrow=1
self.style = xlwt.XFStyle()
self.pattern = xlwt.Pattern()
......@@ -93,6 +110,13 @@ class HolyList(ApplicationTemplate):
self.lila.pattern_fore_colour = 45
def writeBG(self):
for key in sorted(self.baugruppe.keys()):
self.wbbg.write(self.bgrow,0,key,self.style)
info=self.infobg(key)
self.wbbg.write(self.bgrow,1,info,self.style)
self.bgrow+=1
def append(self,phase_in='Phase 1'):
if self.phase==phase_in:
return
......@@ -136,6 +160,8 @@ class HolyList(ApplicationTemplate):
def write(self,elements):
name=elements[0]
reference=elements[2]
elelength=elements[1]
......@@ -224,6 +250,10 @@ class HolyList(ApplicationTemplate):
self.ws.write(self.row, 14,phasetxt,self.style)
self.catalogue[name]=1
bg=elements[5]
if not bg in self.baugruppe.keys():
self.baugruppe[bg]=1
self.row=self.row+1
......@@ -259,7 +289,7 @@ class HolyList(ApplicationTemplate):
off=elements[8]
if (name.find('UN')>-1):
off=0
of=-0.005
of=0.149
if (name.find('SARUN')>-1):
of=-0.008
if (name.find('200')>-1 or name.find('300')>-1):
......@@ -476,3 +506,192 @@ class HolyList(ApplicationTemplate):
self.verts=self.verts+math.sqrt(ds)
def infobg(self,bg):