Changeset 23 in TRACY3 for branches/tracy3-3.10.1b/tracy/tracy/src/physlib.cc
- Timestamp:
- Dec 6, 2013, 5:12:43 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tracy3-3.10.1b/tracy/tracy/src/physlib.cc
r11 r23 16 16 /**************************/ 17 17 18 /******************************************************************************* 19 * 20 * 21 * 22 * 23 ******************************************************************************/ 18 24 19 /**** same as asctime in C without the \n at the end****/ 25 20 char *asctime2(const struct tm *timeptr) { … … 38 33 return result; 39 34 } 40 /******************************************************************************* 41 * 42 * 43 * 44 * 45 ******************************************************************************/ 35 46 36 /** Get time and date **/ 47 37 struct tm* GetTime() { … … 199 189 200 190 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 file203 191 204 192 ****************************************************************************/ … … 263 251 264 252 /****************************************************************************/ 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) 364 254 365 255 Purpose: … … 423 313 fclose(outf); 424 314 } 425 /******************************************************************************* 426 * 427 * 428 * 429 * 430 ******************************************************************************/ 315 431 316 double int_curly_H1(long int n) { 432 317 /* Integration with Simpson's Rule */ … … 445 330 return curly_H; 446 331 } 447 /******************************************************************************* 448 * 449 * 450 * 451 * 452 ******************************************************************************/ 332 453 333 void prt_sigma(void) { 454 334 long int i; … … 597 477 } 598 478 } 599 /******************************************************************************* 600 * 601 * 602 * 603 * 604 ******************************************************************************/ 479 605 480 void getabn(Vector2 &alpha, Vector2 &beta, Vector2 &nu) { 606 481 Vector2 gamma; 607 482 Cell_GetABGN(globval.OneTurnMat, alpha, beta, gamma, nu); 608 483 } 609 /******************************************************************************* 610 * 611 * 612 * 613 * 614 ******************************************************************************/ 484 615 485 void TraceABN(long i0, long i1, const Vector2 &alpha, const Vector2 &beta, 616 486 const Vector2 &eta, const Vector2 &etap, const double dP) { … … 743 613 Ring_Fitchrom(ksi, ksieps, ns, sfbuf, sdbuf, ksidkpL, ksiimax); 744 614 } 745 /******************************************************************************* 746 * 747 * 748 * 749 * 750 ******************************************************************************/ 615 751 616 void FitDisp(long q, long pos, double eta) { 752 long i =0L, nq=0L;617 long i, nq; 753 618 fitvect qbuf; 754 619 … … 760 625 Ring_FitDisp(pos, eta, dispeps, nq, qbuf, dispdkL, dispimax); 761 626 } 762 /******************************************************************************* 763 * 764 * 765 * 766 * 767 ******************************************************************************/ 627 768 628 #define nfloq 4 769 629 … … 775 635 #undef nfloq 776 636 777 /*******************************************************************************778 *779 *780 *781 *782 ******************************************************************************/783 637 #define ntrack 4 784 638 … … 797 651 798 652 */ 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; 801 655 Vector x0, x1, x2, xf; 802 656 FILE *outf; … … 956 810 #undef ntrack 957 811 958 /*******************************************************************************959 *960 *961 *962 *963 ******************************************************************************/964 812 #define step 0.1 965 813 #define px 0.0 966 814 #define py 0.0 967 815 void track_(double r, struct LOC_getdynap *LINK) { 968 long i =0L, lastn=0L, lastpos=0L;816 long i, lastn, lastpos; 969 817 Vector x; 970 818 … … 1041 889 void Trac(double x, double px, double y, double py, double dp, double ctau, 1042 890 long nmax, long pos, long &lastn, long &lastpos, FILE *outf1) { 1043 1044 bool lostF = true; /* Lost particle Flag */ 891 bool lostF; /* Lost particle Flag */ 1045 892 Vector x1; /* tracking coordinates */ 1046 893 Vector2 aperture; … … 1060 907 lastn = 0L; 1061 908 (lastpos) = pos; 909 lostF = true; 1062 910 1063 911 if (trace) … … 1128 976 #define nfloq 4 1129 977 bool 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; 1132 979 Vector x; 1133 980 … … 1259 1106 ****************************************************************************/ 1260 1107 void getcsAscr(void) { 1261 long i =0L, j=0L;1262 double phi =0.0;1108 long i, j; 1109 double phi; 1263 1110 Matrix R; 1264 1111 … … 1331 1178 Assumes mid-plane symmetry. */ 1332 1179 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; 1335 1182 1336 1183 getcod(delta, lastpos); … … 1422 1269 ****************************************************************************/ 1423 1270 double get_aper(int n, double x[], double y[]) { 1424 int i =0;1425 double A =0.0;1271 int i; 1272 double A; 1426 1273 1427 1274 A = 0.0; … … 1436 1283 } 1437 1284 1438 /**************************************************************************1439 * void GetTrack(const char *file_name, long *n, double x[], double px[],1440 double y[], double py[])1441 *1442 *1443 *1444 **************************************************************************/1445 1285 void GetTrack(const char *file_name, long *n, double x[], double px[], 1446 1286 double y[], double py[]) { 1447 int k =0;1287 int k; 1448 1288 char line[200]; 1449 1289 FILE *inf; … … 1495 1335 ****************************************************************************/ 1496 1336 void Getj(long n, double *x, double *px, double *y, double *py) { 1497 long int i =0L;1337 long int i; 1498 1338 1499 1339 for (i = 0; i < n; i++) { … … 1529 1369 ****************************************************************************/ 1530 1370 double GetArg(double x, double px, double nu) { 1531 1532 double phi=0.0, val=0.0; 1371 double phi, val; 1533 1372 1534 1373 phi = GetAngle(x, px); … … 1568 1407 void GetPhi(long n, double *x, double *px, double *y, double *py) { 1569 1408 /* Calculates the linear phase */ 1570 long i =0L;1409 long i; 1571 1410 1572 1411 for (i = 1; i <= n; i++) { … … 1582 1421 void Sinfft(int n, double xr[]) { 1583 1422 /* DFT with sine window */ 1584 int i =0;1423 int i; 1585 1424 double xi[n]; 1586 1425 … … 1611 1450 free_dvector(xi, 1, 2 * n); 1612 1451 } 1613 /******************************************************************************* 1614 * 1615 * 1616 * 1617 * 1618 ******************************************************************************/ 1452 1619 1453 void sin_FFT(int n, double xr[], double xi[]) { 1620 1454 /* DFT with sine window */ 1621 int i =0;1455 int i; 1622 1456 double *xri; 1623 1457 … … 1636 1470 free_dvector(xri, 1, 2 * n); 1637 1471 } 1638 /******************************************************************************* 1639 * 1640 * 1641 * 1642 * 1643 ******************************************************************************/ 1472 1644 1473 void GetInd(int n, int k, int *ind1, int *ind3) { 1645 1474 if (k == 1) { … … 1654 1483 } 1655 1484 } 1656 /******************************************************************************* 1657 * 1658 * 1659 * 1660 * 1661 ******************************************************************************/ 1485 1662 1486 void GetInd1(int n, int k, int *ind1, int *ind3) { 1663 1487 if (k == 1) { … … 1672 1496 } 1673 1497 } 1674 /******************************************************************************* 1675 * 1676 * 1677 * 1678 * 1679 ******************************************************************************/ 1498 1680 1499 void GetPeak(int n, double *x, int *k) { 1681 1500 /* 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; 1685 1505 *k = 1; 1686 1506 for (ind2 = 1; ind2 <= n / 2 + 1; ind2++) { … … 1693 1513 } 1694 1514 } 1695 /******************************************************************************* 1696 * 1697 * 1698 * 1699 * 1700 ******************************************************************************/ 1515 1701 1516 void GetPeak1(int n, double *x, int *k) { 1702 1517 /* 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; 1706 1522 *k = 1; 1707 1523 for (ind2 = 1; ind2 <= n; ind2++) { … … 1714 1530 } 1715 1531 } 1716 /******************************************************************************* 1717 * 1718 * 1719 * 1720 * 1721 ******************************************************************************/ 1532 1722 1533 double Int2snu(int n, double *x, int k) { 1723 1534 /* Get frequency by nonlinear interpolation with two samples … … 1728 1539 N A(k-1) + A(k) 2 1729 1540 */ 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; 1732 1543 1733 1544 GetInd(n, k, &ind1, &ind3); … … 1823 1634 2 pi ( k + 1/2 ) pi ( k - 1/2 ) 1824 1635 */ 1825 double corr =0.0;1636 double corr; 1826 1637 1827 1638 corr = (Sinc(M_PI * (k - 1 + 0.5 - nu * n)) + Sinc(M_PI * (k - 1 - 0.5 - nu … … 1858 1669 /* Get phase by linear interpolation for rectangular window 1859 1670 with -pi <= phi <= pi */ 1860 int i =0;1861 double phi =0.0;1671 int i; 1672 double phi; 1862 1673 double xr[n], xi[n]; 1863 1674 … … 1901 1712 ****************************************************************************/ 1902 1713 void 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; 1905 1716 1906 1717 FORLIM = LINK->n; … … 1970 1781 } while (!V.found); 1971 1782 } 1972 /******************************************************************************* 1973 * 1974 * 1975 * 1976 * 1977 ******************************************************************************/ 1783 1978 1784 void 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; 1980 1786 1981 1787 for (i = 0; i < nf; i++) { … … 1991 1797 } 1992 1798 } 1993 /******************************************************************************* 1994 * 1995 * 1996 * 1997 * 1998 ******************************************************************************/ 1799 1999 1800 void 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; 2001 1802 2002 1803 for (i = 0; i < nf; i++) { … … 2018 1819 2019 1820 void SetTol(int Fnum, double dxrms, double dyrms, double drrms) { 2020 int i =0;2021 long k =0L;1821 int i; 1822 long k; 2022 1823 2023 1824 for (i = 1; i <= GetnKid(Fnum); i++) { … … 2033 1834 } 2034 1835 } 2035 /******************************************************************************* 2036 * 2037 * 2038 * 2039 * 2040 ******************************************************************************/ 1836 2041 1837 void 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; 2044 1840 2045 1841 for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) { … … 2079 1875 ****************************************************************************/ 2080 1876 void SetaTol(int Fnum, int Knum, double dx, double dy, double dr) { 2081 long int loc =0L;1877 long int loc; 2082 1878 2083 1879 loc = Elem_GetPos(Fnum, Knum); … … 2091 1887 Mpole_SetdT(Fnum, Knum); 2092 1888 } 2093 /******************************************************************************* 2094 * 2095 * 2096 * 2097 * 2098 ******************************************************************************/ 1889 2099 1890 void ini_aper(const double Dxmin, const double Dxmax, const double Dymin, 2100 1891 const double Dymax) { 2101 int k =0;1892 int k; 2102 1893 2103 1894 for (k = 0; k <= globval.Cell_nLoc; k++) { … … 2108 1899 } 2109 1900 } 2110 /******************************************************************************* 2111 * 2112 * 2113 * 2114 * 2115 ******************************************************************************/ 1901 2116 1902 void set_aper(const int Fnum, const double Dxmin, const double Dxmax, 2117 1903 const double Dymin, const double Dymax) { 2118 int i =0;2119 long int loc =0L;1904 int i; 1905 long int loc; 2120 1906 2121 1907 for (i = 1; i <= GetnKid(Fnum); i++) { … … 2127 1913 } 2128 1914 } 2129 /************************************************* 2130 * void LoadApertures(const char *ChamberFileName) 2131 * 2132 * 2133 * 2134 **************************************************/ 1915 2135 1916 void LoadApertures(const char *ChamberFileName) { 2136 1917 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; 2139 1920 FILE *ChamberFile; 2140 1921 … … 2154 1935 fclose(ChamberFile); 2155 1936 } 2156 /********************************************************************************** 2157 * void LoadTolerances(const char *TolFileName) 2158 * 2159 * 2160 * 2161 **********************************************************************************/ 1937 2162 1938 // Load tolerances from the file 2163 1939 void LoadTolerances(const char *TolFileName) { 2164 1940 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; 2167 1943 FILE *tolfile; 2168 1944 2169 1945 tolfile = file_read(TolFileName); 2170 if(tolfile == NULL){2171 printf("LoadTolerances(): Error! Failure to read file: %s \n",TolFileName);2172 exit_(1);2173 }2174 1946 2175 1947 do … … 2193 1965 } 2194 1966 2195 /**************************************************************************************2196 * void ScaleTolerances(const char *TolFileName, const double scl)2197 *2198 *2199 *2200 * ************************************************************************************/2201 1967 // Load tolerances from the file 2202 1968 void ScaleTolerances(const char *TolFileName, const double scl) { 2203 1969 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; 2206 1972 FILE *tolfile; 2207 1973 2208 1974 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 2214 1976 do 2215 1977 fgets(line, 128, tolfile); … … 2230 1992 fclose(tolfile); 2231 1993 } 2232 /******************************************************************************* 2233 * 2234 * 2235 * 2236 * 2237 ******************************************************************************/ 1994 2238 1995 void SetKpar(int Fnum, int Knum, int Order, double k) { 2239 1996 … … 2241 1998 Mpole_SetPB(Fnum, Knum, Order); 2242 1999 } 2243 /******************************************************************************* 2244 * 2245 * 2246 * 2247 * 2248 ******************************************************************************/ 2000 2249 2001 void SetL(int Fnum, int Knum, double L) { 2250 2002 2251 2003 Cell[Elem_GetPos(Fnum, Knum)].Elem.PL = L; 2252 2004 } 2253 /******************************************************************************* 2254 * 2255 * 2256 * 2257 * 2258 ******************************************************************************/ 2005 2259 2006 void SetL(int Fnum, double L) { 2260 int i =0;2007 int i; 2261 2008 2262 2009 for (i = 1; i <= GetnKid(Fnum); i++) 2263 2010 Cell[Elem_GetPos(Fnum, i)].Elem.PL = L; 2264 2011 } 2265 /******************************************************************************* 2266 * 2267 * 2268 * 2269 * 2270 ******************************************************************************/ 2012 2271 2013 void SetdKpar(int Fnum, int Knum, int Order, double dk) { 2272 2014 … … 2274 2016 Mpole_SetPB(Fnum, Knum, Order); 2275 2017 } 2276 /******************************************************************************* 2277 * 2278 * 2279 * 2280 * 2281 ******************************************************************************/ 2018 2282 2019 void SetKLpar(int Fnum, int Knum, int Order, double kL) { 2283 long int loc =0L;2020 long int loc; 2284 2021 2285 2022 if (abs(Order) > HOMmax) { … … 2296 2033 Mpole_SetPB(Fnum, Knum, Order); 2297 2034 } 2298 /******************************************************************************* 2299 * 2300 * 2301 * 2302 * 2303 ******************************************************************************/ 2035 2304 2036 void SetdKLpar(int Fnum, int Knum, int Order, double dkL) { 2305 long int loc =0L;2037 long int loc; 2306 2038 2307 2039 loc = Elem_GetPos(Fnum, Knum); … … 2332 2064 **************************************************************/ 2333 2065 void SetdKrpar(int Fnum, int Knum, int Order, double dkrel) { 2334 long int loc =0L;2066 long int loc; 2335 2067 2336 2068 loc = Elem_GetPos(Fnum, Knum); … … 2343 2075 Mpole_SetPB(Fnum, Knum, Order); 2344 2076 } 2345 /******************************************************************************* 2346 * 2347 * 2348 * 2349 * 2350 ******************************************************************************/ 2077 2351 2078 void Setbn(int Fnum, int order, double bn) { 2352 int i =0;2079 int i; 2353 2080 2354 2081 for (i = 1; i <= GetnKid(Fnum); i++) 2355 2082 SetKpar(Fnum, i, order, bn); 2356 2083 } 2357 /******************************************************************************* 2358 * 2359 * 2360 * 2361 * 2362 ******************************************************************************/ 2084 2363 2085 void SetbnL(int Fnum, int order, double bnL) { 2364 int i =0;2086 int i; 2365 2087 2366 2088 for (i = 1; i <= GetnKid(Fnum); i++) 2367 2089 SetKLpar(Fnum, i, order, bnL); 2368 2090 } 2369 /******************************************************************************* 2370 * 2371 * 2372 * 2373 * 2374 ******************************************************************************/ 2091 2375 2092 void Setdbn(int Fnum, int order, double dbn) { 2376 int i =0;2093 int i; 2377 2094 2378 2095 for (i = 1; i <= GetnKid(Fnum); i++) 2379 2096 SetdKpar(Fnum, i, order, dbn); 2380 2097 } 2381 /******************************************************************************* 2382 * 2383 * 2384 * 2385 * 2386 ******************************************************************************/ 2098 2387 2099 void SetdbnL(int Fnum, int order, double dbnL) { 2388 int i =0;2100 int i; 2389 2101 2390 2102 for (i = 1; i <= GetnKid(Fnum); i++) { … … 2415 2127 //void Setbnr(int Fnum, long order, double bnr) { 2416 2128 void Setbnr(int Fnum, int order, double bnr) { 2417 int i =0;2129 int i; 2418 2130 2419 2131 for (i = 1; i <= GetnKid(Fnum); i++) 2420 2132 SetdKrpar(Fnum, i, order, bnr); 2421 2133 } 2422 /******************************************************************************* 2423 * 2424 * 2425 * 2426 * 2427 ******************************************************************************/ 2134 2428 2135 void 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; 2431 2138 2432 2139 for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) { … … 2440 2147 } 2441 2148 } 2442 /******************************************************************************* 2443 * 2444 * 2445 * 2446 * 2447 ******************************************************************************/ 2149 2448 2150 void 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; 2451 2153 2452 2154 printf("\n"); … … 2535 2237 return (Cell[loc].Elem.M->PBpar[Order + HOMmax]); 2536 2238 } 2537 /******************************************************************************* 2538 * 2539 * 2540 * 2541 * 2542 ******************************************************************************/ 2239 2543 2240 void SetdKLrms(int Fnum, int Order, double dkLrms) { 2544 long int Knum =0L, loc=0L;2241 long int Knum, loc; 2545 2242 2546 2243 for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) { … … 2555 2252 } 2556 2253 } 2557 /******************************************************************************* 2558 * 2559 * 2560 * 2561 * 2562 ******************************************************************************/ 2254 2563 2255 void Setdkrrms(int Fnum, int Order, double dkrrms) { 2564 long int Knum =0L, loc=0L;2256 long int Knum, loc; 2565 2257 2566 2258 for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) { … … 2576 2268 } 2577 2269 } 2578 /******************************************************************************* 2579 * 2580 * 2581 * 2582 * 2583 ******************************************************************************/ 2270 2584 2271 void SetKL(int Fnum, int Order) { 2585 long int Knum =0L;2272 long int Knum; 2586 2273 2587 2274 for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) 2588 2275 Mpole_SetPB(Fnum, Knum, Order); 2589 2276 } 2590 /******************************************************************************* 2591 * 2592 * 2593 * 2594 * 2595 ******************************************************************************/ 2277 2596 2278 void set_dx(const int type, const double sigma_x, const double sigma_y) { 2597 long int j =0L;2279 long int j; 2598 2280 2599 2281 printf("\n"); … … 2611 2293 } 2612 2294 } 2613 /******************************************************************************* 2614 * 2615 * 2616 * 2617 * 2618 ******************************************************************************/ 2295 2619 2296 void SetBpmdS(int Fnum, double dxrms, double dyrms) { 2620 long int Knum, loc =0L;2297 long int Knum, loc; 2621 2298 2622 2299 for (Knum = 1; Knum <= GetnKid(Fnum); Knum++) { … … 2644 2321 ****************************************************************************/ 2645 2322 void codstat(double *mean, double *sigma, double *xmax, long lastpos, bool all) { 2646 long i =0L, j=0L, n=0L;2323 long i, j, n; 2647 2324 Vector2 sum, sum2; 2648 double TEMP =0.0;2325 double TEMP; 2649 2326 2650 2327 n = 0; … … 2711 2388 void CodStatBpm(double *mean, double *sigma, double *xmax, long lastpos, 2712 2389 long bpmdis[mnp]) { 2713 long i =0L, j=0L, m=0L, n=0L;2390 long i, j, m, n; 2714 2391 Vector2 sum, sum2; 2715 double TEMP =0.0;2392 double TEMP; 2716 2393 2717 2394 m = n = 0; … … 2871 2548 ****************************************************************************/ 2872 2549 void GetMean(long n, double *x) { 2873 long i =0L;2550 long i; 2874 2551 double mean = 0e0; 2875 2552 … … 3280 2957 const int ntrial = 40; // maximum number of trials for closed orbit 3281 2958 const double tolx = 1e-8; // numerical precision 3282 int k =0;3283 int dim =0; // 4D or 6D tracking3284 long lastpos =0L;2959 int k; 2960 int dim; // 4D or 6D tracking 2961 long lastpos; 3285 2962 3286 2963 vcod = dvector(1, 6); … … 3362 3039 const int ntrial = 40; // maximum number of trials for closed orbit 3363 3040 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; 3366 3043 3367 3044 // initializations … … 3429 3106 3430 3107 void computeFandJS(double *x, int n, double **fjac, double *fvect) { 3431 int i =0, k=0;3108 int i, k; 3432 3109 long lastpos = 0L; 3433 3110 Vector x0, fx, fx1, fx2; … … 3501 3178 ****************************************************************************/ 3502 3179 void computeFandJ(int n, Vector &x, Matrix &fjac, Vector &fvect) { 3503 int i =0, k=0;3180 int i, k; 3504 3181 long lastpos = 0; 3505 3182 Vector x0, fx1, fx2; … … 3583 3260 3584 3261 void 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; 3587 3264 3588 3265 errx = 0.0; … … 3681 3358 ****************************************************************************/ 3682 3359 int 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; 3685 3362 Vector bet, fvect; 3686 3363 Matrix alpha; … … 3724 3401 return 0; 3725 3402 } 3726 /******************************************************************************* 3727 * 3728 * 3729 * 3730 * 3731 ******************************************************************************/ 3403 3732 3404 void 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; 3736 3409 for (i = 0; i < n; i++) 3737 3410 mean += x[i];
Note: See TracChangeset
for help on using the changeset viewer.