Ignore:
Timestamp:
Nov 9, 2018 3:25:10 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
7126c04
Parents:
599993b9 (diff), cf3d0ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'beta_approx' into ticket-1015-gpu-mem-error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/hollow_rectangular_prism_thin_walls.c

    rd86f0fc r99658f6  
     1static double 
     2shell_volume(double length_a, double b2a_ratio, double c2a_ratio) 
     3{ 
     4    const double length_b = length_a * b2a_ratio; 
     5    const double length_c = length_a * c2a_ratio; 
     6    const double shell_volume = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c); 
     7    return shell_volume; 
     8} 
     9 
    110static double 
    211form_volume(double length_a, double b2a_ratio, double c2a_ratio) 
    312{ 
    4     double length_b = length_a * b2a_ratio; 
    5     double length_c = length_a * c2a_ratio; 
    6     double vol_shell = 2.0 * (length_a*length_b + length_a*length_c + length_b*length_c); 
    7     return vol_shell; 
     13    const double length_b = length_a * b2a_ratio; 
     14    const double length_c = length_a * c2a_ratio; 
     15    const double form_volume = length_a * length_b * length_c; 
     16    return form_volume; 
    817} 
    918 
    1019static double 
    11 Iq(double q, 
     20radius_from_excluded_volume(double length_a, double b2a_ratio, double c2a_ratio) 
     21{ 
     22    const double r_equiv = sqrt(length_a*length_a*b2a_ratio/M_PI); 
     23    const double length_c = length_a*c2a_ratio; 
     24    return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_c + (r_equiv + length_c)*(M_PI*r_equiv + length_c))); 
     25} 
     26 
     27static double 
     28effective_radius(int mode, double length_a, double b2a_ratio, double c2a_ratio) 
     29{ 
     30    switch (mode) { 
     31    default: 
     32    case 1: // equivalent cylinder excluded volume 
     33        return radius_from_excluded_volume(length_a, b2a_ratio, c2a_ratio); 
     34    case 2: // equivalent outer volume sphere 
     35        return cbrt(cube(length_a)*b2a_ratio*c2a_ratio/M_4PI_3); 
     36    case 3: // half length_a 
     37        return 0.5 * length_a; 
     38    case 4: // half length_b 
     39        return 0.5 * length_a*b2a_ratio; 
     40    case 5: // half length_c 
     41        return 0.5 * length_a*c2a_ratio; 
     42    case 6: // equivalent outer circular cross-section 
     43        return length_a*sqrt(b2a_ratio/M_PI); 
     44    case 7: // half ab diagonal 
     45        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio))); 
     46    case 8: // half diagonal 
     47        return 0.5*sqrt(square(length_a) * (1.0 + square(b2a_ratio) + square(c2a_ratio))); 
     48    } 
     49} 
     50 
     51static void 
     52Fq(double q, 
     53    double *F1, 
     54    double *F2, 
    1255    double sld, 
    1356    double solvent_sld, 
     
    2871    const double v2b = M_PI_2;  //phi integration limits 
    2972 
    30     double outer_sum = 0.0; 
     73    double outer_sum_F1 = 0.0; 
     74    double outer_sum_F2 = 0.0; 
    3175    for(int i=0; i<GAUSS_N; i++) { 
    3276        const double theta = 0.5 * ( GAUSS_Z[i]*(v1b-v1a) + v1a + v1b ); 
     
    4185        const double termAT_theta = 8.0 * sin_c / (q*q*sin_theta*cos_theta); 
    4286 
    43         double inner_sum = 0.0; 
     87        double inner_sum_F1 = 0.0; 
     88        double inner_sum_F2 = 0.0; 
    4489        for(int j=0; j<GAUSS_N; j++) { 
    4590            const double phi = 0.5 * ( GAUSS_Z[j]*(v2b-v2a) + v2a + v2b ); 
     
    60105                * ( cos_a*sin_b/cos_phi + cos_b*sin_a/sin_phi ); 
    61106 
    62             inner_sum += GAUSS_W[j] * square(AL+AT); 
     107            inner_sum_F1 += GAUSS_W[j] * (AL+AT); 
     108            inner_sum_F2 += GAUSS_W[j] * square(AL+AT); 
    63109        } 
    64110 
    65         inner_sum *= 0.5 * (v2b-v2a); 
    66         outer_sum += GAUSS_W[i] * inner_sum * sin_theta; 
     111        inner_sum_F1 *= 0.5 * (v2b-v2a); 
     112        inner_sum_F2 *= 0.5 * (v2b-v2a); 
     113        outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * sin_theta; 
     114        outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * sin_theta; 
    67115    } 
    68116 
    69     outer_sum *= 0.5*(v1b-v1a); 
     117    outer_sum_F1 *= 0.5*(v1b-v1a); 
     118    outer_sum_F2 *= 0.5*(v1b-v1a); 
    70119 
    71120    // Normalize as in Eqn. (15) without the volume factor (as cancels with (V*DelRho)^2 normalization) 
    72121    // The factor 2 is due to the different theta integration limit (pi/2 instead of pi) 
    73     double answer = outer_sum/M_PI_2; 
     122    const double form_avg = outer_sum_F1/M_PI_2; 
     123    const double form_squared_avg = outer_sum_F2/M_PI_2; 
    74124 
    75125    // Multiply by contrast^2. Factor corresponding to volume^2 cancels with previous normalization. 
    76     answer *= square(sld-solvent_sld); 
     126    const double contrast = sld - solvent_sld; 
    77127 
    78128    // Convert from [1e-12 A-1] to [cm-1] 
    79     answer *= 1.0e-4; 
    80  
    81     return answer; 
     129    *F1 = 1e-2 * contrast * form_avg; 
     130    *F2 = 1e-4 * contrast * contrast * form_squared_avg; 
    82131} 
Note: See TracChangeset for help on using the changeset viewer.