source: sasmodels/sasmodels/models/elliptical_cylinder.c @ 71b751d

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 71b751d was 71b751d, checked in by Paul Kienzle <pkienzle@…>, 2 years ago

update remaining form factors to use Fq interface

  • Property mode set to 100644
File size: 2.8 KB
Line 
1static double
2form_volume(double radius_minor, double r_ratio, double length)
3{
4    return M_PI * radius_minor * radius_minor * r_ratio * length;
5}
6
7static void
8Fq(double q, double *F1, double *F2, double radius_minor, double r_ratio, double length,
9   double sld, double solvent_sld)
10{
11    // orientational average limits
12    const double va = 0.0;
13    const double vb = 1.0;
14    // inner integral limits
15    const double vaj=0.0;
16    const double vbj=M_PI;
17
18    const double radius_major = r_ratio * radius_minor;
19    const double rA = 0.5*(square(radius_major) + square(radius_minor));
20    const double rB = 0.5*(square(radius_major) - square(radius_minor));
21
22    //initialize integral
23    double outer_sum_F1 = 0.0;
24    double outer_sum_F2 = 0.0;
25    for(int i=0;i<GAUSS_N;i++) {
26        //setup inner integral over the ellipsoidal cross-section
27        const double cos_val = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0;
28        const double sin_val = sqrt(1.0 - cos_val*cos_val);
29        //const double arg = radius_minor*sin_val;
30        double inner_sum_F1 = 0.0;
31        double inner_sum_F2 = 0.0;
32        for(int j=0;j<GAUSS_N;j++) {
33            const double theta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0;
34            const double r = sin_val*sqrt(rA - rB*cos(theta));
35            const double be = sas_2J1x_x(q*r);
36            inner_sum_F1 += GAUSS_W[j] * be;
37            inner_sum_F2 += GAUSS_W[j] * be * be;
38        }
39        //now calculate the value of the inner integral
40        inner_sum_F1 *= 0.5*(vbj-vaj);
41        inner_sum_F2 *= 0.5*(vbj-vaj);
42
43        //now calculate outer integral
44        const double si = sas_sinx_x(q*0.5*length*cos_val);
45        outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * si;
46        outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * si * si;
47    }
48    // correct limits and divide integral by pi
49    outer_sum_F1 *= 0.5*(vb-va)/M_PI;
50    outer_sum_F2 *= 0.5*(vb-va)/M_PI;
51
52    // scale by contrast and volume, and convert to to 1/cm units
53    const double volume = form_volume(radius_minor, r_ratio, length);
54    const double contrast = sld - solvent_sld;
55    const double s = contrast*volume;
56    *F1 = 1.0e-2*s*outer_sum_F1;
57    *F2 = 1.0e-4*s*s*outer_sum_F2;
58}
59
60
61static double
62Iqabc(double qa, double qb, double qc,
63     double radius_minor, double r_ratio, double length,
64     double sld, double solvent_sld)
65{
66    // Compute:  r = sqrt((radius_major*cos_nu)^2 + (radius_minor*cos_mu)^2)
67    // Given:    radius_major = r_ratio * radius_minor
68    const double qr = radius_minor*sqrt(square(r_ratio*qb) + square(qa));
69    const double be = sas_2J1x_x(qr);
70    const double si = sas_sinx_x(qc*0.5*length);
71    const double fq = be * si;
72    const double contrast = sld - solvent_sld;
73    const double volume = form_volume(radius_minor, r_ratio, length);
74    return 1.0e-4 * square(contrast * volume * fq);
75}
Note: See TracBrowser for help on using the repository browser.