Commit 3d93dca1 authored by reiche's avatar reiche
Browse files

Added resolution of wake function. Added the possibility to center beam in elegant lattice

parent f20b0ff5
......@@ -8,7 +8,7 @@ class Dechirper:
self.eps=8.854e-12
self.mks=1./4/np.pi/self.eps
self.N=1000
self.N=10000
# OK for python2 and python3
self.lwake=list(range(self.N))
self.twake=list(range(self.N))
......
......@@ -54,6 +54,7 @@ class Elegant(ElegantLattice):
self.fid.write('\trandom_number_seed\t= 9876543210,\n')
self.fid.write('\tp_central\t= %f,\n' % dist.p0)
self.fid.write('\ttracking_updates\t= 1\n')
self.fid.write('\talways_change_p0\t= 1\n')
self.fid.write('&end\n\n')
self.fid.write('&run_control\n')
self.fid.write('\tn_steps\t= 1,\n')
......
......@@ -22,8 +22,9 @@ class ElegantLattice(ApplicationTemplate):
self.charge=200e-12
self.wakebins=0 # bins for wakefield calculation - carfule of strange binning procedure
self.wakes={} # arrays to accumulate the name of used wakes.
self.dump=[] # diagnostics location where to dump particle distribution
self.center=[] # location where the beam is centered due to CSR kicks
self.Distribution = 1
def openLatticeStream(self,path,name):
filename='%s/%s.lat' % (path,name)
......@@ -126,14 +127,18 @@ class ElegantLattice(ApplicationTemplate):
ds=ele.sRef+Seval;
if ds>0:
self.writeDrift(ds)
if ele.enable==0:
self.writeMarker(ele)
else:
if self.Distribution==0:
self.write('%s: WATCH, FILENAME="%%s.%s.p1", MODE=PARAMETER\n' % (ele.Name,ele.Name))
else:
self.write('%s: WATCH, FILENAME="%%s.%s.w1", MODE=COORD\n' % (ele.Name,ele.Name))
if ele.Name in self.center:
print('Adding center in ELegant output for',ele.Name)
self.write('%s_CENTER\n': % ele.Name)
self.seq.append('%s_CENTER' % ele.Name)
if ele.Name in self.dump:
print('Adding dump in ELegant output for',ele.Name)
self.write('%s: WATCH, FILENAME="%%s.%s.sdds", MODE=COORD\n' % (ele.Name,ele.Name))
self.seq.append(ele.Name)
else:
self.writeMarker(ele)
ds=ele.getResLength()-ds
if ds>0:
self.writeDrift(ds)
......@@ -276,7 +281,7 @@ class ElegantLattice(ApplicationTemplate):
if 'UDCP' in ele.Name:
wake=Dechirper()
wake.getWake(ele.gap, ele.Name,self.path)
self.write('%s_LW : WAKE, INPUTFILE = "%s/wake_%s.sdds", &\n' % (ele.Name,self.path,ele.Name))
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)
......
......@@ -127,6 +127,7 @@ class FacilityAccess:
if field in ele.__dict__.keys():
if (field=='angle'):
ele.__dict__[field]=np.sign(ele['design_angle'])*abs(value) # this is needed to set collectively a bunch compressor angle without flipping signs
# print(ele.Name,ele.__dict__[field])
else:
ele.__dict__[field]=value
......
......@@ -8,7 +8,7 @@ class Wakes:
self.Z0 = 120*math.pi
self.N=1000
self.N=10000
# OK for python2 and python3
self.lwake=list(range(self.N))
self.twake=list(range(self.N))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment