Changeset 5d4777d in sasmodels for sasmodels/models/ellipsoid.c


Ignore:
Timestamp:
Sep 2, 2014 1:24:38 AM (10 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
f4cf580
Parents:
ff7119b
Message:

reorganize, check and update models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/ellipsoid.c

    rce27e21 r5d4777d  
    1 /* PARAMETERS 
     1real form_volume(real rpolar, real requatorial); 
     2real Iq(real q, real sld, real solvent_sld, real rpolar, real requatorial); 
     3real Iqxy(real qx, real qy, real sld, real solvent_sld, 
     4    real rpolar, real requatorial, real theta, real phi); 
     5 
     6real _ellipsoid_kernel(real q, real rpolar, real requatorial, real cos_alpha); 
     7real _ellipsoid_kernel(real q, real rpolar, real requatorial, real cos_alpha) 
    28{ 
    3 name: "ellipsoid", 
    4 title: "Ellipsoid with uniform scattering length density", 
    5 include: [ "lib/gauss76.c" ], 
    6 parameters: [ 
    7    // [ "name", "units", default, [lower, upper], "type", "description" ], 
    8    [ "sld", "1e-6/Ang^2", 4, [-Infinity,Infinity], "", 
    9      "Cylinder scattering length density" ], 
    10    [ "solvent_sld", "1e-6/Ang^2", 1, [-Infinity,Infinity], "", 
    11      "Solvent scattering length density" ], 
    12    [ "a", "Ang",  20, [0, Infinity], "volume", 
    13      "Cylinder radius" ], 
    14    [ "b", "Ang",  20, [0, Infinity], "volume", 
    15      "Cylinder length" ], 
    16    [ "theta", "degrees", 60, [-Infinity, Infinity], "orientation", 
    17      "In plane angle" ], 
    18    [ "phi", "degrees", 60, [-Infinity, Infinity], "orientation", 
    19      "Out of plane angle" ], 
    20 ], 
    21 } 
    22 PARAMETERS END 
    23  
    24 DOCUMENTATION 
    25 .. _EllipseModel: 
    26  
    27 DOCUMENTATION END 
    28 */ 
    29  
    30 real form_volume(real a, real b); 
    31 real Iq(real qx, real qy, real sld, real solvent_sld, real a, real b); 
    32 real Iqxy(real qx, real qy, real sld, real solvent_sld, real a, real b, real theta, real phi); 
    33  
    34 real form_volume(real a, real b) 
    35 { 
    36     return REAL(1.333333333333333)*M_PI_2*a*b*b; 
     9    real sn, cn; 
     10    real ratio = rpolar/requatorial; 
     11    const real u = q*requatorial*sqrt(REAL(1.0) 
     12                   + cos_alpha*cos_alpha*(ratio*ratio - REAL(1.0))); 
     13    SINCOS(u, sn, cn); 
     14    const real f = ( u==REAL(0.0) ? REAL(1.0) : REAL(3.0)*(sn-u*cn)/(u*u*u) ); 
     15    return f*f; 
    3716} 
    3817 
    39 real ellipsoid_kernel(double q, double b, double a, double dum) 
     18real form_volume(real rpolar, real requatorial) 
    4019{ 
    41     real sn, cn; 
    42     const real nu = a/b; 
    43     const real arg = q * b * sqrt(REAL(1.0)+(dum*dum*(nu*nu--REAL(1.0)))); 
    44     SINCOS(arg, sn, cn); 
    45     const real f = (arg==REAL(0.0) ? REAL(1.0) : REAL(3.0)*(sn-arg*cn)/(arg*arg*arg); 
    46     return f*f; 
     20    return REAL(1.333333333333333)*M_PI*rpolar*requatorial*requatorial; 
    4721} 
    4822 
     
    5024    real sld, 
    5125    real solvent_sld, 
    52     real a, 
    53     real b) 
     26    real rpolar, 
     27    real requatorial) 
    5428{ 
    55     real summ = REAL(0.0); 
     29    //const real lower = REAL(0.0); 
     30    //const real upper = REAL(1.0); 
     31    real total = REAL(0.0); 
    5632    for (int i=0;i<76;i++) { 
    57         //const real zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0; 
    58         zi = ( Gauss76Z[i] + REAL(1.0))/REAL(2.0); 
    59         summ += Gauss76Wt[i] * ellipsoid_kernel(q, b, a, zi); 
     33        //const real cos_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2; 
     34        const real cos_alpha = REAL(0.5)*(Gauss76Z[i] + REAL(1.0)); 
     35        total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha); 
    6036    } 
    61     //const real form = (uplim-lolim)/2.0*summ; 
    62     const real form = REAL(0.5)*summ 
    63     const real s = (sld - sld_solvent) * form_volume(a, b); 
     37    //const real form = (upper-lower)/2*total; 
     38    const real form = REAL(0.5)*total; 
     39    const real s = (sld - solvent_sld) * form_volume(rpolar, requatorial); 
    6440    return REAL(1.0e-4) * form * s * s; 
    6541} 
     
    6844    real sld, 
    6945    real solvent_sld, 
    70     real a, 
    71     real b, 
     46    real rpolar, 
     47    real requatorial, 
    7248    real theta, 
    7349    real phi) 
     
    7753    const real q = sqrt(qx*qx + qy*qy); 
    7854    SINCOS(theta*M_PI_180, sn, cn); 
    79     const real cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 
    80     const real form = ellipsoid_kernel(q, b, a, cos_val); 
    81     const real s = (sld - solvent_sld) * form_volume(a, b); 
     55    const real cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 
     56    const real form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha); 
     57    const real s = (sld - solvent_sld) * form_volume(rpolar, requatorial); 
    8258 
    8359    return REAL(1.0e-4) * form * s * s; 
Note: See TracChangeset for help on using the changeset viewer.