diff --git a/tracy/tracy/src/nsls-ii_lib.cc b/tracy/tracy/src/nsls-ii_lib.cc index 2eae6cb5340bd5a1997f13af3e39a53bf4f0dc84..834f5f44816148d0a42f729368da451e7c7fce79 100644 --- a/tracy/tracy/src/nsls-ii_lib.cc +++ b/tracy/tracy/src/nsls-ii_lib.cc @@ -5,9 +5,9 @@ T. Shaftan, I. Pinayev, Y. Luo, C. Montag, B. Nash */ -/* Current revision $Revision: 1.10 $ +/* Current revision $Revision: 1.11 $ On branch $Name: not supported by cvs2svn $ - Latest change by $Author: nadolski $ + Latest change by $Author: zhang $ */ // global params @@ -2463,7 +2463,8 @@ char* get_prm(void) \n Comments: 10/2010 By Jianfeng Zhang - Fix the bug for reading the line end symbol "\n" or "\r" + Fix the bug for reading the end of line symbol "\n" , "\r",'\r\n' + at different operation system *********************************************************************/ char* get_prm(void) { @@ -4560,12 +4561,14 @@ void pol_fit(int n, double x[], double y[], int order, Vector &b, const double sigma_k = 1.0, chi2 = 4.0; + /* initialization */ for (i = 0; i <= order; i++) { b[i] = 0.0; for (j = 0; j <= order; j++) T1[i][j] = 0.0; } + /* polynomal fiting */ for (i = 0; i < n; i++) for (j = 0; j <= order; j++) { b[j] += y[i]*pow(x[i], j)/pow(sigma_k, 2); @@ -4838,7 +4841,13 @@ void get_alphac(void) void get_alphac2(void) Purpose: - Calculate momentum compact factor up to third order + Calculate momentum compact factor up to third order. + Method: + track the orbit offset c*tau at the first element, + at 11 different energy offset(-10-3 to 10-3), then + use polynomal to fit the momentum compact faction factor + up to 3rd order. + The initial coorinates are (x_co,px_co,y_co,py_co,delta,0). Input: none @@ -4853,7 +4862,8 @@ void get_alphac2(void) none Comments: - none + change the initial coorinates from (0 0 0 0 delta 0) to + (x_co,px_co,y_co,py_co,delta,0). *******************************************************************/ @@ -4864,12 +4874,14 @@ void get_alphac2(void) const int n_points = 5; const double d_delta = 1e-3; + //const double d_delta = 1e-4; int i, j, n; - long int lastpos; + long int lastpos; // last tracking position when the particle is stable double delta[2*n_points+1], alphac[2*n_points+1], sigma; Vector x, b; CellType Cell; + bool cod; globval.pathlength = false; getelem(globval.Cell_nLoc, &Cell); @@ -4878,15 +4890,21 @@ void get_alphac2(void) for (i = -n_points; i <= n_points; i++) { n++; delta[n-1] = i*(double)d_delta/(double)n_points; - for (j = 0; j < nv_; j++) - x[j] = 0.0; - x[delta_] = delta[n-1]; + + // for (j = 0; j < nv_; j++) + // x[j] = 0.0; + // x[delta_] = delta[n-1]; + + cod = getcod(delta[n-1], lastpos); + x = globval.CODvect; + + Cell_Pass(0, globval.Cell_nLoc, x, lastpos); alphac[n-1] = x[ct_]/Cell.S; // this is not mcf but DT/T } pol_fit(n, delta, alphac, 3, b, sigma); printf("Momentum compaction factor:\n"); - printf(" alpha1 = %10.3e alpha2 = %10.3e alpha3 = %10.3e\n", + printf(" alpha1 = %10.4e alpha2 = %10.4e alpha3 = %10.4e\n", b[1], b[2], b[3]); }