Changeset 554 for sans/XOP_Dev


Ignore:
Timestamp:
Sep 10, 2009 3:56:43 PM (13 years ago)
Author:
srkline
Message:

(libTwoPhase):re-definition if DAB parameters so they are not correlated

(libSphere): correct integration ranges/normalization for simple cubic model

(elliptical cylinder): wholesale changes (JaeHie??). not really sure of these, but probably related to the definition of the relative orientation angles.

Location:
sans/XOP_Dev/SANSAnalysis/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sans/XOP_Dev/SANSAnalysis/lib/DANSE/c_extensions/elliptical_cylinder.c

    r231 r554  
    1818double elliptical_cylinder_analytical_1D(EllipticalCylinderParameters *pars, double q) { 
    1919        double dp[6]; 
    20          
     20 
    2121        // Fill paramater array 
    2222        dp[0] = pars->scale; 
     
    2626        dp[4] = pars->contrast; 
    2727        dp[5] = pars->background; 
    28          
     28 
    2929        // Call library function to evaluate model 
    30         return EllipCyl20(dp, q);        
     30        return EllipCyl20(dp, q); 
    3131} 
    3232 
    33 double elliptical_cylinder_kernel(EllipticalCylinderParameters *pars, double q, double alpha, double psi) { 
     33double elliptical_cylinder_kernel(EllipticalCylinderParameters *pars, double q, double alpha, double psi, double nu) { 
    3434        double qr; 
    3535        double qL; 
    3636        double r_major; 
    3737        double kernel; 
    38          
     38 
    3939        r_major = pars->r_ratio * pars->r_minor; 
    4040 
    41         qr = q*sin(alpha)*sqrt( r_major*r_major*sin(psi)*sin(psi) + pars->r_minor*pars->r_minor*cos(psi)*cos(psi) ); 
     41        qr = q*sin(alpha)*sqrt( r_major*r_major*sin(nu)*sin(nu) + pars->r_minor*pars->r_minor*cos(nu)*cos(nu) ); 
    4242        qL = q*pars->length*cos(alpha)/2.0; 
    43          
     43 
    4444        kernel = 2.0*NR_BessJ1(qr)/qr * sin(qL)/qL; 
    4545        return kernel*kernel; 
     
    5656        q = sqrt(qx*qx+qy*qy); 
    5757    return elliptical_cylinder_analytical_2D_scaled(pars, q, qx/q, qy/q); 
    58 }  
     58} 
    5959 
    6060/** 
     
    6262 * @param pars: parameters of the cylinder 
    6363 * @param q: q-value 
    64  * @param phi: angle phi 
     64 * @param theta: angle theta = angle wrt z axis 
     65 * @param phi: angle phi = angle around y axis (starting from the x+-direction as phi = 0) 
    6566 * @return: function value 
    6667 */ 
    6768double elliptical_cylinder_analytical_2D(EllipticalCylinderParameters *pars, double q, double phi) { 
    6869    return elliptical_cylinder_analytical_2D_scaled(pars, q, cos(phi), sin(phi)); 
    69 }  
     70} 
    7071 
    7172/** 
     
    7980double elliptical_cylinder_analytical_2D_scaled(EllipticalCylinderParameters *pars, double q, double q_x, double q_y) { 
    8081        double cyl_x, cyl_y, cyl_z; 
     82        double ell_x, ell_y; 
    8183        double q_z; 
    8284        double alpha, vol, cos_val; 
     85        double nu, cos_nu; 
    8386        double answer; 
    84          
    85     // Cylinder orientation 
     87 
     88    //Cylinder orientation 
    8689    cyl_x = sin(pars->cyl_theta) * cos(pars->cyl_phi); 
    8790    cyl_y = sin(pars->cyl_theta) * sin(pars->cyl_phi); 
    8891    cyl_z = cos(pars->cyl_theta); 
    89       
     92 
    9093    // q vector 
    9194    q_z = 0; 
    92          
     95 
    9396    // Compute the angle btw vector q and the 
    9497    // axis of the cylinder 
    9598    cos_val = cyl_x*q_x + cyl_y*q_y + cyl_z*q_z; 
    96      
     99 
    97100    // The following test should always pass 
    98101    if (fabs(cos_val)>1.0) { 
     
    100103        return 0; 
    101104    } 
    102      
     105 
    103106    // Note: cos(alpha) = 0 and 1 will get an 
    104107    // undefined value from CylKernel 
    105108        alpha = acos( cos_val ); 
    106          
    107         answer = elliptical_cylinder_kernel(pars, q, alpha, pars->cyl_psi); 
    108          
     109 
     110    //ellipse orientation: 
     111        // the elliptical corss section was transformed and projected 
     112        // into the detector plane already through sin(alpha)and furthermore psi remains as same 
     113        // on the detector plane. 
     114        // So, all we need is to calculate the angle (nu) of the minor axis of the ellipse wrt 
     115        // the wave vector q. 
     116        // JaeHie Cho 12JUN09 
     117 
     118        //x- y- component on the detector plane. 
     119    ell_x =  cos(pars->cyl_psi); 
     120    ell_y =  sin(pars->cyl_psi); 
     121 
     122    // calculate the axis of the ellipse wrt q-coord. 
     123    cos_nu = ell_x*q_x + ell_y*q_y; 
     124    nu = acos(cos_nu); 
     125 
     126    // The following test should always pass 
     127    if (fabs(cos_nu)>1.0) { 
     128        printf("cyl_ana_2D: Unexpected error: cos(nu)>1\n"); 
     129        return 0; 
     130    } 
     131 
     132        answer = elliptical_cylinder_kernel(pars, q, alpha, pars->cyl_psi,nu); 
     133 
    109134        // Multiply by contrast^2 
    110135        answer *= pars->contrast*pars->contrast; 
    111          
     136 
    112137        //normalize by cylinder volume 
    113138        //NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl 
    114139    vol = acos(-1.0) * pars->r_minor * pars->r_minor * pars->r_ratio * pars->length; 
    115140        answer *= vol; 
    116          
     141 
    117142        //convert to [cm-1] 
    118143        answer *= 1.0e8; 
    119          
     144 
    120145        //Scale 
    121146        answer *= pars->scale; 
    122          
     147 
    123148        // add in the background 
    124149        answer += pars->background; 
    125          
     150 
    126151        return answer; 
    127152} 
    128      
     153 
  • sans/XOP_Dev/SANSAnalysis/lib/libSphere.c

    r453 r554  
    20382038        Pi = 4.0*atan(1.0); 
    20392039        va = 0.0; 
    2040         vb = 2.0*Pi;            //orintational average, outer integral 
     2040        vb = Pi/2.0;            //orintational average, outer integral 
    20412041        vaj = 0.0; 
    2042         vbj = Pi;               //endpoints of inner integral 
     2042        vbj = Pi/2.0;           //endpoints of inner integral 
    20432043         
    20442044        summ = 0.0;                     //initialize intergral 
     
    21042104         
    21052105        retVal = temp2*SCeval(yy,xx,temp3,temp4,temp5); 
    2106         retVal /= 4*Pi; 
     2106        retVal *= 2.0/Pi; 
    21072107         
    21082108        return(retVal); 
  • sans/XOP_Dev/SANSAnalysis/lib/libTwoPhase.c

    r453 r554  
    116116} 
    117117 
     118// 6 JUL 2009 SRK changed definition of Izero scale factor to be uncorrelated with range 
     119// 
    118120double 
    119121DAB_Model(double dp[], double q) 
     
    127129        incoh = dp[2];  
    128130         
    129         inten = Izero/pow((1.0 + (qval*range)*(qval*range)),2) + incoh; 
     131        inten = (Izero*range*range*range)/pow((1.0 + (qval*range)*(qval*range)),2) + incoh; 
    130132         
    131133        return(inten); 
Note: See TracChangeset for help on using the changeset viewer.