Ignore:
Timestamp:
Dec 6, 2013, 5:12:43 PM (10 years ago)
Author:
zhangj
Message:

Clean version of Tracy: SoleilVersion at the end of 2011.Use this clean version to find the correct dipole fringe field to have the correct FMAP and FMAPDP of ThomX. Modified files: tpsa_lin.cc, soleillib.cc, prtmfile.cc, rdmfile.cc, read_script.cc, physlib.cc, tracy.cc, t2lat.cc, t2elem.cc, naffutils.cc in /tracy/tracy/src folder; naffutils.h, tracy_global.h, physlib.h, tracy.h, read_script.h, solielilib.h, t2elem.h in /tracy/tracy.inc folder; soltracy.cc in tracy/tools folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/tracy3-3.10.1b/tracy/tracy/src/physlib.cc

    r11 r23  
    1616/**************************/
    1717
    18 /*******************************************************************************
    19  *
    20  *
    21  *
    22  *
    23  ******************************************************************************/
     18
    2419/**** same as asctime in C without the \n at the end****/
    2520char *asctime2(const struct tm *timeptr) {
     
    3833    return result;
    3934}
    40 /*******************************************************************************
    41  *
    42  *
    43  *
    44  *
    45  ******************************************************************************/
     35
    4636/** Get time and date **/
    4737struct tm* GetTime() {
     
    199189
    200190 Comments copied from Tracy 2.7(soleil),Written by L.Nadolski.
    201  
    202  03/06/2013 Add feature to print the summary on the sreen and an external file
    203191
    204192 ****************************************************************************/
     
    263251
    264252/****************************************************************************/
    265 /* void printglob2file(void)
    266 
    267  Purpose:
    268  Print global variables on screen
    269  Print tunes and chromaticities
    270  Print Oneturn matrix
    271 
    272  Input:
    273  none
    274 
    275  Output:
    276  output on the screen
    277 
    278  Return:
    279  none
    280 
    281  Global variables:
    282  globval
    283 
    284  Specific functions:
    285  none
    286 
    287  Comments:
    288  03/06/2013  by Jianfeng Zhang @ LAL
    289  The same feature as the file printglob(void), but
    290  added feature to print the lattice summary to an external file
    291 
    292  
    293  ****************************************************************************/
    294 void printglob2file(const char fic[]) {
    295   FILE *fout;
    296   int i=0,j=0;
    297  
    298   fout = fopen(fic,"w");
    299  
    300     fprintf(fout, "\n***************************************************************"
    301         "***************\n");
    302     fprintf(fout,"\n");
    303     fprintf(fout,"  dPcommon     =  %9.3e  dPparticle   =  %9.3e"
    304         "  Energy [GeV] = %.3f\n", globval.dPcommon, globval.dPparticle,
    305             globval.Energy);
    306     fprintf(fout,"  MaxAmplx [m] = %9.3e   MaxAmply [m] = %9.3e"
    307         "   RFAccept [%%] = +/- %4.2f\n", Cell[0].maxampl[X_][1],
    308             Cell[0].maxampl[Y_][1], globval.delta_RF * 1e2);
    309     fprintf(fout,"  MatMeth      =  %s     ", globval.MatMeth ? "TRUE " : "FALSE");
    310     fprintf(fout," Cavity_On    =  %s    ", globval.Cavity_on ? "TRUE " : "FALSE");
    311     fprintf(fout,"  Radiation_On = %s     \n", globval.radiation ? "TRUE " : "FALSE");
    312    
    313     if(globval.bpm == 0)
    314       fprintf(fout,"  bpm          =  0"); 
    315     else
    316       fprintf(fout,"  bpm          =  %3d", GetnKid(globval.bpm));
    317     if(globval.qt == 0)
    318       fprintf(fout,"                             qt           = 0           \n");
    319     else
    320       fprintf(fout,"                             qt           = %3d         \n", GetnKid(globval.qt));   
    321     if(globval.hcorr == 0)
    322       fprintf(fout,"  hcorr         =  0"); 
    323     else
    324       fprintf(fout,"  hcorr         = %3d", GetnKid(globval.hcorr));
    325     if(globval.vcorr == 0)
    326       fprintf(fout,"                             vcorr        =  0        \n"); 
    327     else
    328       fprintf(fout,"                             vcorr        = %3d      \n", GetnKid(globval.vcorr));
    329                                            
    330     fprintf(fout," Chambre_On   = %s     \n", globval.Aperture_on ? "TRUE " : "FALSE");
    331  
    332     fprintf(fout,"  alphac       =   %8.4e\n", globval.Alphac);
    333     fprintf(fout,"  nux          =   %8.6f      nuy  =  %8.6f",
    334             globval.TotalTune[X_], globval.TotalTune[Y_]);
    335     if (globval.Cavity_on)
    336         fprintf(fout,"  omega  = %13.9f\n", globval.Omega);
    337     else {
    338         fprintf(fout,"\n");
    339         fprintf(fout,"  ksix         =    %8.6f      ksiy  =   %8.6f\n",
    340                 globval.Chrom[X_], globval.Chrom[Y_]);
    341     }
    342     fprintf(fout,"\n");
    343    
    344     fprintf(fout,"  OneTurn matrix:\n");
    345     for(i=0;i<ss_dim;i++){
    346       fprintf(fout,"\n");
    347       for(j=0;j<ss_dim;j++)
    348         fprintf(fout,"%14.6e",globval.OneTurnMat[i][j]);
    349     }
    350 
    351     fprintf(fout,"\n\nTwiss parameters at entrance:\n");
    352     fprintf(fout,
    353             "   Betax [m] = % 9.3e  Alphax = % 9.3e Etax [m] = % 9.3e Etaxp = % 9.3e\n"
    354                 "   Betay [m] = % 9.3e  Alphay = % 9.3e Etay [m] = % 9.3e Etayp = % 9.3e\n\n",
    355             Cell[1].Beta[X_], Cell[1].Alpha[X_], Cell[1].Eta[X_],
    356             Cell[1].Etap[X_], Cell[1].Beta[Y_], Cell[1].Alpha[Y_],
    357             Cell[1].Eta[Y_], Cell[1].Etap[Y_]);
    358 
    359     fclose(fout);
    360 }
    361 
    362 /****************************************************************************/
    363 /* void printlatt(const char fic[])
     253/* void printlatt(void)
    364254
    365255 Purpose:
     
    423313    fclose(outf);
    424314}
    425 /*******************************************************************************
    426  *
    427  *
    428  *
    429  *
    430  ******************************************************************************/
     315
    431316double int_curly_H1(long int n) {
    432317    /* Integration with Simpson's Rule */
     
    445330    return curly_H;
    446331}
    447 /*******************************************************************************
    448  *
    449  *
    450  *
    451  *
    452  ******************************************************************************/
     332
    453333void prt_sigma(void) {
    454334    long int i;
     
    597477    }
    598478}
    599 /*******************************************************************************
    600  *
    601  *
    602  *
    603  *
    604  ******************************************************************************/
     479
    605480void getabn(Vector2 &alpha, Vector2 &beta, Vector2 &nu) {
    606481    Vector2 gamma;
    607482    Cell_GetABGN(globval.OneTurnMat, alpha, beta, gamma, nu);
    608483}
    609 /*******************************************************************************
    610  *
    611  *
    612  *
    613  *
    614  ******************************************************************************/
     484
    615485void TraceABN(long i0, long i1, const Vector2 &alpha, const Vector2 &beta,
    616486        const Vector2 &eta, const Vector2 &etap, const double dP) {
     
    743613    Ring_Fitchrom(ksi, ksieps, ns, sfbuf, sdbuf, ksidkpL, ksiimax);
    744614}
    745 /*******************************************************************************
    746  *
    747  *
    748  *
    749  *
    750  ******************************************************************************/
     615
    751616void FitDisp(long q, long pos, double eta) {
    752     long i=0L, nq=0L;
     617    long i, nq;
    753618    fitvect qbuf;
    754619
     
    760625    Ring_FitDisp(pos, eta, dispeps, nq, qbuf, dispdkL, dispimax);
    761626}
    762 /*******************************************************************************
    763  *
    764  *
    765  *
    766  *
    767  ******************************************************************************/
     627
    768628#define nfloq           4
    769629
     
    775635#undef nfloq
    776636
    777 /*******************************************************************************
    778  *
    779  *
    780  *
    781  *
    782  ******************************************************************************/
    783637#define ntrack          4
    784638
     
    797651
    798652     */
    799     long int i=0L;
    800     double twoJx=0.0, twoJy=0.0, phix=0.0, phiy=0.0, scl_1 = 1.0, scl_2 = 1.0;
     653    long int i;
     654    double twoJx, twoJy, phix, phiy, scl_1 = 1.0, scl_2 = 1.0;
    801655    Vector x0, x1, x2, xf;
    802656    FILE *outf;
     
    956810#undef ntrack
    957811
    958 /*******************************************************************************
    959  *
    960  *
    961  *
    962  *
    963  ******************************************************************************/
    964812#define step            0.1
    965813#define px              0.0
    966814#define py              0.0
    967815void track_(double r, struct LOC_getdynap *LINK) {
    968     long i=0L, lastn=0L, lastpos=0L;
     816    long i, lastn, lastpos;
    969817    Vector x;
    970818
     
    1041889void Trac(double x, double px, double y, double py, double dp, double ctau,
    1042890        long nmax, long pos, long &lastn, long &lastpos, FILE *outf1) {
    1043  
    1044     bool lostF = true; /* Lost particle Flag */
     891    bool lostF; /* Lost particle Flag */
    1045892    Vector x1; /* tracking coordinates */
    1046893    Vector2 aperture;
     
    1060907    lastn = 0L;
    1061908    (lastpos) = pos;
     909    lostF = true;
    1062910
    1063911    if (trace)
     
    1128976#define nfloq     4
    1129977bool chk_if_lost(double x0, double y0, double delta, long int nturn, bool floqs) {
    1130  
    1131     long int i=0L, lastn=0L, lastpos=0L;
     978    long int i, lastn, lastpos;
    1132979    Vector x;
    1133980
     
    12591106 ****************************************************************************/
    12601107void getcsAscr(void) {
    1261     long i=0L, j=0L;
    1262     double phi=0.0;
     1108    long i, j;
     1109    double phi;
    12631110    Matrix R;
    12641111
     
    13311178     Assumes mid-plane symmetry.                    */
    13321179
    1333     long int i=0L, lastpos=0L;
    1334     double phi=0.0, x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0;
     1180    long int i, lastpos;
     1181    double phi, x_min, x_max, y_min, y_max;
    13351182
    13361183    getcod(delta, lastpos);
     
    14221269 ****************************************************************************/
    14231270double get_aper(int n, double x[], double y[]) {
    1424     int i=0;
    1425     double A=0.0;
     1271    int i;
     1272    double A;
    14261273
    14271274    A = 0.0;
     
    14361283}
    14371284
    1438 /**************************************************************************
    1439  * void GetTrack(const char *file_name, long *n, double x[], double px[],
    1440         double y[], double py[])
    1441  *
    1442  *
    1443  *
    1444  **************************************************************************/
    14451285void GetTrack(const char *file_name, long *n, double x[], double px[],
    14461286        double y[], double py[]) {
    1447     int k=0;
     1287    int k;
    14481288    char line[200];
    14491289    FILE *inf;
     
    14951335 ****************************************************************************/
    14961336void Getj(long n, double *x, double *px, double *y, double *py) {
    1497     long int i=0L;
     1337    long int i;
    14981338
    14991339    for (i = 0; i < n; i++) {
     
    15291369 ****************************************************************************/
    15301370double GetArg(double x, double px, double nu) {
    1531    
    1532   double phi=0.0, val=0.0;
     1371    double phi, val;
    15331372
    15341373    phi = GetAngle(x, px);
     
    15681407void GetPhi(long n, double *x, double *px, double *y, double *py) {
    15691408    /* Calculates the linear phase */
    1570     long i=0L;
     1409    long i;
    15711410
    15721411    for (i = 1; i <= n; i++) {
     
    15821421void Sinfft(int n, double xr[]) {
    15831422    /* DFT with sine window */
    1584     int i=0;
     1423    int i;
    15851424    double xi[n];
    15861425
     
    16111450    free_dvector(xi, 1, 2 * n);
    16121451}
    1613 /*******************************************************************************
    1614  *
    1615  *
    1616  *
    1617  *
    1618  ******************************************************************************/
     1452
    16191453void sin_FFT(int n, double xr[], double xi[]) {
    16201454    /* DFT with sine window */
    1621     int i=0;
     1455    int i;
    16221456    double *xri;
    16231457
     
    16361470    free_dvector(xri, 1, 2 * n);
    16371471}
    1638 /*******************************************************************************
    1639  *
    1640  *
    1641  *
    1642  *
    1643  ******************************************************************************/
     1472
    16441473void GetInd(int n, int k, int *ind1, int *ind3) {
    16451474    if (k == 1) {
     
    16541483    }
    16551484}
    1656 /*******************************************************************************
    1657  *
    1658  *
    1659  *
    1660  *
    1661  ******************************************************************************/
     1485
    16621486void GetInd1(int n, int k, int *ind1, int *ind3) {
    16631487    if (k == 1) {
     
    16721496    }
    16731497}
    1674 /*******************************************************************************
    1675  *
    1676  *
    1677  *
    1678  *
    1679  ******************************************************************************/
     1498
    16801499void GetPeak(int n, double *x, int *k) {
    16811500    /* Locate peak in DFT spectrum */
    1682     int ind1=0, ind2=0, ind3=0;
    1683     double peak=0.0;
    1684 
     1501    int ind1, ind2, ind3;
     1502    double peak;
     1503
     1504    peak = 0.0;
    16851505    *k = 1;
    16861506    for (ind2 = 1; ind2 <= n / 2 + 1; ind2++) {
     
    16931513    }
    16941514}
    1695 /*******************************************************************************
    1696  *
    1697  *
    1698  *
    1699  *
    1700  ******************************************************************************/
     1515
    17011516void GetPeak1(int n, double *x, int *k) {
    17021517    /* Locate peak in DFT spectrum */
    1703     int ind1=0, ind2=0, ind3=0;
    1704     double peak=0.0;
    1705 
     1518    int ind1, ind2, ind3;
     1519    double peak;
     1520
     1521    peak = 0.0;
    17061522    *k = 1;
    17071523    for (ind2 = 1; ind2 <= n; ind2++) {
     
    17141530    }
    17151531}
    1716 /*******************************************************************************
    1717  *
    1718  *
    1719  *
    1720  *
    1721  ******************************************************************************/
     1532
    17221533double Int2snu(int n, double *x, int k) {
    17231534    /* Get frequency by nonlinear interpolation with two samples
     
    17281539     N           A(k-1) + A(k)   2
    17291540     */
    1730     int ind=0, ind1=0, ind3=0;
    1731     double ampl1=0.0, ampl2=0.0;
     1541    int ind, ind1, ind3;
     1542    double ampl1, ampl2;
    17321543
    17331544    GetInd(n, k, &ind1, &ind3);
     
    18231634     2      pi ( k + 1/2 )          pi ( k - 1/2 )
    18241635     */
    1825     double corr=0.0;
     1636    double corr;
    18261637
    18271638    corr = (Sinc(M_PI * (k - 1 + 0.5 - nu * n)) + Sinc(M_PI * (k - 1 - 0.5 - nu
     
    18581669    /* Get phase by linear interpolation for rectangular window
    18591670     with -pi <= phi <= pi */
    1860     int i=0;
    1861     double phi=0.0;
     1671    int i;
     1672    double phi;
    18621673    double xr[n], xi[n];
    18631674
     
    19011712 ****************************************************************************/
    19021713void FndRes(struct LOC_findres *LINK) {
    1903     int i=0, j=0, FORLIM=0, FORLIM1=0;
    1904     double delta=0.0;
     1714    int i, j, FORLIM, FORLIM1;
     1715    double delta;
    19051716
    19061717    FORLIM = LINK->n;
     
    19701781    } while (!V.found);
    19711782}
    1972 /*******************************************************************************
    1973  *
    1974  *
    1975  *
    1976  *
    1977  ******************************************************************************/
     1783
    19781784void GetPeaks(int n, double *x, int nf, double *nu, double *A) {
    1979     int i=0, k=0, ind1=0, ind3=0;
     1785    int i, k, ind1, ind3;
    19801786
    19811787    for (i = 0; i < nf; i++) {
     
    19911797    }
    19921798}
    1993 /*******************************************************************************
    1994  *
    1995  *
    1996  *
    1997  *
    1998  ******************************************************************************/
     1799
    19991800void GetPeaks1(int n, double *x, int nf, double *nu, double *A) {
    2000     int i=0, k=0, ind1=0, ind3=0;
     1801    int i, k, ind1, ind3;
    20011802
    20021803    for (i = 0; i < nf; i++) {
     
    20181819
    20191820void SetTol(int Fnum, double dxrms, double dyrms, double drrms) {
    2020     int i=0;
    2021     long k=0L;
     1821    int i;
     1822    long k;
    20221823
    20231824    for (i = 1; i <= GetnKid(Fnum); i++) {
     
    20331834    }
    20341835}
    2035 /*******************************************************************************
    2036  *
    2037  *
    2038  *
    2039  *
    2040  ******************************************************************************/
     1836
    20411837void Scale_Tol(int Fnum, double dxrms, double dyrms, double drrms) {
    2042     int Knum=0;
    2043     long int loc=0L;
     1838    int Knum;
     1839    long int loc;
    20441840
    20451841    for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) {
     
    20791875 ****************************************************************************/
    20801876void SetaTol(int Fnum, int Knum, double dx, double dy, double dr) {
    2081     long int loc=0L;
     1877    long int loc;
    20821878
    20831879    loc = Elem_GetPos(Fnum, Knum);
     
    20911887    Mpole_SetdT(Fnum, Knum);
    20921888}
    2093 /*******************************************************************************
    2094  *
    2095  *
    2096  *
    2097  *
    2098  ******************************************************************************/
     1889
    20991890void ini_aper(const double Dxmin, const double Dxmax, const double Dymin,
    21001891        const double Dymax) {
    2101     int k=0;
     1892    int k;
    21021893
    21031894    for (k = 0; k <= globval.Cell_nLoc; k++) {
     
    21081899    }
    21091900}
    2110 /*******************************************************************************
    2111  *
    2112  *
    2113  *
    2114  *
    2115  ******************************************************************************/
     1901
    21161902void set_aper(const int Fnum, const double Dxmin, const double Dxmax,
    21171903        const double Dymin, const double Dymax) {
    2118     int i=0;
    2119     long int loc=0L;
     1904    int i;
     1905    long int loc;
    21201906
    21211907    for (i = 1; i <= GetnKid(Fnum); i++) {
     
    21271913    }
    21281914}
    2129 /*************************************************
    2130  * void LoadApertures(const char *ChamberFileName)
    2131  *
    2132  *
    2133  *
    2134  **************************************************/
     1915
    21351916void LoadApertures(const char *ChamberFileName) {
    21361917    char line[128], FamName[32];
    2137     long Fnum=0L;
    2138     double Xmin=0.0, Xmax=0.0, Ymin=0.0, Ymax=0.0;
     1918    long Fnum;
     1919    double Xmin, Xmax, Ymin, Ymax;
    21391920    FILE *ChamberFile;
    21401921
     
    21541935    fclose(ChamberFile);
    21551936}
    2156 /**********************************************************************************
    2157  * void LoadTolerances(const char *TolFileName)
    2158  *
    2159  *
    2160  *
    2161  **********************************************************************************/
     1937
    21621938// Load tolerances from the file
    21631939void LoadTolerances(const char *TolFileName) {
    21641940    char line[128], FamName[32];
    2165     int Fnum=0;
    2166     double dx=0.0, dy=0.0, dr=0.0;
     1941    int Fnum;
     1942    double dx, dy, dr;
    21671943    FILE *tolfile;
    21681944
    21691945    tolfile = file_read(TolFileName);
    2170     if(tolfile == NULL){
    2171       printf("LoadTolerances(): Error! Failure to read file: %s \n",TolFileName);
    2172       exit_(1);
    2173     }
    21741946
    21751947    do
     
    21931965}
    21941966
    2195 /**************************************************************************************
    2196  * void ScaleTolerances(const char *TolFileName, const double scl)
    2197  *
    2198  *
    2199  *
    2200  * ************************************************************************************/
    22011967// Load tolerances from the file
    22021968void ScaleTolerances(const char *TolFileName, const double scl) {
    22031969    char line[128], FamName[32];
    2204     int Fnum=0;
    2205     double dx=0.0, dy=0.0, dr=0.0;
     1970    int Fnum;
     1971    double dx, dy, dr;
    22061972    FILE *tolfile;
    22071973
    22081974    tolfile = file_read(TolFileName);
    2209     if(tolfile == NULL){
    2210       printf("LoadTolerances(): Error! Failure to read file: %s \n",TolFileName);
    2211       exit_(1);
    2212     }
    2213    
     1975
    22141976    do
    22151977        fgets(line, 128, tolfile);
     
    22301992    fclose(tolfile);
    22311993}
    2232 /*******************************************************************************
    2233  *
    2234  *
    2235  *
    2236  *
    2237  ******************************************************************************/
     1994
    22381995void SetKpar(int Fnum, int Knum, int Order, double k) {
    22391996
     
    22411998    Mpole_SetPB(Fnum, Knum, Order);
    22421999}
    2243 /*******************************************************************************
    2244  *
    2245  *
    2246  *
    2247  *
    2248  ******************************************************************************/
     2000
    22492001void SetL(int Fnum, int Knum, double L) {
    22502002
    22512003    Cell[Elem_GetPos(Fnum, Knum)].Elem.PL = L;
    22522004}
    2253 /*******************************************************************************
    2254  *
    2255  *
    2256  *
    2257  *
    2258  ******************************************************************************/
     2005
    22592006void SetL(int Fnum, double L) {
    2260     int i=0;
     2007    int i;
    22612008
    22622009    for (i = 1; i <= GetnKid(Fnum); i++)
    22632010        Cell[Elem_GetPos(Fnum, i)].Elem.PL = L;
    22642011}
    2265 /*******************************************************************************
    2266  *
    2267  *
    2268  *
    2269  *
    2270  ******************************************************************************/
     2012
    22712013void SetdKpar(int Fnum, int Knum, int Order, double dk) {
    22722014
     
    22742016    Mpole_SetPB(Fnum, Knum, Order);
    22752017}
    2276 /*******************************************************************************
    2277  *
    2278  *
    2279  *
    2280  *
    2281  ******************************************************************************/
     2018
    22822019void SetKLpar(int Fnum, int Knum, int Order, double kL) {
    2283     long int loc=0L;
     2020    long int loc;
    22842021
    22852022    if (abs(Order) > HOMmax) {
     
    22962033    Mpole_SetPB(Fnum, Knum, Order);
    22972034}
    2298 /*******************************************************************************
    2299  *
    2300  *
    2301  *
    2302  *
    2303  ******************************************************************************/
     2035
    23042036void SetdKLpar(int Fnum, int Knum, int Order, double dkL) {
    2305     long int loc=0L;
     2037    long int loc;
    23062038
    23072039    loc = Elem_GetPos(Fnum, Knum);
     
    23322064**************************************************************/
    23332065void SetdKrpar(int Fnum, int Knum, int Order, double dkrel) {
    2334     long int loc=0L;
     2066    long int loc;
    23352067
    23362068    loc = Elem_GetPos(Fnum, Knum);
     
    23432075    Mpole_SetPB(Fnum, Knum, Order);
    23442076}
    2345 /*******************************************************************************
    2346  *
    2347  *
    2348  *
    2349  *
    2350  ******************************************************************************/
     2077
    23512078void Setbn(int Fnum, int order, double bn) {
    2352     int i=0;
     2079    int i;
    23532080
    23542081    for (i = 1; i <= GetnKid(Fnum); i++)
    23552082        SetKpar(Fnum, i, order, bn);
    23562083}
    2357 /*******************************************************************************
    2358  *
    2359  *
    2360  *
    2361  *
    2362  ******************************************************************************/
     2084
    23632085void SetbnL(int Fnum, int order, double bnL) {
    2364     int i=0;
     2086    int i;
    23652087
    23662088    for (i = 1; i <= GetnKid(Fnum); i++)
    23672089        SetKLpar(Fnum, i, order, bnL);
    23682090}
    2369 /*******************************************************************************
    2370  *
    2371  *
    2372  *
    2373  *
    2374  ******************************************************************************/
     2091
    23752092void Setdbn(int Fnum, int order, double dbn) {
    2376     int i=0;
     2093    int i;
    23772094
    23782095    for (i = 1; i <= GetnKid(Fnum); i++)
    23792096        SetdKpar(Fnum, i, order, dbn);
    23802097}
    2381 /*******************************************************************************
    2382  *
    2383  *
    2384  *
    2385  *
    2386  ******************************************************************************/
     2098
    23872099void SetdbnL(int Fnum, int order, double dbnL) {
    2388     int i=0;
     2100    int i;
    23892101
    23902102    for (i = 1; i <= GetnKid(Fnum); i++) {
     
    24152127//void Setbnr(int Fnum, long order, double bnr) {
    24162128void Setbnr(int Fnum, int order, double bnr) {
    2417     int i=0;
     2129    int i;
    24182130
    24192131    for (i = 1; i <= GetnKid(Fnum); i++)
    24202132        SetdKrpar(Fnum, i, order, bnr);
    24212133}
    2422 /*******************************************************************************
    2423  *
    2424  *
    2425  *
    2426  *
    2427  ******************************************************************************/
     2134
    24282135void SetbnL_sys(int Fnum, int Order, double bnL_sys) {
    2429     int Knum=0;
    2430     long int loc=0L;
     2136    int Knum;
     2137    long int loc;
    24312138
    24322139    for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) {
     
    24402147    }
    24412148}
    2442 /*******************************************************************************
    2443  *
    2444  *
    2445  *
    2446  *
    2447  ******************************************************************************/
     2149
    24482150void set_dbn_rel(const int type, const int n, const double dbn_rel) {
    2449     long int j=0L;
    2450     double dbn=0.0;
     2151    long int j;
     2152    double dbn;
    24512153
    24522154    printf("\n");
     
    25352237        return (Cell[loc].Elem.M->PBpar[Order + HOMmax]);
    25362238}
    2537 /*******************************************************************************
    2538  *
    2539  *
    2540  *
    2541  *
    2542  ******************************************************************************/
     2239
    25432240void SetdKLrms(int Fnum, int Order, double dkLrms) {
    2544     long int Knum=0L, loc=0L;
     2241    long int Knum, loc;
    25452242
    25462243    for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) {
     
    25552252    }
    25562253}
    2557 /*******************************************************************************
    2558  *
    2559  *
    2560  *
    2561  *
    2562  ******************************************************************************/
     2254
    25632255void Setdkrrms(int Fnum, int Order, double dkrrms) {
    2564     long int Knum=0L, loc=0L;
     2256    long int Knum, loc;
    25652257
    25662258    for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) {
     
    25762268    }
    25772269}
    2578 /*******************************************************************************
    2579  *
    2580  *
    2581  *
    2582  *
    2583  ******************************************************************************/
     2270
    25842271void SetKL(int Fnum, int Order) {
    2585     long int Knum=0L;
     2272    long int Knum;
    25862273
    25872274    for (Knum = 1; Knum <= GetnKid(Fnum); Knum++)
    25882275        Mpole_SetPB(Fnum, Knum, Order);
    25892276}
    2590 /*******************************************************************************
    2591  *
    2592  *
    2593  *
    2594  *
    2595  ******************************************************************************/
     2277
    25962278void set_dx(const int type, const double sigma_x, const double sigma_y) {
    2597     long int j=0L;
     2279    long int j;
    25982280
    25992281    printf("\n");
     
    26112293        }
    26122294}
    2613 /*******************************************************************************
    2614  *
    2615  *
    2616  *
    2617  *
    2618  ******************************************************************************/
     2295
    26192296void SetBpmdS(int Fnum, double dxrms, double dyrms) {
    2620     long int Knum, loc=0L;
     2297    long int Knum, loc;
    26212298
    26222299    for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) {
     
    26442321****************************************************************************/
    26452322void codstat(double *mean, double *sigma, double *xmax, long lastpos, bool all) {
    2646     long i=0L, j=0L, n=0L;
     2323    long i, j, n;
    26472324    Vector2 sum, sum2;
    2648     double TEMP=0.0;
     2325    double TEMP;
    26492326
    26502327    n = 0;
     
    27112388void CodStatBpm(double *mean, double *sigma, double *xmax, long lastpos,
    27122389        long bpmdis[mnp]) {
    2713     long i=0L, j=0L, m=0L, n=0L;
     2390    long i, j, m, n;
    27142391    Vector2 sum, sum2;
    2715     double TEMP=0.0;
     2392    double TEMP;
    27162393
    27172394    m = n = 0;
     
    28712548 ****************************************************************************/
    28722549void GetMean(long n, double *x) {
    2873     long i=0L;
     2550    long i;
    28742551    double mean = 0e0;
    28752552
     
    32802957    const int ntrial = 40; // maximum number of trials for closed orbit
    32812958    const double tolx = 1e-8; // numerical precision
    3282     int k=0;
    3283     int dim=0; // 4D or 6D tracking
    3284     long lastpos=0L;
     2959    int k;
     2960    int dim; // 4D or 6D tracking
     2961    long lastpos;
    32852962
    32862963    vcod = dvector(1, 6);
     
    33623039    const int ntrial = 40; // maximum number of trials for closed orbit
    33633040    const double tolx = 1e-10; // numerical precision
    3364     int k=0, dim = 0;
    3365     long lastpos=0L;
     3041    int k, dim = 0;
     3042    long lastpos;
    33663043
    33673044    // initializations
     
    34293106
    34303107void computeFandJS(double *x, int n, double **fjac, double *fvect) {
    3431     int i=0, k=0;
     3108    int i, k;
    34323109    long lastpos = 0L;
    34333110    Vector x0, fx, fx1, fx2;
     
    35013178 ****************************************************************************/
    35023179void computeFandJ(int n, Vector &x, Matrix &fjac, Vector &fvect) {
    3503     int i=0, k=0;
     3180    int i, k;
    35043181    long lastpos = 0;
    35053182    Vector x0, fx1, fx2;
     
    35833260
    35843261void Newton_RaphsonS(int ntrial, double x[], int n, double tolx) {
    3585     int k=0, i=0, *indx;
    3586     double errx=0.0, d=0.0, *bet, *fvect, **alpha;
     3262    int k, i, *indx;
     3263    double errx, d, *bet, *fvect, **alpha;
    35873264
    35883265    errx = 0.0;
     
    36813358 ****************************************************************************/
    36823359int Newton_Raphson(int n, Vector &x, int ntrial, double tolx) {
    3683     int k=0, i=0;
    3684     double errx=0.0;
     3360    int k, i;
     3361    double errx;
    36853362    Vector bet, fvect;
    36863363    Matrix alpha;
     
    37243401    return 0;
    37253402}
    3726 /*******************************************************************************
    3727  *
    3728  *
    3729  *
    3730  *
    3731  ******************************************************************************/
     3403
    37323404void rm_mean(long int n, double x[]) {
    3733     long int i=0L;
    3734     double mean=0.0;
    3735 
     3405    long int i;
     3406    double mean;
     3407
     3408    mean = 0.0;
    37363409    for (i = 0; i < n; i++)
    37373410        mean += x[i];
Note: See TracChangeset for help on using the changeset viewer.