Changeset 23 in TRACY3 for branches/tracy3-3.10.1b/tracy/tracy/src/naffutils.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/naffutils.cc
r11 r23 18 18 19 19 /****************************************************************************/ 20 /* void Trac_Simple4DCOD(double x, double px, double y, double py, double dp, 21 double ctau, long nmax, double Tx[][NTURN], bool *status2)20 /* void Trac_Simple4DCOD(double x, double px, double y, double py, double dp, long nmax, 21 double Tx[][NTURN], bool *status) 22 22 23 23 Purpose: 24 24 Single particle tracking around the closed orbit for NTURN turns 25 The 6D phase trajectory is saved in a array, but the 26 tracked dp and ctau is not about the COD. 25 The 6D phase trajectory is saved in a array 27 26 28 27 Input: … … 70 69 71 70 72 if ( !trace && status.codflag)71 if (trace && status.codflag) 73 72 printf("dp= % .5e %% xcod= % .5e mm zcod= % .5e mm \n", 74 73 dp*1e2, globval.CODvect[0]*1e3, globval.CODvect[2]*1e3); … … 108 107 } while ((lastn < nmax) && (lastpos == globval.Cell_nLoc) && (lostF == false)); 109 108 110 111 109 if (lastpos != globval.Cell_nLoc) 112 110 { /* Particle lost: Error message section */ … … 118 116 } 119 117 120 121 /****************************************************************************/122 /* void Trac_Simple4DCOD(double x, double px, double y, double py, double dp,123 double ctau, long nmax, double Tx[][NTURN], bool *status2)124 125 Purpose:126 Single particle tracking around the closed orbit for NTURN turns127 The 6D phase trajectory is saved in a array, but the128 tracked dp and ctau is not about the COD.129 130 Input:131 x, px, y, py 4 transverse coordinates132 dp energy offset133 nmax number of turns134 pos starting position for tracking135 aperture global physical aperture136 137 Output:138 lastn last n (should be nmax if not lost)139 lastpos last position in the ring140 Tx 6xNTURN matrix of phase trajectory141 142 Return:143 none144 145 Global variables:146 NTURN number of turn for tracking147 globval148 149 Specific functions:150 Cell_Pass151 152 Comments:153 useful for connection with NAFF154 19/01/03 tracking around the closed orbit155 156 11/06/2013 Modified by Jianfeng Zhang @ LAL157 The same feature as function158 Trac_Simple4DCOD(double x, double px, double y, double py, double dp,159 double ctau, long nmax, double Tx[][NTURN], bool *status2)160 but add the feature to extract the position of the location of161 the lost particle;162 called by function163 fmap(const char *FmapFile, long Nbx, long Nbz, long Nbtour, double xmax, double zmax,164 double energy, bool diffusion, bool loss)165 in soleillib.cc.166 167 ****************************************************************************/168 void Trac_Simple4DCOD(double x, double px, double y, double py, double dp,169 double ctau, long nmax, double Tx[][NTURN], long& lastn, long& lastpos, ss_vect<double>& x1, bool *status2)170 {171 bool lostF = false; /* Lost particle Flag */172 Vector2 aperture = {1.0, 1.0};173 174 lastn = 0;175 lastpos = globval.Cell_nLoc;176 *status2 = true; /* stable */177 x1[0]=0,x1[1]=0,x1[2]=0,x1[3]=0,x1[4]=0,x1[5]=0;178 179 if (globval.MatMeth) Cell_Concat(dp);180 181 /* Get closed orbit */182 183 getcod(dp, lastpos);184 185 186 if (!trace && status.codflag)187 printf("dp= % .5e %% xcod= % .5e mm zcod= % .5e mm \n",188 dp*1e2, globval.CODvect[0]*1e3, globval.CODvect[2]*1e3);189 190 /* Tracking coordinates around the closed orbit */191 x1[0] = x + globval.CODvect[0]; x1[1] = px + globval.CODvect[1];192 x1[2] = y + globval.CODvect[2]; x1[3] = py + globval.CODvect[3];193 x1[4] = dp; x1[5] = ctau;194 195 Tx[0][lastn] = x1[0]; Tx[1][lastn] = x1[1];196 Tx[2][lastn] = x1[2]; Tx[3][lastn] = x1[3];197 Tx[4][lastn] = x1[4]; Tx[5][lastn] = x1[5];198 lastn++;199 200 do201 { /* tracking through the ring */202 if ((lastpos == globval.Cell_nLoc) &&203 (fabs(x1[0]) < aperture[0]) && (fabs(x1[2]) < aperture[1]) && status.codflag)204 {205 if (globval.MatMeth)206 Cell_fPass(x1, lastpos);207 else208 Cell_Pass(0, globval.Cell_nLoc, x1, lastpos);209 Tx[0][lastn] = x1[0]; Tx[1][lastn] = x1[1];210 Tx[2][lastn] = x1[2]; Tx[3][lastn] = x1[3];211 Tx[4][lastn] = x1[4]; Tx[5][lastn] = x1[5];212 }213 else214 {215 printf("Trac_Simple: Particle lost \n");216 fprintf(stdout, "%6ld plane: %1d %+10.5g %+10.5g %+10.5g %+10.5g %+10.5g %+10.5g \n",217 lastn, status.lossplane, x1[0], x1[1], x1[2], x1[3], x1[4], x1[5]);218 lostF = true;219 *status2 = false;220 }221 lastn++;222 } while ((lastn < nmax) && (lastpos == globval.Cell_nLoc) && (lostF == false));223 224 225 if (lastpos != globval.Cell_nLoc)226 { /* Particle lost: Error message section */227 *status2 = false;228 printf("Trac_Simple: Particle lost \n");229 fprintf(stdout, "turn=%5ld plane= %1d %+10.5g %+10.5g %+10.5g %+10.5g %+10.5g %+10.5g \n", lastn-1,230 status.lossplane, x1[0], x1[1], x1[2], x1[3], x1[4], x1[5]);231 }232 }233 234 235 118 /****************************************************************************/ 236 119 /* void Trac_Simple6DCOD(double x, double px, double y, double py, double dp, long nmax, 237 double Tx[][NTURN], bool *status 2)120 double Tx[][NTURN], bool *status) 238 121 239 122 Purpose:
Note: See TracChangeset
for help on using the changeset viewer.