diff --git a/tracy/tracy/src/physlib.cc b/tracy/tracy/src/physlib.cc index f8feb3aba856371a84f253f78db326ed4d1bcd22..3941d70ca38e35d4b56608d292d59bc8db29d3d2 100644 --- a/tracy/tracy/src/physlib.cc +++ b/tracy/tracy/src/physlib.cc @@ -2561,7 +2561,7 @@ void ChamberOff(void) fprintf(f, "# TRACY III synchrotron soleil -- %s -- %s \n", fic, asctime2(newtime)); fprintf(f, "# i name s -xch(mm) +xch(mm) -zch(mm) +zch(mm)\n#\n"); - for (i = 0; i <= globval.Cell_nLoc; i++) + for (i = 1; i <= globval.Cell_nLoc; i++) fprintf(f, "%4ld %15s %6.2f %7.3f %7.3f %7.3f %7.3f\n", i, Cell[i].Elem.PName, Cell[i].S, Cell[i].maxampl[X_][0] * 1E3, Cell[i].maxampl[X_][1] * 1E3, diff --git a/tracy/tracy/src/read_script.cc b/tracy/tracy/src/read_script.cc index 8b184dfef67316d5e6327e3f360c8a1339c35a78..d1b4ce62b3aa3580999351d458ee0d9d984e6a45 100644 --- a/tracy/tracy/src/read_script.cc +++ b/tracy/tracy/src/read_script.cc @@ -137,7 +137,7 @@ void read_script(const char *param_file_name, bool rd_lat) /* chamber file */ else if (strcmp("chamber_file", name) == 0){ sscanf(line, "%*s %s", str); - sprintf(chamber_file,"%s%s", in_dir, str); /* add file directory of the chamber file*/ + sprintf(chamber_file,"%s", str); /* add file directory of the chamber file*/ } /* read in bool flags */ diff --git a/tracy/tracy/src/soleillib.cc b/tracy/tracy/src/soleillib.cc index d4b598bdb1ec5492817188f4c566029e53d42bc0..a85cab4a12501cddd79f17f48e44b4a96912f056 100644 --- a/tracy/tracy/src/soleillib.cc +++ b/tracy/tracy/src/soleillib.cc @@ -308,7 +308,7 @@ void Hcofonction(long pos, double dP) void SetErr(void) { double fac = 0.0, normcut = 0.0; -// long seed = 0L; + long seed = 0L; long i = 0L; // CellType Cell; double theta = 0.0; @@ -329,7 +329,7 @@ void SetErr(void) fac = 0.0014/2.0; // fac = 0.00115/2.0; setrancut(normcut=2L); -// iniranf(seed=0L); + iniranf(seed); for (i = 1L; i <= globval.Cell_nLoc; i++) { @@ -632,7 +632,7 @@ void ReadCh(const char *AperFile) Fnum1 = ElemIndex(Name1); Fnum2 = ElemIndex(Name2); if(Fnum1>0 && Fnum2>0) { - /* if element Name1 is defined before elment Name2, give error message*/ + /* if element Name1 is defined before element Name2, give error message*/ if(Fnum1 > Fnum2){ printf("\nReadCh(): \n" " aperture file, Line %d, Element %s should be defined after Element %s \n", @@ -851,7 +851,7 @@ void NuDx(long Nbx, long Nbz, long Nbtour, double xmax, double zmax, xstep = xmax/Nbx*2.0; x0 = 1e-6 - xmax; - z0 = 1e-3; + z0 = 1e-6; for (i = 0; i <= Nbx; i++) { x = x0 + i*xstep ; @@ -892,7 +892,7 @@ void NuDx(long Nbx, long Nbz, long Nbtour, double xmax, double zmax, fprintf(outf,"# x[mm] z[mm] fx fz \n"); zstep = zmax/Nbz*2.0; - x0 = 1e-3; + x0 = 1e-6; z0 = 1e-6 - zmax; for (i = 0; i <= Nbz; i++) { x = x0 ; @@ -1868,170 +1868,6 @@ void Multipole_thicksext(char const *fic_hcorr, char const *fic_vcorr, char cons } } - /* building list of quadrupoles */ -// nquad = 0; -// ElemFamIndex = ElemIndex("QP1"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (!trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP2"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP3"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP4"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP5"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP6"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP7"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP8"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP9"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("QP10"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// qlist[nquad] = Elem_GetPos(ElemFamIndex, i); -// getelem(qlist[nquad], &Cell); /* get element */ -// nquad++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[2L + HOMmax]); -// } - -// /* building list of sextupoles */ -// nsext = 0; -// ElemFamIndex = ElemIndex("SX1"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX2"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX3"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX4"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX5"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX6"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX7"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX8"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX9"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// -// ElemFamIndex = ElemIndex("SX10"); -// for (i=1; i<=GetnKid(ElemFamIndex); i++){ -// slist[nsext] = Elem_GetPos(ElemFamIndex, i); -// getelem(slist[nsext], &Cell); /* get element */ -// nsext++; -// if (trace) printf("%s % f\n",Cell.Elem.PName, Cell.Elem.M->PBpar[3L + HOMmax]); -// } -// /* find sextupole associated with the corrector */ // solution 1: find by names @@ -2386,7 +2222,6 @@ void Multipole_thicksext(char const *fic_hcorr, char const *fic_vcorr, char cons dBoB11 =-0.037*1; /* 22-poles */ brho = globval.Energy/0.299792458; /* magnetic rigidity */ -// brho = 1.0; /* magnetic rigidity */ conv = 8.14e-4; /*conversion des A en T.m*/ /* open H corrector file */ @@ -2402,31 +2237,6 @@ void Multipole_thicksext(char const *fic_hcorr, char const *fic_vcorr, char cons } fclose(fi); /* close H corrector file */ -// for (i = 0; i < nhcorr; i++){ -// getelem(hcorrlist[i], &Cell); -// corr_strength = hcorr[i]*conv/brho; -// -// /* decapole error */ -// mKL = dBoB5*corr_strength*x04i; -// SetKLpar(Cell.Fnum, Cell.Knum, mOrder=5L, mKL); -// -// if (trace) printf("num= %4d name = %s Fnum = %3ld, Knum=%3ld BL/brho=% e mKl=% e\n",i, -// Cell.Elem.PName,Cell.Fnum, Cell.Knum, corr_strength, mKL); -// /* 14-pole error */ -// mKL = dBoB7*corr_strength*x06i; -// SetKLpar(Cell.Fnum, Cell.Knum, mOrder=7L, mKL); -// -// if (trace) printf("num= %4d name = %s Fnum = %3ld, Knum=%3ld BL/brho=% e mKl=% e\n",i, -// Cell.Elem.PName,Cell.Fnum, Cell.Knum, corr_strength, mKL); -// -// /* 22-pole error */ -// mKL = dBoB11*corr_strength*x010i; -// SetKLpar(Cell.Fnum, Cell.Knum, mOrder=11, mKL); -// -// if (trace) printf("num= %4d name = %s Fnum = %3ld, Knum=%3ld BL/brho=% e mKl=% e\n",i, -// Cell.Elem.PName,Cell.Fnum, Cell.Knum, corr_strength, mKL); -// } - for (i = 0; i < nhcorr; i++){ getelem(hcorrlistThick[i], &Cell); corr_strength = hcorr[i]*conv/brho; diff --git a/tracy/tracy/src/t2lat.cc b/tracy/tracy/src/t2lat.cc index 190b69f0e724f3a96590f30fb4be99ccfe1a0426..bc9d0b3baaff30207580fded57d5e4680065b0ff 100644 --- a/tracy/tracy/src/t2lat.cc +++ b/tracy/tracy/src/t2lat.cc @@ -47,12 +47,13 @@ typedef enum nbdsym, frgsym, latsym, mpsym, dbnsym, kssym, homsym, lmdsym, dtsym, xytsym, vrfsym, harnumsym, frqsym, gstsym, typsym, rollsym, idsym, fnamesym1, fnamesym2, scalingsym, fmsym, harmsym, sprsym, recsym, solsym, - ff1sym, ff2sym, ffscalingsym + ff1sym, ff2sym, ffscalingsym, tiltsym } Lat_symbol; /*\*/ // idsym fnamesym1 fnamesym2 scalingsym added for insertion // ring sym added // ff1sym ff2sym for quadrupole entrance and exit fringe field // ffscalingsym scaling factor for entrance and exit fringe field. /*J.Zhang +// tilt added for comptaibility with Tracy II /* p2c: t2lat.pas, line 52: * Note: Line breaker spent 0.0 seconds, 5000 tries on line 603 [251] */ @@ -2235,8 +2236,9 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, K =<K-value>, ( [m-2] ) N =<# of kicks>, Method=<method>, + FF1, FF1 = 1 means scaling factor entrance, exit FFscaling = Fringe field scaling factor, default 1.0, - Roll=<roll angle>, ( [deg], design roll angle ) + Roll or tilt =<roll angle>, ( [deg], design roll angle ) HOM=(i, <Bi>, <Ai>, ( higher order component in USA notation ) j, <Bj>, <Aj>, ( Systematic error Only ) ............ ( Random errors are assigned ) @@ -2245,7 +2247,7 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, Example Q1: Quadrupole, L=0.5, K=2.213455, N=4, Method=4; - Q1 : Quadrupole, L=0.5, K=2.213455, N=4, FF =1, FFscaling=2, Method=4; + Q1 : Quadrupole, L=0.5, K=2.213455, N=4, FF1 =1, FF2, FFscaling=1, Method=4; **************************************************************/ case qdsym: /*4*/ @@ -2265,6 +2267,7 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, P_addset(mysys, (long)nsym); P_addset(mysys, (long)mthsym); P_addset(mysys, (long)rollsym); + P_addset(mysys, (long)tiltsym); P_addset(mysys, (long)homsym); P_addset(mysys, (long)dbnsym); P_addset(mysys, (long)ff1sym); @@ -2313,6 +2316,10 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, dt = EVAL_(&V); break; + case tiltsym: + dt = EVAL_(&V); + break; + case homsym: GetHOM(&V); break; @@ -3205,7 +3212,7 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, GetSym__(&V); QK = 0e0; QKxV = 0e0; QKS = 0e0; k1 = 1; - k2 = 1; // linear interpolation by default + k2 = 1; // 1 linear interpolation, 2 spline interpolation dt = 0e0; scaling = 1.0; // scaling factor P_addset(P_expset(mysys, 0), (long)nsym); @@ -3650,6 +3657,7 @@ static void init_reserved_words(struct LOC_Lattice_Read *LINK) Reg("t2 ", t2sym, &V); Reg("table ", tblsym, &V); Reg("task ", tsksym, &V); + Reg("tilt ", tiltsym, &V); // added for compatibility with Tracy II Reg("type ", typsym, &V); Reg("use ", usesym, &V); Reg("vertical ", versym, &V); diff --git a/tracy/tracy/src/t2ring.cc b/tracy/tracy/src/t2ring.cc index cad42744f59df25863bcb8d0d829d8af2ae049b0..00b0a46f6d52d265361ef573328c87b089db25ba 100644 --- a/tracy/tracy/src/t2ring.cc +++ b/tracy/tracy/src/t2ring.cc @@ -510,7 +510,7 @@ void Ring_Getchrom(double dP) return; } - /* get tunes for energy dP+globval.dPcommon/2 from oneturn matrix */ + /* get tunes for energy dP+globval.dPcommon/2 from one turn matrix */ Cell_GetABGN(globval.OneTurnMat, alpha, beta, gamma, nu); if (!globval.stable) { @@ -526,6 +526,7 @@ void Ring_Getchrom(double dP) #undef n + /****************************************************************************/ /* static void Ring_Twiss_M(bool chroma, double dP)