From 968195dc06d814738944ea2323a4f17ea8a84f20 Mon Sep 17 00:00:00 2001 From: zhang <zhang@9a6e40ed-f3a0-4838-9b4a-bf418f78e88d> Date: Fri, 27 Jan 2012 16:47:39 +0000 Subject: [PATCH] 1) Add the features to read horizontal and vertical kicks of the correctors. 2) Fix the bug to assign the entrance fringe field of the sextupole (FF1 --> FF2) --- tracy/tracy/src/t2lat.cc | 63 +++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/tracy/tracy/src/t2lat.cc b/tracy/tracy/src/t2lat.cc index 44dc78d..9dec889 100644 --- a/tracy/tracy/src/t2lat.cc +++ b/tracy/tracy/src/t2lat.cc @@ -7,9 +7,9 @@ L. Nadolski SOLEIL 2002 Link to NAFF, Radia field maps J. Bengtsson NSLS-II, BNL 2004 - */ -/* Current revision $Revision: 1.19 $ +/* Current revision $Revision: 1.20 $ On branch $Name: not supported by cvs2svn $ - Latest change $Date: 2011-06-30 16:41:49 $ by $Author: zhang $ + Latest change $Date: 2012-01-27 16:47:39 $ by $Author: zhang $ */ @@ -38,8 +38,8 @@ typedef char Latlinetype[LatLLng]; typedef enum { - bndsym, defsym, dfcsym, drfsym, elmsym, fcssym, horsym, monsym, - qdsym, sexsym, versym, plus_, minus_, lparent, rparent, eql, comma, lbrack, + bndsym, defsym, dfcsym, drfsym, elmsym, fcssym, horsym, versym,corkicksym, monsym, + qdsym, sexsym, plus_, minus_, lparent, rparent, eql, comma, lbrack, rbrack, neq, andsy, semicolon, times, rdiv, intcon, realcon, becomes, colon, leq, pwrsym, lss, geo, gtr, period_, charcon, stringcon, ident, geq, lsym, bobrhosym, bobrhovsym, bobrhohsym, kxvsym, kxhsym, phisym, ksym, @@ -2017,6 +2017,8 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, struct LOC_Lat_DealElement V; bool Result = false; double t, t1, t2, gap, QL = 0.0, QK; + double QKick; /* kick angle of the corrector [rad]*/ + int Kplane; /* kick plane of the corrector, 1 for H plane, -1 for V plane*/ double QKV, QKH, QKxV, QKxH, QPhi, QKS; double dt, Frf, Vrf; long k1, k2, harnum, FF1, FF2; @@ -2482,7 +2484,7 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, WITH2->quadFF1 = 0; /* entrance fringe field flag */ WITH2->quadFF2 = 0; /* exit fringe field flag */ WITH2->sextFF1 = FF1; /* entrance fringe field flag */ - WITH2->sextFF2 = FF1; /* exit fringe field flag */ + WITH2->sextFF2 = FF2; /* exit fringe field flag */ if (WITH1->PL != 0.0) WITH2->Pthick = pthicktype(thick); else @@ -2581,12 +2583,13 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, } break; - /************************************************************************** - Orbit Corrector + Corrector *************************************************************************** - - <name>: Corrector, <direction>, L=<length>, ; + + Kickers specific for orbit correction. + + <name>: Corrector, <direction>, L=<length>, kick = <kick angle [rad]>; <name> :== Alphanumeric string. Up to NameLength character length. BEGIN with an alphabet. @@ -2600,7 +2603,8 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, case corsym: /*4*/ QL = 0.0; /* L */ - QK = 0.0; /* K */ + QKick = 0.0; /* kick angle of the corrector [rad]*/ + Kplane = 0; /* 1 is horizontal corrector, -1 is vertical corrector */ k1 = 0; /* N */ k2 = Meth_Linear; /* method */ dt = 0.0; @@ -2613,13 +2617,14 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, P_addset(mysys, (long)mthsym); P_addset(mysys, (long)horsym); P_addset(mysys, (long)versym); + P_addset(mysys, (long)corkicksym); P_addset(mysys, (long)rollsym); P_addset(mysys, (long)dbnsym); do { /*5: read L, K, N, T, T1, T2 */ test__(mysys, "illegal parameter", &V); sym1 = *V.sym; if (*V.sym == (long)dbnsym || *V.sym == (long)rollsym || - *V.sym == (long)mthsym || - *V.sym == (long)nsym || *V.sym == (long)lsym) + *V.sym == (long)mthsym || *V.sym == (long)nsym || + *V.sym == (long)lsym || *V.sym == (long)corkicksym) { getest__(P_expset(SET, 1 << ((long)eql)), "<=> expected", &V); if (*V.sym == eql) { @@ -2629,6 +2634,10 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, QL = EVAL_(&V); break; + case corkicksym: + QKick = EVAL_(&V); + break; + case nsym: k1 = (long)floor(EVAL_(&V) + 0.5); break; @@ -2654,9 +2663,9 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, } } else { if (sym1 == horsym) - QK = 1.0; - else - QK = -1.0; + Kplane = 1; + else if (sym1 == versym) + Kplane = -1; GetSym__(&V); } test__(P_expset(SET, @@ -2686,6 +2695,15 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, WITH2->Pmethod = k2; WITH2->PN = k1; WITH2->PdTpar = dt; + + if(Kplane == 0){ + cout << "t2lat: Error! Must specify the type of the corrector, Horizontal or vertical!" << endl; + exit_(1); + } + WITH2->PBpar[Kplane*Dip + HOMmax] = -1*QKick; //assign the kick angle [rad] + + + } else { printf("Elem_nFamMax exceeded: %ld(%ld)\n", globval.Elem_nFam, (long)Elem_nFamMax); @@ -3623,14 +3641,17 @@ static void init_reserved_words(struct LOC_Lattice_Read *LINK) V.LINK = LINK; LINK->nkw = 0; /* Number of keywords equals zero */ - /* Must follow alphabetical list */ + /*------------------------------------------------------------- + To define reserved symbol in the lattice reading, + MUST follow alphabetical list !!!!!!!!!!!!!!!!!!!!!!!!!!!!! + --------------------------------------------------------------*/ Reg("and ", andsym, &V); Reg("beam ", bemsym, &V); Reg("bending ", bndsym, &V); Reg("cavity ", cavsym, &V); Reg("cell ", celsym, &V); Reg("chromaticity ", chmsym, &V); - Reg("corrector ", corsym, &V); + Reg("corrector ", corsym, &V); /* corrector */ Reg("dbname ", dbnsym, &V); Reg("define ", defsym, &V); Reg("dispersion ", dspsym, &V); @@ -3652,9 +3673,10 @@ static void init_reserved_words(struct LOC_Lattice_Read *LINK) Reg("harm ", harmsym, &V); Reg("harnum ", harnumsym, &V); Reg("hom ", homsym, &V); - Reg("horizontal ", horsym, &V); + Reg("horizontal ", horsym, &V); /* with "corrector", define the horizontal corrector in the lattice*/ Reg("insertion ", idsym, &V); /* ID Laurent */ Reg("inv ", invsym, &V); + Reg("kick ", corkicksym, &V); /* with "corrector", define the kick angle of the corrector , Jianfeng Zhang*/ Reg("kicker ", kicksym, &V); Reg("ks ", kssym, &V); Reg("lambda ", lmdsym, &V); @@ -3684,7 +3706,7 @@ static void init_reserved_words(struct LOC_Lattice_Read *LINK) Reg("tilt ", tiltsym, &V); // added for compatibility with Tracy II Reg("type ", typsym, &V); Reg("use ", usesym, &V); - Reg("vertical ", versym, &V); + Reg("vertical ", versym, &V); /* with "corrector", define the vertical corrector in the lattice*/ Reg("voltage ", vrfsym, &V); Reg("wiggler ", wglsym, &V); @@ -3719,7 +3741,7 @@ static void init_reserved_words(struct LOC_Lattice_Read *LINK) LINK->skipflag = false; /* reset skip flag */ P_addset(P_expset(LINK->defbegsys, 0), (long)ident); P_addset(P_expset(LINK->elmbegsys, 0), (long)qdsym); - P_addset(LINK->elmbegsys, (long)sexsym); + P_addset(LINK->elmbegsys, (long)sexsym); /*link the lattice element name*/ P_addset(LINK->elmbegsys, (long)corsym); P_addset(LINK->elmbegsys, (long)bemsym); P_addset(LINK->elmbegsys, (long)gstsym); @@ -4332,6 +4354,7 @@ long ElemIndex(const char *name) int n = 0; partsName name1, name2; + const bool prt = false; if (prt) printf("\n"); -- GitLab