Ignore:
Timestamp:
Jan 19, 2016 11:48:55 AM (7 years ago)
Author:
srkline
Message:

adding the function for the basic metropolis algorithm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sans/XOP_Dev/MonteCarlo/MonteCarlo_Main.c

    r834 r974  
    1515#include "MonteCarlo.h" 
    1616#include "DebyeSpheres.h" 
     17#include "Metropolis.h" 
    1718 
    1819 
     
    3334 
    3435 
     36// corrected Feb 2013 to return values in [0,127] rather than detector coordinates (which are passed in) 
     37// -- also corrected the pixel calculation 
    3538int 
    3639FindPixel(double testQ, double testPhi, double lam, double yg_d, double sdd, 
    3740                  double pixSize, double xCtr, double yCtr, long *xPixel, long *yPixel) { 
    3841         
    39         double theta,dy,dx,qx,qy,pi; 
    40         pi = 4.0*atan(1.0);      
     42//      double theta,dy,dx,qx,qy,pi; 
     43        double pi,two_theta,dist,dx,dy; 
     44         
     45        pi = 4.0*atan(1.0); 
     46 
     47/* OLD way 
    4148        //decompose to qx,qy 
    4249        qx = testQ*cos(testPhi); 
     
    5764//      *xPixel = lround(xCtr + dx/pixSize); 
    5865        *xPixel = MC_round(xCtr + dx/pixSize); 
     66 
     67*/ 
     68         
     69        // corrected way Feb 2013 
     70        two_theta = 2.0*asin(testQ*lam/4.0/pi); 
     71        dist = sdd*tan(two_theta);                      //hypot in det plane 
     72         
     73        dx = dist*cos(testPhi); 
     74        dy = dist*sin(testPhi); 
     75        *xPixel = MC_round(dx/pixSize + xCtr); 
     76        *yPixel = MC_round(dy/pixSize + yCtr + yg_d/pixSize);           //shift down due to gravity 
     77         
     78        // to array coordinates rather than detector coordinates 
     79        *xPixel -= 1; 
     80        *yPixel -= 1; 
     81         
    5982         
    6083        //if on detector, return xPix and yPix values, otherwise -1 
     
    387410                        return((long)binSLDDistanceX); 
    388411                        break; 
     412                case 9:                                         //  
     413                        return((long)MetropolisX); 
     414                        break; 
    389415        } 
    390416        return(NIL); 
Note: See TracChangeset for help on using the changeset viewer.