diff --git a/tracy/tracy/src/nsls-ii_lib.cc b/tracy/tracy/src/nsls-ii_lib.cc index 834f5f44816148d0a42f729368da451e7c7fce79..d39b7e4c25374f3ca7dc1052781f17630efe3804 100644 --- a/tracy/tracy/src/nsls-ii_lib.cc +++ b/tracy/tracy/src/nsls-ii_lib.cc @@ -5,7 +5,7 @@ T. Shaftan, I. Pinayev, Y. Luo, C. Montag, B. Nash */ -/* Current revision $Revision: 1.11 $ +/* Current revision $Revision: 1.12 $ On branch $Name: not supported by cvs2svn $ Latest change by $Author: zhang $ */ @@ -735,7 +735,39 @@ void prt_chrom_lat(void) fclose(outf); } +/****************************************************************************/ +/* void prt_cod(const char *file_name, const int Fnum, const bool all) + + Purpose: + print the close orbit + + Input: + file_name file to save close orbit + code in the file: + 0 drfit + 0.5 dipole + -1 defocusing quadrupole + 1 focusing quadrupole + 1.5 sextupole + 2.0 bpm + Fnum family index of BPM + all print the cod at all elements + Output: + none + + Return: + none + + Global variables: + + + specific functions: + + Comments: + + +****************************************************************************/ void prt_cod(const char *file_name, const int Fnum, const bool all) { long i; @@ -749,7 +781,7 @@ void prt_cod(const char *file_name, const int Fnum, const bool all) /* Get time and date */ newtime = GetTime(); - fprintf(outf,"# TRACY II v.2.6 -- %s -- %s \n", + fprintf(outf,"# TRACY III -- %s -- %s \n", file_name, asctime2(newtime)); fprintf(outf, "# name s code betax nux betay nuy" @@ -789,8 +821,8 @@ void prt_cod(const char *file_name, const int Fnum, const bool all) Cell[i].Beta[Y_], Cell[i].Nu[Y_], 1e3*Cell[i].BeamPos[x_], 1e3*Cell[i].BeamPos[y_], 1e3*Cell[i].dS[X_], 1e3*Cell[i].dS[Y_], - -1e3*Elem_GetKval(Cell[i].Fnum, Cell[i].Knum, Dip), - 1e3*Elem_GetKval(Cell[i].Fnum, Cell[i].Knum, -Dip)); + -1e3*Elem_GetKval(Cell[i].Fnum, Cell[i].Knum, Dip), //K value of the dipole component + 1e3*Elem_GetKval(Cell[i].Fnum, Cell[i].Knum, -Dip)); //K value of the dipole component } } fclose(outf); diff --git a/tracy/tracy/src/radia2tracy.cc b/tracy/tracy/src/radia2tracy.cc index efc1066f000bcf45e36e4f5c19475cf535dd6a56..5fc669b7e7a1a59c800b5d278b66545bde504148 100644 --- a/tracy/tracy/src/radia2tracy.cc +++ b/tracy/tracy/src/radia2tracy.cc @@ -9,17 +9,22 @@ */ /* Spline routine adapted from NR with template */ +/************************************************************************************************** + void spline(const double x[], const T y[], int const n, double const yp1, + const double ypn, T y2[]) + + Purpose: + Function to be called only once + Given arrays x[1..n] and y[1..n] containing a tabulated function, i.e., yi = f(xi), with + x1 <x2 < :: : < xN, and given values yp1 and ypn for the first derivative of the interpolating + function at points 1 and n, respectively, this routine returns an array y2[1..n] that contains + the second derivatives of the interpolating function at the tabulated points xi. If yp1 and/or + ypn are equal to 10e30 or larger, the routine is signaled to set the corresponding boundary + condition for a natural spline, with zero second derivative on that boundary. + ***************************************************************************************************/ template<typename T> void spline(const double x[], const T y[], int const n, double const yp1, const double ypn, T y2[]) -/* Function to be called only once - Given arrays x[1..n] and y[1..n] containing a tabulated function, i.e., yi = f(xi), with - x1 <x2 < :: : < xN, and given values yp1 and ypn for the first derivative of the interpolating - function at points 1 and n, respectively, this routine returns an array y2[1..n] that contains - the second derivatives of the interpolating function at the tabulated points xi. If yp1 and/or - ypn are equal to 10e30 or larger, the routine is signaled to set the corresponding boundary - condition for a natural spline, with zero second derivative on that boundary. - */ { int i, k; double sig; @@ -51,14 +56,19 @@ void spline(const double x[], const T y[], int const n, double const yp1, y2[k] = y2[k] * y2[k + 1] + u[k]; } +/*********************************************************************************************** + void splint(const double xa[], const U ya[], const U y2a[], const int n, + const T &x, T &y) + + Purpose: + SPLine INTerpolation. Once spline are known, only evaluate polynome + Given the arrays xa[1..n] and ya[1..n], which tabulate a function (with the xai's in order), + and given the array y2a[1..n], which is the output from spline above, and given a value of + x, this routine returns a cubic-spline interpolated value y. + ***********************************************************************************************/ template<typename T, typename U> void splint(const double xa[], const U ya[], const U y2a[], const int n, const T &x, T &y) -/* SPLine INTerpolation. Once spline are known, only evaluate polynome - * Given the arrays xa[1..n] and ya[1..n], which tabulate a function (with the xai's in order), - and given the array y2a[1..n], which is the output from spline above, and given a value of - x, this routine returns a cubic-spline interpolated value y. - */ { int klo, khi, k; double h; @@ -82,14 +92,20 @@ void splint(const double xa[], const U ya[], const U y2a[], const int n, - b) * y2a[khi]) * (h * h) / 6.0; } +/********************************************************************************************** + void splin2(const double x1a[], const double x2a[], double **ya, double **y2a, + const int m, const int n, const T &x1, const T &x2, T &y) + + Purpose: + Main function computing the bicubic spline + Given x1a, x2a, ya, m, n as described in splie2 and y2a as produced by that routine; and + given a desired interpolating point x1,x2; this routine returns an interpolated function + value y by bicubic spline interpolation. + ******************************************************************************************/ template<typename T> void splin2(const double x1a[], const double x2a[], double **ya, double **y2a, const int m, const int n, const T &x1, const T &x2, T &y) -/* Main function computing the bicubic spline - Given x1a, x2a, ya, m, n as described in splie2 and y2a as produced by that routine; and - given a desired interpolating point x1,x2; this routine returns an interpolated function value y - by bicubic spline interpolation. - */{ +{ int j; T ytmp[m + 1], yytmp[m + 1]; // Perform m evaluations of the row splines constructed by @@ -99,13 +115,17 @@ void splin2(const double x1a[], const double x2a[], double **ya, double **y2a, splint(x1a, yytmp, ytmp, m, x1, y); } +/************************************************************************************************** +void splie2(double x1a[], double x2a[], double **ya, int m, int n, double **y2a) + + Purpose: + precompute the auxiliary second-derivative table + Given an m by n tabulated function ya[1..m][1..n], and tabulated independent variables + x2a[1..n], this routine constructs one-dimensional natural cubic splines of the rows of ya + and returns the second-derivatives in the array y2a[1..m][1..n]. (The array x1a[1..m] is + included in the argument list merely for consistency with routine splin2.) + ***************************************************************************************************/ void splie2(double x1a[], double x2a[], double **ya, int m, int n, double **y2a) -/* precompute the auxiliary second-derivative table - Given an m by n tabulated function ya[1..m][1..n], and tabulated independent variables - x2a[1..n], this routine constructs one-dimensional natural cubic splines of the rows of ya - and returns the second-derivatives in the array y2a[1..m][1..n]. (The array x1a[1..m] is - included in the argument list merely for consistency with routine splin2.) - */ { int j; @@ -170,7 +190,7 @@ void Read_IDfile(char *fic_radia, double *L, int *pnx, int *pnz, } fprintf(stdout, "\n"); - fprintf(stdout, "Reading ID filename %s \n", fic_radia); + fprintf(stdout, "Reading ID file: %s \n", fic_radia); /* first line */ fscanf(fi, "%[^\n]\n", dummy); /* Read a full line */ @@ -613,7 +633,7 @@ void Matrices4Spline(InsertionType *WITH, int Order) { WITH->TabxOrd1[kx] = (float) WITH->tabx1[kx]; } - /** reordering: it has to be in increasing order */ + /* reordering: it has to be in increasing order */ for (kz = 0; kz < WITH->nz1; kz++) { WITH->TabzOrd1[kz] = (float) WITH->tabz1[WITH->nz1 - kz - 1]; } @@ -638,7 +658,7 @@ void Matrices4Spline(InsertionType *WITH, int Order) { WITH->TabxOrd2[kx] = (float) WITH->tabx2[kx]; } - /** reordering: it has to be in increasing order */ + /* reordering: it has to be in increasing order */ for (kz = 0; kz < WITH->nz2; kz++) { WITH->TabzOrd2[kz] = (float) WITH->tabz2[WITH->nz2 - kz - 1]; } diff --git a/tracy/tracy/src/t2elem.cc b/tracy/tracy/src/t2elem.cc index 9668de70f0b7b17e3673a342970d8f30168ce262..7ceadb307633251799b8a41740fd65ac92ba5872 100644 --- a/tracy/tracy/src/t2elem.cc +++ b/tracy/tracy/src/t2elem.cc @@ -1648,9 +1648,10 @@ void FieldMap_Pass(CellType &Cell, ss_vect<T> &X) { LtoG(X, Cell.dS, Cell.dT, 0.0, 0.0, 0.0); } -template<typename T> -void Insertion_Pass(CellType &Cell, ss_vect<T> &x) { - /* Purpose: +/******************************************************************** + void Insertion_Pass(CellType &Cell, ss_vect<T> &x) + + Purpose: Track vector x through an insertion If radiation or cavity on insertion is like a drift @@ -1675,8 +1676,12 @@ void Insertion_Pass(CellType &Cell, ss_vect<T> &x) { Comments: Outside of interpolation table simulated by putting 1 in x[4] 01/07/03 6D tracking activated - 10/01/05 First order kick part added */ + 10/01/05 First order kick part added + *******************************************************************/ +template<typename T> +void Insertion_Pass(CellType &Cell, ss_vect<T> &x) { + elemtype *elemp; double LN = 0.0; T tx1, tz1; /* thetax and thetaz retrieved from @@ -2612,8 +2617,8 @@ void Insertion_SetMatrix(int Fnum1, int Knum1) { // } } -void Insertion_Pass_M(CellType &Cell, Vector &xref, Matrix &M) { - /* Purpose: called by Elem_Pass_M +/********************************************************************* + Purpose: called by Elem_Pass_M matrix propagation through a insertion kick-driftlike matrix x = KD55*x xref= insertion(xref) @@ -2636,7 +2641,10 @@ void Insertion_Pass_M(CellType &Cell, Vector &xref, Matrix &M) { MulLMat, Drft Comments: - 01/07/03 6D tracking activated */ + 01/07/03 6D tracking activated +******************************************************************************/ +void Insertion_Pass_M(CellType &Cell, Vector &xref, Matrix &M) { + elemtype *elemp; diff --git a/tracy/tracy/src/t2lat.cc b/tracy/tracy/src/t2lat.cc index 9fcefb9979a1d7106baa8ae6b49e09e17fde1a58..ced0f6e6dbb9caa46cf5cf945c6c636e2143a07d 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.15 $ +/* Current revision $Revision: 1.16 $ On branch $Name: not supported by cvs2svn $ - Latest change $Date: 2010-12-03 17:15:10 $ by $Author: zhang $ + Latest change $Date: 2011-03-23 08:10:31 $ by $Author: zhang $ */ @@ -3218,7 +3218,7 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, QK = 0e0; QKxV = 0e0; QKS = 0e0; - k1 = 1; + k1 = 1; // number of slices of the lattice element k2 = 3; // 1 linear interpolation, 3 spline interpolation dt = 0e0; scaling1 = 1.0; // scaling factor @@ -3233,8 +3233,10 @@ static bool Lat_DealElement(FILE **fi_, FILE **fo_, long *cc_, long *ll_, test__(mysys, "illegal parameter", &V); sym1 = *V.sym; getest__(P_expset(SET, 1L << ((long) eql)), "<=> expected", &V); - switch (sym1) { - + + //read the parameters setting from the lattice + switch (sym1) { + case nsym: /* Read number of slices */ k1 = abs((long) floor(EVAL_(&V))); GetSym__(&V);