source: sasmodels/sasmodels/models/core_shell_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@…>, 6 years ago

update remaining form factors to use Fq interface

  • Property mode set to 100644
File size: 2.4 KB
Line 
1// vd = volume * delta_rho
2// besarg = q * R * sin(theta)
3// siarg = q * L/2 * cos(theta)
4static double _cyl(double vd, double besarg, double siarg)
5{
6    return vd * sas_sinx_x(siarg) * sas_2J1x_x(besarg);
7}
8
9static double
10form_volume(double radius, double thickness, double length)
11{
12    return M_PI*square(radius+thickness)*(length+2.0*thickness);
13}
14
15static void
16Fq(double q,
17    double *F1,
18    double *F2,
19    double core_sld,
20    double shell_sld,
21    double solvent_sld,
22    double radius,
23    double thickness,
24    double length)
25{
26    // precalculate constants
27    const double core_r = radius;
28    const double core_h = 0.5*length;
29    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
30    const double shell_r = (radius + thickness);
31    const double shell_h = (0.5*length + thickness);
32    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
33    double total_F1 = 0.0;
34    double total_F2 = 0.0;
35    for (int i=0; i<GAUSS_N ;i++) {
36        // translate a point in [-1,1] to a point in [0, pi/2]
37        //const double theta = ( GAUSS_Z[i]*(upper-lower) + upper + lower )/2.0;
38        double sin_theta, cos_theta;
39        const double theta = GAUSS_Z[i]*M_PI_4 + M_PI_4;
40        SINCOS(theta, sin_theta,  cos_theta);
41        const double qab = q*sin_theta;
42        const double qc = q*cos_theta;
43        const double fq = _cyl(core_vd, core_r*qab, core_h*qc)
44            + _cyl(shell_vd, shell_r*qab, shell_h*qc);
45        total_F1 += GAUSS_W[i] * fq * sin_theta;
46        total_F2 += GAUSS_W[i] * fq * fq * sin_theta;
47    }
48    // translate dx in [-1,1] to dx in [lower,upper]
49    //const double form = (upper-lower)/2.0*total;
50    *F1 = 1.0e-2 * total_F1 * M_PI_4;
51    *F2 = 1.0e-4 * total_F2 * M_PI_4;
52}
53
54static double
55Iqac(double qab, double qc,
56    double core_sld,
57    double shell_sld,
58    double solvent_sld,
59    double radius,
60    double thickness,
61    double length)
62{
63    const double core_r = radius;
64    const double core_h = 0.5*length;
65    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
66    const double shell_r = (radius + thickness);
67    const double shell_h = (0.5*length + thickness);
68    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
69
70    const double fq = _cyl(core_vd, core_r*qab, core_h*qc)
71        + _cyl(shell_vd, shell_r*qab, shell_h*qc);
72    return 1.0e-4 * fq * fq;
73}
Note: See TracBrowser for help on using the repository browser.