Ignore:
Timestamp:
Aug 20, 2009 1:24:23 PM (15 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
1d67243
Parents:
191b369
Message:

fixed and tested ppmodel 2d and cleaned it up.

Location:
sansmodels/src/sans/models/c_extensions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/parallelepiped.c

    r3c102d4 r8e36cdd  
    2323        dp[0] = pars->scale; 
    2424        dp[1] = pars->short_a; 
    25         dp[2] = pars->long_b; 
    26         dp[3] = pars->longer_c; 
     25        dp[2] = pars->short_b; 
     26        dp[3] = pars->long_c; 
    2727        dp[4] = pars->contrast; 
    2828        dp[5] = pars->background; 
     
    9898 */ 
    9999double parallelepiped_analytical_2D_scaled(ParallelepipedParameters *pars, double q, double q_x, double q_y) { 
    100         double parallel_x, parallel_y, parallel_z; 
     100        double cparallel_x, cparallel_y, cparallel_z, bparallel_x, bparallel_y, parallel_x, parallel_y, parallel_z; 
    101101        double q_z; 
    102102        double alpha, vol, cos_val_c, cos_val_b, cos_val_a, edgeA, edgeB, edgeC; 
     
    106106 
    107107        edgeA = pars->short_a; 
    108         edgeB = pars->long_b; 
    109         edgeC = pars->longer_c; 
     108        edgeB = pars->short_b; 
     109        edgeC = pars->long_c; 
    110110 
    111111 
    112112    // parallelepiped c axis orientation 
    113     parallel_x = sin(pars->parallel_theta) * cos(pars->parallel_phi); 
    114     parallel_y = sin(pars->parallel_theta) * sin(pars->parallel_phi); 
    115     parallel_z = cos(pars->parallel_theta); 
     113    cparallel_x = sin(pars->parallel_theta) * cos(pars->parallel_phi); 
     114    cparallel_y = sin(pars->parallel_theta) * sin(pars->parallel_phi); 
     115    cparallel_z = cos(pars->parallel_theta); 
    116116 
    117117    // q vector 
     
    120120    // Compute the angle btw vector q and the 
    121121    // axis of the parallelepiped 
    122     cos_val_c = parallel_x*q_x + parallel_y*q_y + parallel_z*q_z; 
     122    cos_val_c = cparallel_x*q_x + cparallel_y*q_y + cparallel_z*q_z; 
    123123    alpha = acos(cos_val_c); 
    124124 
    125125    // parallelepiped a axis orientation 
    126     parallel_x = -(1-sin(pars->parallel_theta)*sin(pars->parallel_phi))*sin(pars->parallel_psi);//cos(pars->parallel_theta) * sin(pars->parallel_phi)*sin(pars->parallel_psi); 
    127     parallel_y = (1-sin(pars->parallel_theta)*sin(pars->parallel_phi))*cos(pars->parallel_psi);//cos(pars->parallel_theta) * cos(pars->parallel_phi)*cos(pars->parallel_psi); 
     126    parallel_x = sin(pars->parallel_psi);//cos(pars->parallel_theta) * sin(pars->parallel_phi)*sin(pars->parallel_psi); 
     127    parallel_y = cos(pars->parallel_psi);//cos(pars->parallel_theta) * cos(pars->parallel_phi)*cos(pars->parallel_psi); 
    128128 
    129     //parallel_x = -(1-sin(pars->parallel_theta)*sin(pars->parallel_phi))*sin(pars->parallel_psi);//cos(pars->parallel_theta) * sin(pars->parallel_phi)*sin(pars->parallel_psi); 
    130     //parallel_y = (1-sin(pars->parallel_theta)*sin(pars->parallel_phi))*cos(pars->parallel_psi);//cos(pars->parallel_theta) * cos(pars->parallel_phi)*cos(pars->parallel_psi); 
    131     cos_val_a = (parallel_x*q_x + parallel_y*q_y); 
     129    cos_val_a = parallel_x*q_x + parallel_y*q_y; 
    132130 
    133131 
    134132 
    135133    // parallelepiped b axis orientation 
    136     parallel_x = (1-sin(pars->parallel_theta)*cos(pars->parallel_phi))*cos(pars->parallel_psi);//cos(pars->parallel_theta) * cos(pars->parallel_phi)* cos(pars->parallel_psi); 
    137     parallel_y = (1-sin(pars->parallel_theta)*cos(pars->parallel_phi))*sin(pars->parallel_psi);//cos(pars->parallel_theta) * sin(pars->parallel_phi)* sin(pars->parallel_psi); 
     134    bparallel_x = sqrt(1-sin(pars->parallel_theta)*cos(pars->parallel_phi))*cos(pars->parallel_psi);//cos(pars->parallel_theta) * cos(pars->parallel_phi)* cos(pars->parallel_psi); 
     135    bparallel_y = sqrt(1-sin(pars->parallel_theta)*cos(pars->parallel_phi))*sin(pars->parallel_psi);//cos(pars->parallel_theta) * sin(pars->parallel_phi)* sin(pars->parallel_psi); 
    138136    // axis of the parallelepiped 
    139     cos_val_b = (parallel_x*q_x + parallel_y*q_y) ; 
     137    cos_val_b = sin(acos(cos_val_a)) ; 
    140138 
    141139 
     
    148146 
    149147        // Call the IGOR library function to get the kernel 
    150         answer = pkernel( q*edgeA, q*edgeB, q*edgeC, cos_val_a,cos_val_b,cos_val_c); 
     148        answer = pkernel( q*edgeA, q*edgeB, q*edgeC, sin(alpha)*cos_val_a,sin(alpha)*cos_val_b,cos_val_c); 
    151149 
    152150        // Multiply by contrast^2 
  • sansmodels/src/sans/models/c_extensions/parallelepiped.h

    r2cb89e7 r8e36cdd  
    77/** Structure definition for Parallelepiped parameters 
    88 * [PYTHONCLASS] = ParallelepipedModel 
    9  * [DISP_PARAMS] = short_a, long_b, longer_c,parallel_phi,parallel_psi, parallel_theta 
     9 * [DISP_PARAMS] = short_a, short_b, long_c,parallel_phi,parallel_psi, parallel_theta 
    1010   [DESCRIPTION] = <text> Form factor for a rectangular solid with uniform scattering length density. 
    1111 
    1212                scale:Scale factor 
    13                 short_a: length of short side of the parallelepiped [A] 
    14                 long_b: length of long side of the parallelepiped [A] 
    15                 longer_c: length of longer side of the parallelepiped [A] 
     13                short_a: length of short edge [A] 
     14                short_b: length of another short edge [A] 
     15                long_c: length of long edge of the parallelepiped [A] 
    1616                contrast: particle_sld - solvent_sld 
    1717                background:Incoherent Background [1/cm] 
    1818                </text> 
    19         [FIXED]= <text>short_a.width; long_b.width; longer_c.width;parallel_phi.width;parallel_psi.width; parallel_theta.width</text> 
     19        [FIXED]= <text>short_a.width; short_b.width; long_c.width;parallel_phi.width;parallel_psi.width; parallel_theta.width</text> 
    2020        [ORIENTATION_PARAMS]= <text>parallel_phi;parallel_psi; parallel_theta; parallel_phi.width;parallel_psi.width; parallel_theta.width</text> 
    2121 
     
    2626    //  [DEFAULT]=scale=1.0 
    2727    double scale; 
    28     ///  Length of short side of the parallelepiped [A] 
     28    ///  Length of short edge of the parallelepiped [A] 
    2929    //  [DEFAULT]=short_a=35 [A] 
    3030    double short_a; 
    31         /// Length of long side edge of the parallelepiped [A] 
    32     //  [DEFAULT]=long_b=75 [A] 
    33     double long_b; 
    34         /// Length of longer side of the parallelepiped [A] 
    35     //  [DEFAULT]=longer_c=400 [A] 
    36     double longer_c; 
     31        /// Length of short edge edge of the parallelepiped [A] 
     32    //  [DEFAULT]=short_b=75 [A] 
     33    double short_b; 
     34        /// Length of long edge of the parallelepiped [A] 
     35    //  [DEFAULT]=long_c=400 [A] 
     36    double long_c; 
    3737    /// Contrast [1/A²] 
    3838    //  [DEFAULT]=contrast=5.3e-6 [1/A²] 
Note: See TracChangeset for help on using the changeset viewer.