Changeset 2f5c6d4 in sasmodels


Ignore:
Timestamp:
Jul 26, 2016 12:38:21 AM (8 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:
a3a0c5c
Parents:
a4280bd
Message:

move valid parameter test to macro

Location:
sasmodels/models
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/barbell.c

    r26141cb r2f5c6d4  
    55        double bell_radius, double radius, double length, 
    66        double theta, double phi); 
     7 
     8#define INVALID(v) (v.bell_radius < v.radius) 
    79 
    810//barbell kernel - same as dumbell 
     
    5860          double bell_radius, double radius, double length) 
    5961{ 
    60     // Exclude invalid inputs. 
    61     if (bell_radius < radius) return NAN; 
    6262    const double h = -sqrt(bell_radius*bell_radius - radius*radius); 
    6363    const double half_length = 0.5*length; 
     
    100100    const double alpha = acos(cos_val); // rod angle relative to q 
    101101 
    102     // Exclude invalid inputs. 
    103     if (bell_radius < radius) return NAN; 
    104102    const double h = -sqrt(square(bell_radius) - square(radius)); 
    105103    const double half_length = 0.5*length; 
  • sasmodels/models/capped_cylinder.c

    r26141cb r2f5c6d4  
    44double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    55    double radius, double cap_radius, double length, double theta, double phi); 
     6 
     7#define INVALID(v) (v.cap_radius < v.radius) 
    68 
    79// Integral over a convex lens kernel for t in [h/R,1].  See the docs for 
     
    7981          double radius, double cap_radius, double length) 
    8082{ 
    81     // Exclude invalid inputs. 
    82     if (cap_radius < radius) return NAN; 
    8383    const double h = sqrt(cap_radius*cap_radius - radius*radius); 
    8484    const double half_length = 0.5*length; 
     
    121121    const double alpha = acos(cos_val); // rod angle relative to q 
    122122 
    123     // Exclude invalid inputs. 
    124     if (cap_radius < radius) return NAN; 
    125123    const double h = sqrt(cap_radius*cap_radius - radius*radius); 
    126124    const double half_length = 0.5*length; 
  • sasmodels/models/hollow_cylinder.c

    r43b7eea r2f5c6d4  
    1 static double _hollow_cylinder_kernel(double q, double core_radius, double radius,  
    2         double length, double dum); 
    3 static double hollow_cylinder_analytical_2D_scaled(double q, double q_x, double q_y, double radius, double core_radius, double length, double sld, 
    4         double solvent_sld, double theta, double phi); 
    5 static double hollow_cylinder_scaling(double integrand, double delrho, double volume); 
    6          
    71double form_volume(double radius, double core_radius, double length); 
    82 
     
    126        double solvent_sld, double theta, double phi); 
    137 
     8#define INVALID(v) (v.core_radius >= v.radius || v.radius >= v.length) 
     9 
    1410// From Igor library 
    15 static double _hollow_cylinder_kernel(double q, double core_radius, double radius,  
     11static double hollow_cylinder_scaling(double integrand, double delrho, double volume) 
     12{ 
     13        double answer; 
     14        // Multiply by contrast^2 
     15        answer = integrand*delrho*delrho; 
     16 
     17        //normalize by cylinder volume 
     18        answer *= volume*volume; 
     19 
     20        //convert to [cm-1] 
     21        answer *= 1.0e-4; 
     22 
     23        return answer; 
     24} 
     25 
     26static double _hollow_cylinder_kernel(double q, double core_radius, double radius, 
    1627        double length, double dum) 
    1728{ 
     
    6879        cos_val = cyl_x*q_x + cyl_y*q_y;// + cyl_z*q_z; 
    6980 
    70         // The following test should always pass 
    71         if (fabs(cos_val)>1.0) { 
    72                 //printf("core_shell_cylinder_analytical_2D: Unexpected error: cos(alpha)=%g\n", cos_val); 
    73                 return NAN; 
    74         } 
    75  
    7681        answer = _hollow_cylinder_kernel(q, core_radius, radius, length, cos_val); 
    7782 
     
    7984        answer = hollow_cylinder_scaling(answer, delrho, vol); 
    8085 
    81         return answer; 
    82 } 
    83 static double hollow_cylinder_scaling(double integrand, double delrho, double volume) 
    84 { 
    85         double answer; 
    86         // Multiply by contrast^2 
    87         answer = integrand*delrho*delrho; 
    88  
    89         //normalize by cylinder volume 
    90         answer *= volume*volume; 
    91  
    92         //convert to [cm-1] 
    93         answer *= 1.0e-4; 
    94          
    9586        return answer; 
    9687} 
     
    113104        double summ,answer,delrho;                      //running tally of integration 
    114105        double norm,volume;     //final calculation variables 
    115          
    116         if (core_radius >= radius || radius >= length) { 
    117                 return NAN; 
    118         } 
    119106         
    120107        delrho = solvent_sld - sld; 
  • sasmodels/models/pearl_necklace.c

    r2c74c11 r2f5c6d4  
    88        double string_thickness, double number_of_pearls, double sld,  
    99        double string_sld, double solvent_sld); 
     10 
     11#define INVALID(v) (v.string_thickness >= v.radius || v.number_of_pearls <= 0) 
    1012 
    1113// From Igor library 
     
    126128        double value, tot_vol; 
    127129         
    128         if (string_thickness >= radius || number_of_pearls <= 0) { 
    129                 return NAN; 
    130         } 
    131          
    132130        value = _pearl_necklace_kernel(q, radius, edge_separation, string_thickness, 
    133131                number_of_pearls, sld, string_sld, solvent_sld); 
  • sasmodels/models/triaxial_ellipsoid.c

    r50e1e40 r2f5c6d4  
    44double Iqxy(double qx, double qy, double sld, double solvent_sld, 
    55    double req_minor, double req_major, double rpolar, double theta, double phi, double psi); 
     6 
     7//#define INVALID(v) (v.req_minor > v.req_major || v.req_major > v.rpolar) 
     8 
    69 
    710double form_volume(double req_minor, double req_major, double rpolar) 
     
    1720    double rpolar) 
    1821{ 
    19     // if (req_minor > req_major || req_major > rpolar) return NAN;  // Exclude invalid region 
    20  
    2122    double sn, cn; 
    2223    // translate a point in [-1,1] to a point in [0, 1] 
     
    5758    double psi) 
    5859{ 
    59     // if (req_minor > req_major || req_major > rpolar) return NAN;  // Exclude invalid region 
    60  
    6160    double stheta, ctheta; 
    6261    double sphi, cphi; 
Note: See TracChangeset for help on using the changeset viewer.