Changeset 591 for sans/XOP_Dev/MonteCarlo/MonteCarlo.c
 Timestamp:
 Nov 4, 2009 12:52:13 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sans/XOP_Dev/MonteCarlo/MonteCarlo.c
r552 r591 51 51 // double *MC_linear_data; /* pointer to double precision wave data */ 52 52 double *results; /* pointer to double precision wave data */ 53 double re sult; //return value53 double retVal; //return value 54 54 55 55 long imon; … … 86 86 /* check that wave handles are all valid */ 87 87 if (p>inputWaveH == NIL) { 88 SetNaN64(&p>re sult); /* return NaN if wave is not valid */88 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 89 89 return(NON_EXISTENT_WAVE); 90 90 } 91 91 if (p>ran_devH == NIL) { 92 SetNaN64(&p>re sult); /* return NaN if wave is not valid */92 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 93 93 return(NON_EXISTENT_WAVE); 94 94 } 95 95 if (p>ntH == NIL) { 96 SetNaN64(&p>re sult); /* return NaN if wave is not valid */96 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 97 97 return(NON_EXISTENT_WAVE); 98 98 } 99 99 if (p>j1H == NIL) { 100 SetNaN64(&p>re sult); /* return NaN if wave is not valid */100 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 101 101 return(NON_EXISTENT_WAVE); 102 102 } 103 103 if (p>j2H == NIL) { 104 SetNaN64(&p>re sult); /* return NaN if wave is not valid */104 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 105 105 return(NON_EXISTENT_WAVE); 106 106 } 107 107 if (p>nnH == NIL) { 108 SetNaN64(&p>re sult); /* return NaN if wave is not valid */108 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 109 109 return(NON_EXISTENT_WAVE); 110 110 } 111 111 if (p>MC_linear_dataH == NIL) { 112 SetNaN64(&p>re sult); /* return NaN if wave is not valid */112 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 113 113 return(NON_EXISTENT_WAVE); 114 114 } 115 115 if (p>resultsH == NIL) { 116 SetNaN64(&p>re sult); /* return NaN if wave is not valid */116 SetNaN64(&p>retVal); /* return NaN if wave is not valid */ 117 117 return(NON_EXISTENT_WAVE); 118 118 } 119 119 120 p>re sult =0;120 p>retVal = 0.0; 121 121 122 122 // trusting that all inputs are DOUBLE PRECISION WAVES!!! … … 157 157 158 158 dummy = MDGetWaveScaling(p>ran_devH, 0, &delta, &left); //0 is the rows 159 if (re sult= MDGetWaveDimensions(p>ran_devH, &numDimensions, dimensionSizes))160 return re sult;159 if (retVal = MDGetWaveDimensions(p>ran_devH, &numDimensions, dimensionSizes)) 160 return retVal; 161 161 numRows_ran_dev = dimensionSizes[0]; 162 162 … … 173 173 // if (waveType==TEXT_WAVE_TYPE) 174 174 // return NUMERIC_ACCESS_ON_TEXT_WAVE; 175 // if (re sult= MDGetWaveDimensions(wavH, &numDimensions, dimensionSizes))176 // return re sult;175 // if (retVal = MDGetWaveDimensions(wavH, &numDimensions, dimensionSizes)) 176 // return retVal; 177 177 // numRows = dimensionSizes[0]; 178 178 // numColumns = dimensionSizes[1]; 179 179 180 // if (re sult= MDAccessNumericWaveData(wavH, kMDWaveAccessMode0, &dataOffset))181 // return re sult;180 // if (retVal = MDAccessNumericWaveData(wavH, kMDWaveAccessMode0, &dataOffset)) 181 // return retVal; 182 182 183 183 // hState = MoveLockHandle(wavH); // So wave data can't move. Remember to call HSetState when done. … … 204 204 ratio = sig_incoh / sig_total; 205 205 206 theta_max = wavelength*qmax/(2 *pi);206 theta_max = wavelength*qmax/(2.0*pi); 207 207 //C SET ThetaSTEP SIZE. 208 208 dth = theta_max/num_bins; … … 229 229 ////SpinProcess() IS A CALLBACK, and not good for Threading! 230 230 // if ((n1 % 1000 == 0) && gCallSpinProcess && SpinProcess()) { // Spins cursor and allows background processing. 231 // re sult= 1; // User aborted.231 // retVal = 1; // User aborted. 232 232 // break; 233 233 // } … … 294 294 295 295 q0 =left + locate_interp(ran_dev,numRows_ran_dev,ran3(&seed))*delta; 296 theta = q0/2 /pi*wavelength; //SAS approximation. 1% error at theta=30 degrees296 theta = q0/2.0/pi*wavelength; //SAS approximation. 1% error at theta=30 degrees 297 297 298 298 find_theta = 1; //always accept … … 326 326 indices[0] =index; //this sets access to nn[index] 327 327 if (index <= n_index) { 328 if (re sult= MDGetNumericWavePointValue(p>nnH, indices, value))329 return re sult;328 if (retVal = MDGetNumericWavePointValue(p>nnH, indices, value)) 329 return retVal; 330 330 value[0] += 1; // add one to the value 331 if (re sult= MDSetNumericWavePointValue(p>nnH, indices, value))332 return re sult;331 if (retVal = MDSetNumericWavePointValue(p>nnH, indices, value)) 332 return retVal; 333 333 // nn[index] += 1; 334 334 } … … 336 336 if( index != 0) { //neutron was scattered, figure out where it went 337 337 theta_z = acos(vz); // Angle (= 2theta) WITH respect to z axis. 338 testQ = 2 *pi*sin(theta_z)/wavelength;338 testQ = 2.0*pi*sin(theta_z)/wavelength; 339 339 340 340 // pick a random phi angle, and see if it lands on the detector 341 341 // since the scattering is isotropic, I can safely pick a new, random value 342 342 // this would not be true if simulating anisotropic scattering. 343 testPhi = ran3(&seed)*2 *pi;343 testPhi = ran3(&seed)*2.0*pi; 344 344 345 345 // is it on the detector? … … 351 351 indices[0] = xPixel; 352 352 indices[1] = yPixel; 353 if (re sult= MDGetNumericWavePointValue(wavH, indices, value))354 return re sult;353 if (retVal = MDGetNumericWavePointValue(wavH, indices, value)) 354 return retVal; 355 355 value[0] += 1; // Real part 356 if (re sult= MDSetNumericWavePointValue(wavH, indices, value))357 return re sult;356 if (retVal = MDSetNumericWavePointValue(wavH, indices, value)) 357 return retVal; 358 358 //if(index==1) // only the single scattering events 359 359 //dp = dp0 + xPixel + yPixel*numColumns; //offset the pointer to the exact memory location … … 415 415 if(indices[1] < 0) indices[1] = 0; 416 416 417 if (re sult= MDGetNumericWavePointValue(wavH, indices, value))418 return re sult;417 if (retVal = MDGetNumericWavePointValue(wavH, indices, value)) 418 return retVal; 419 419 value[0] += 1; // Real part 420 if (re sult= MDSetNumericWavePointValue(wavH, indices, value))421 return re sult;420 if (retVal = MDSetNumericWavePointValue(wavH, indices, value)) 421 return retVal; 422 422 } 423 423 } … … 430 430 value[0] = (double)n1; 431 431 indices[0] = 0; 432 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))433 return re sult;432 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 433 return retVal; 434 434 value[0] = (double)n2; 435 435 indices[0] = 1; 436 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))437 return re sult;436 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 437 return retVal; 438 438 value[0] = (double)isOn; 439 439 indices[0] = 2; 440 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))441 return re sult;440 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 441 return retVal; 442 442 value[0] = (double)NScatterEvents; 443 443 indices[0] = 3; 444 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))445 return re sult;444 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 445 return retVal; 446 446 value[0] = (double)NSingleCoherent; 447 447 indices[0] = 4; 448 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))449 return re sult;448 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 449 return retVal; 450 450 value[0] = (double)NMultipleCoherent; 451 451 indices[0] = 5; 452 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))453 return re sult;452 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 453 return retVal; 454 454 value[0] = (double)NMultipleScatter; 455 455 indices[0] = 6; 456 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))457 return re sult;456 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 457 return retVal; 458 458 value[0] = (double)NCoherentEvents; 459 459 indices[0] = 7; 460 if (re sult= MDSetNumericWavePointValue(p>resultsH, indices, value))461 return re sult;460 if (retVal = MDSetNumericWavePointValue(p>resultsH, indices, value)) 461 return retVal; 462 462 463 463 … … 480 480 481 481 //convert qx,qy to pixel locations relative to # of pixels x, y from center 482 theta = 2 *asin(qy*lam/4/pi);482 theta = 2.0*asin(qy*lam/4.0/pi); 483 483 dy = sdd*tan(theta); 484 484 *yPixel = round(yCtr + dy/pixSize); 485 485 486 theta = 2 *asin(qx*lam/4/pi);486 theta = 2.0*asin(qx*lam/4.0/pi); 487 487 dx = sdd*tan(theta); 488 488 *xPixel = round(xCtr + dx/pixSize); … … 543 543 double retval; 544 544 545 retval = 1 *log(1aval)/sig_tot;545 retval = 1.0*log(1.0aval)/sig_tot; 546 546 547 547 return(retval);
Note: See TracChangeset
for help on using the changeset viewer.