Ignore:
Timestamp:
Aug 14, 2018 12:09:34 PM (6 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:
86aa992
Parents:
2f8cbb9
Message:

update remaining form factors to use Fq interface

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/core_shell_bicelle_elliptical_belt_rough.c

    r108e70e r71b751d  
    1111} 
    1212 
    13 static double 
    14 Iq(double q, 
     13static void 
     14Fq(double q, 
     15        double *F1, 
     16        double *F2, 
    1517        double r_minor, 
    1618        double x_core, 
     
    2426        double sigma) 
    2527{ 
    26     double si1,si2,be1,be2; 
    2728     // core_shell_bicelle_elliptical_belt, RKH 5th Oct 2017, core_shell_bicelle_elliptical 
    2829     // tested briefly against limiting cases of cylinder, hollow cylinder & elliptical cylinder models 
     
    3839    const double r2A = 0.5*(square(r_major) + square(r_minor)); 
    3940    const double r2B = 0.5*(square(r_major) - square(r_minor)); 
     41    const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight); 
     42    const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight; 
     43    const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); 
    4044    // dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face, 
    41     const double dr1 = (-rhor - rhoh + rhoc + rhosolv) *M_PI*r_minor*r_major* 
    42           2.0*halfheight; 
    43     const double dr2 = (rhor-rhosolv) *M_PI*(r_minor+thick_rim)*( 
    44          r_major+thick_rim)* 2.0*halfheight; 
    45     const double dr3 = (rhoh-rhosolv) *M_PI*r_minor*r_major* 
    46          2.0*(halfheight+thick_face); 
     45    const double dr1 = vol1*(-rhor - rhoh + rhoc + rhosolv); 
     46    const double dr2 = vol2*(rhor-rhosolv); 
     47    const double dr3 = vol3*(rhoh-rhosolv); 
     48 
    4749    //initialize integral 
    48     double outer_sum = 0.0; 
     50    double outer_total_F1 = 0.0; 
     51    double outer_total_F2 = 0.0; 
    4952    for(int i=0;i<GAUSS_N;i++) { 
    5053        //setup inner integral over the ellipsoidal cross-section 
    5154        // since we generate these lots of times, why not store them somewhere? 
    52         //const double cos_alpha = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; 
    53         const double cos_alpha = ( GAUSS_Z[i] + 1.0 )/2.0; 
    54         const double sin_alpha = sqrt(1.0 - cos_alpha*cos_alpha); 
    55         double inner_sum=0; 
    56         double sinarg1 = q*halfheight*cos_alpha; 
    57         double sinarg2 = q*(halfheight+thick_face)*cos_alpha; 
    58         si1 = sas_sinx_x(sinarg1); 
    59         si2 = sas_sinx_x(sinarg2); 
     55        //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; 
     56        const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0; 
     57        const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); 
     58        const double qab = q*sin_theta; 
     59        const double qc = q*cos_theta; 
     60        const double si1 = sas_sinx_x(halfheight*qc); 
     61        const double si2 = sas_sinx_x((halfheight+thick_face)*qc); 
     62        double inner_total_F1 = 0; 
     63        double inner_total_F2 = 0; 
    6064        for(int j=0;j<GAUSS_N;j++) { 
    6165            //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe) 
     
    6367            const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2; 
    6468            const double rr = sqrt(r2A - r2B*cos(beta)); 
    65             double besarg1 = q*rr*sin_alpha; 
    66             double besarg2 = q*(rr+thick_rim)*sin_alpha; 
    67             be1 = sas_2J1x_x(besarg1); 
    68             be2 = sas_2J1x_x(besarg2); 
    69             inner_sum += GAUSS_W[j] *square(dr1*si1*be1 + 
    70                                               dr2*si1*be2 + 
    71                                               dr3*si2*be1); 
     69            const double be1 = sas_2J1x_x(rr*qab); 
     70            const double be2 = sas_2J1x_x((rr+thick_rim)*qab); 
     71            const double f = dr1*si1*be1 + dr2*si1*be2 + dr3*si2*be1; 
     72 
     73            inner_total_F1 += GAUSS_W[j] * f; 
     74            inner_total_F2 += GAUSS_W[j] * f * f; 
    7275        } 
    7376        //now calculate outer integral 
    74         outer_sum += GAUSS_W[i] * inner_sum; 
     77        outer_total_F1 += GAUSS_W[i] * inner_total_F1; 
     78        outer_total_F2 += GAUSS_W[i] * inner_total_F2; 
    7579    } 
     80    // now complete change of integration variables (1-0)/(1-(-1))= 0.5 
     81    outer_total_F1 *= 0.25; 
     82    outer_total_F2 *= 0.25; 
    7683 
    77     return outer_sum*2.5e-05*exp(-0.5*square(q*sigma)); 
     84    //convert from [1e-12 A-1] to [cm-1] 
     85    *F1 = 1e-2*outer_total_F1*exp(-0.25*square(q*sigma)); 
     86    *F2 = 1e-4*outer_total_F2*exp(-0.5*square(q*sigma)); 
    7887} 
    7988 
     
    111120    const double si1 = sas_sinx_x( halfheight*qc ); 
    112121    const double si2 = sas_sinx_x( (halfheight + thick_face)*qc ); 
    113     const double Aq = square( vol1*dr1*si1*be1 + vol2*dr2*si1*be2 +  vol3*dr3*si2*be1); 
    114     return 1.0e-4 * Aq*exp(-0.5*(square(qa) + square(qb) + square(qc) )*square(sigma)); 
     122    const double fq = vol1*dr1*si1*be1 + vol2*dr2*si1*be2 +  vol3*dr3*si2*be1; 
     123    const double atten = exp(-0.5*(qa*qa + qb*qb + qc*qc)*(sigma*sigma)); 
     124    return 1.0e-4 * fq*fq * atten; 
    115125} 
Note: See TracChangeset for help on using the changeset viewer.