ptc_enforce6d, flag=true; dsel :=1.2;!length of starting and ending drift dmid1l:=1.5;!length of middle drift dmid2l:=0.6;!length of middle drift ! This example illustrates two features of MADXP ! - matching of higher order map elements ! - placemant of elements at arbitrary position ql :=0.2;!length of quads qfstr := 6.695198761;!strength of quads qdstr :=-6.712879942;!strength of quads lbend:=2.0; sedft: drift, L:=dsel; middft1: drift, L:=dmid1l; middft2: drift, L:=dmid2l; angb = pi/6.; !bend1: MULTIPOLE, L=lbend, bend1: RBEND, L=lbend, ANGLE:=-angb, e1=angb/2, ptcrbend=true, APERTYPE=CIRCLE, APERTURE={10}; ! Deflection to the left qf1: quadrupole, l=ql, k1:=qfstr, APERTYPE=CIRCLE, APERTURE={10.0}; qd: quadrupole, l=ql, k1:=qdstr, APERTYPE=CIRCLE, APERTURE={10.0}; qf2: quadrupole, l=ql, k1:=qfstr, APERTYPE=CIRCLE, APERTURE={10.0}; bend2: RBEND, L=lbend, ANGLE=angb, e1=-angb/2, ptcrbend=true, APERTYPE=CIRCLE, APERTURE={10}; ! Deflection to the right theend: marker, APERTYPE=CIRCLE, APERTURE={10.0}; chicane: line=(sedft,bend1,middft1,qf1,middft2,qd,middft2,qf2,middft1,bend2,sedft,theend); beam, PARTICLE=ELECTRON, ENERGY=0.11d0; use, period=chicane; ptc_create_universe; ptc_create_layout, model=1, method=6, nst=100, exact=true, closed_layout=false; ptc_setswitch, debuglevel=0, exact_mis=true, time=true, totalpath=false; !ptc_align; ptc_eplacement, range=qf1[1], onlyoposition, x= 0.09, y=0, z=0, refframe=gcs, autoplacedownstream=false; ptc_eplacement, range=qf2[1], onlyoposition, x=-0.09, y=0, z=0, refframe=gcs, autoplacedownstream=false; ptc_printframes, file="drawlayout.C", format=rootmacro;!this prints my visualisation with ROOT ptc_printframes, file="frames.txt"; !ptc_script, file="printflatfile.ptc"; !ptc_eplacement, range=qf1[1], theta=(-30/180)*pi, !theta=(30/180)*pi, ! onlyorientation, ! x= 0.09, y=0, z=0, ! refframe=gcs, autoplacedownstream=false, surveyall=false; !ptc_eplacement, range=bend2[1], onlyorientation, phi=(-45/180)*pi, ! refframe=gcs, autoplacedownstream=true, surveyall=true; !ptc_twiss, table=twiss, icase=6, no=3, betx=10., alfx=0.0, bety=10., alfy=0.0, betz=10., alfz=0.0; PTC_OBSERVE, place=middft2[1]; PTC_OBSERVE, place=middft1[2]; ptc_start, x=0.; ptc_trackline; ptc_track_end; ptc_end; !write, table=track.obs0002.p0001; value, table(track.obs0002.p0001,x); value, table(twiss,middft2[1],x); value, table(track.obs0003.p0001,x); value, table(twiss,middft1[2],x); !creates a table create, table=R1, withname, column="c11","c12","c21","c22"; !instructs ptc to store given monomials cofficients in the just created table ptc_select, table=R1, column="c11", polynomial=1, monomial="100000"; ptc_select, table=R1, column="c12", polynomial=1, monomial="010000"; ptc_select, table=R1, column="c21", polynomial=2, monomial="100000"; ptc_select, table=R1, column="c22", polynomial=2, monomial="010000"; create, table=R3, withname, column="c51","c52","c55","c56","c66"; ptc_select, table=R3, column="c51", polynomial=5, monomial="100000"; ptc_select, table=R3, column="c52", polynomial=5, monomial="010000"; ptc_select, table=R3, column="c55", polynomial=5, monomial="000010"; ptc_select, table=R3, column="c56", polynomial=5, monomial="000001"; ptc_select, table=R3, column="c66", polynomial=6, monomial="000001"; create, table=T2, withname, column="c111","c112","c113","c566","c556","c656","c666"; !instructs ptc to store given monomials cofficients in the just created table ptc_select, table=T2, column="c111", polynomial=1, monomial="200000"; ptc_select, table=T2, column="c112", polynomial=1, monomial="110000"; ptc_select, table=T2, column="c113", polynomial=1, monomial="101000"; ptc_select, table=T2, column="c566", polynomial=5, monomial="000002";!In 6D, PTC 5th col. is dp/p ptc_select, table=T2, column="c556", polynomial=5, monomial="000011";!In 6D, PTC 5th col. is dp/p ptc_select, table=T2, column="c666", polynomial=6, monomial="000002";!In 6D, PTC 5th col. is dp/p ptc_select, table=T2, column="c656", polynomial=6, monomial="000011";!In 6D, PTC 5th col. is dp/p !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! rm51:=table(r3,c51);!we need that for plotting rm52:=table(r3,c52); rm56:=table(r3,c56); select, flag=twiss, column=name, s, beta11, alfa11, beta13, rm51, rm52, rm56; ptc_create_universe; ptc_create_layout, model=1, method=6, nst=100, exact=true, closed_layout=false; ptc_setswitch, debuglevel=4, exact_mis=true, time=true, totalpath=true; !ptc_knob, elementname=QF1; !ptc_eplacement, range=bend1[1], onlyorientation, refframe=current, phi= (-angb/2/180) * pi; !ptc_eplacement, range=qf1[1], x=0.4, y=0, z=0, onlyposition, refframe=previouselement, autoplacedownstream=false; !ptc_eplacement, range=qf2[1], x=-0.4, y=0, z=0, onlyposition, refframe=previouselement, autoplacedownstream=false; !ptc_eplacement, range=qf2[1], onlyorientation, refframe=current, phi= (-30/180) * pi; !ptc_twiss, table=twiss, icase=6, no=3, betx=10., alfx=0.0, bety=10., alfy=0.0, betz=10., alfz=0.0; !ptc_dumpmaps, file="ptcmaps.txt"; !system, "mv ptcmaps.txt nomis.ptcmaps.txt"; !ptc_printframes, file="frames.txt"; !ptc_printframes, file="drawlayout.C",format=rootmacro; ptc_end; dupax:=0; ptc_create_universe; ptc_create_layout, model=1, method=6, nst=20, exact=true, closed_layout=false; ptc_setswitch, debuglevel=0, exact_mis=true, time=true, totalpath=true; match, use_macro; vary, name=dupax, step=0.01,lower=-0.09,upper=0.09; m1: macro= { value, dupax ; ptc_eplacement, range=qf1[1], x= dupax, y=0, z=0, onlyposition, refframe=previouselement, autoplacedownstream=false; ptc_eplacement, range=qf2[1], x=-dupax, y=0, z=0, onlyposition, refframe=previouselement, autoplacedownstream=false; ! ptc_printframes, file="d.C", format=rootmacro; ! ptc_printframes, file="f.txt"; ptc_twiss, table=twiss, icase=6, no=3, betx=10., alfx=0.0, bety=10., alfy=0.0, betz=10., alfz=0.0; value, table(twiss,qf1,beta11), table(twiss,qf1,beta12); value, table(twiss,theend,beta11), table(twiss,theend,beta12), table(twiss,theend,beta13); value, table(R3,theend,c51), table(R3,theend,c52), table(R3,theend,c56); value, table(T2,theend,c111), table(T2,theend,c112), table(T2,theend,c113), table(T2,theend,c566), table(T2,theend,c556), table(T2,theend,c666), table(T2,theend,c656); value, table(twiss,theend,disp1); value, table(twiss,middft1[1],x), table(twiss,middft2[1],x), table(twiss,middft2[2],x); value, dupax ; print, text=""; print, text="Macro ened"; print, text="#################################################"; print, text=""; }; ! constraint, expr=table(R3,theend,c51) = 0; ! constraint, expr=table(R3,theend,c52) = 0; ! constraint, expr=table(R3,theend,c56) = 0.4; constraint, expr=table(T2,theend,c566) = 3; constraint, weight=10, expr=table(twiss,qf1,beta11) <200.0; constraint, weight=10, expr=table(twiss,qf1,beta12) <200.0; constraint, weight=10, expr=table(twiss,theend,beta11)<200.0; constraint, weight=10, expr=table(twiss,theend,beta12)<200.0; constraint, weight=1000, expr=table(twiss,middft1[1],x)< 0.5; constraint, weight=1000, expr=table(twiss,middft1[1],x)>-0.5; constraint, weight=1000, expr=table(twiss,middft2[1],x)< 0.5; constraint, weight=1000, expr=table(twiss,middft2[1],x)>-0.5; constraint, weight=1000, expr=table(twiss,middft2[2],x)< 0.5; constraint, weight=1000, expr=table(twiss,middft2[2],x)>-0.5; lmdif, tolerance=1e-30 ,calls=200; ! jacobian, tolerance=1e-30 ,calls=200; endmatch; ptc_end; PLOT, noversion=true, file="chicane", haxis=s, vaxis=beta11,beta12, colour=100, title="Chicane with centered quads"; PLOT, noversion=true, file="chicane", haxis=s, vaxis=beta13, colour=100, title="Chicane with centered quads"; PLOT, noversion=true, file="chicane", haxis=s, vaxis=rm51,rm52,rm56, colour=100, title="Chicane with centered quads"; PLOT, noversion=true, file="chicane", haxis=s, vaxis=disp1, colour=100, title="Chicane with centered quads"; write, table=R1, file=R1.txt; write, table=T2, file=T2.txt; write, table=R3, file=R3.txt; write, table=twiss, file=twiss.txt; stop;