source: sasmodels/sasmodels/models/cylinder.c @ 86aa992

core_shell_microgelsmagnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 86aa992 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: 1.6 KB
Line 
1#define INVALID(v) (v.radius<0 || v.length<0)
2
3static double
4form_volume(double radius, double length)
5{
6    return M_PI*radius*radius*length;
7}
8
9static double
10_fq(double qab, double qc, double radius, double length)
11{
12    return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length);
13}
14
15static void
16Fq(double q,
17    double *F1,
18    double *F2,
19    double sld,
20    double solvent_sld,
21    double radius,
22    double length)
23{
24    // translate a point in [-1,1] to a point in [0, pi/2]
25    const double zm = M_PI_4;
26    const double zb = M_PI_4;
27
28    double total_F1 = 0.0;
29    double total_F2 = 0.0;
30    for (int i=0; i<GAUSS_N ;i++) {
31        const double theta = GAUSS_Z[i]*zm + zb;
32        double sin_theta, cos_theta; // slots to hold sincos function output
33        // theta (theta,phi) the projection of the cylinder on the detector plane
34        SINCOS(theta , sin_theta, cos_theta);
35        const double form = _fq(q*sin_theta, q*cos_theta, radius, length);
36        total_F1 += GAUSS_W[i] * form * sin_theta;
37        total_F2 += GAUSS_W[i] * form * form * sin_theta;
38    }
39    // translate dx in [-1,1] to dx in [lower,upper]
40    total_F1 *= zm;
41    total_F2 *= zm;
42    const double s = (sld - solvent_sld) * form_volume(radius, length);
43    *F1 = 1e-2 * s * total_F1;
44    *F2 = 1e-4 * s * s * total_F2;
45}
46
47
48
49static double
50Iqac(double qab, double qc,
51    double sld,
52    double solvent_sld,
53    double radius,
54    double length)
55{
56    const double form = _fq(qab, qc, radius, length);
57    const double s = (sld-solvent_sld) * form_volume(radius, length);
58    return 1.0e-4 * square(s * form);
59}
60
Note: See TracBrowser for help on using the repository browser.