# source:sasmodels/sasmodels/models/barbell.c@3a48772

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 3a48772 was 3a48772, checked in by Paul Kienzle <pkienzle@…>, 7 years ago

use predefined constants for fractions of pi

• Property mode set to `100644`
File size: 3.9 KB
Line
2double Iq(double q, double sld, double solvent_sld,
4double Iqxy(double qx, double qy, double sld, double solvent_sld,
6        double theta, double phi);
7
9
10//barbell kernel - same as dumbell
11static double
12_bell_kernel(double q, double h, double radius_bell,
13             double half_length, double sin_alpha, double cos_alpha)
14{
15    // translate a point in [-1,1] to a point in [lower,upper]
16    const double upper = 1.0;
17    const double lower = h/radius_bell;
18    const double zm = 0.5*(upper-lower);
19    const double zb = 0.5*(upper+lower);
20
21    // cos term in integral is:
22    //    cos (q (R t - h + L/2) cos(alpha))
23    // so turn it into:
24    //    cos (m t + b)
25    // where:
26    //    m = q R cos(alpha)
27    //    b = q(L/2-h) cos(alpha)
28    const double m = q*radius_bell*cos_alpha; // cos argument slope
29    const double b = q*(half_length-h)*cos_alpha; // cos argument intercept
30    const double qrst = q*radius_bell*sin_alpha; // Q*R*sin(theta)
31    double total = 0.0;
32    for (int i = 0; i < 76; i++){
33        const double t = Gauss76Z[i]*zm + zb;
34        const double radical = 1.0 - t*t;
35        const double bj = sas_J1c(qrst*sqrt(radical));
36        const double Fq = cos(m*t + b) * radical * bj;
37        total += Gauss76Wt[i] * Fq;
38    }
39    // translate dx in [-1,1] to dx in [lower,upper]
40    const double integral = total*zm;
41    const double bell_fq = 2.0*M_PI*cube(radius_bell)*integral;
42    return bell_fq;
43}
44
45static double
46_fq(double q, double h,
48    double sin_alpha, double cos_alpha)
49{
50    const double bell_fq = _bell_kernel(q, h, radius_bell, half_length, sin_alpha, cos_alpha);
51    const double bj = sas_J1c(q*radius*sin_alpha);
52    const double si = sinc(q*half_length*cos_alpha);
54    const double Aq = bell_fq + cyl_fq;
55    return Aq;
56}
57
58
61        double length)
62{
63    // bell radius should never be less than radius when this is called
65    const double p1 = 2.0/3.0*cube(radius_bell);
66    const double p2 = square(radius_bell)*hdist;
67    const double p3 = cube(hdist)/3.0;
68
70}
71
72double Iq(double q, double sld, double solvent_sld,
74{
76    const double half_length = 0.5*length;
77
78    // translate a point in [-1,1] to a point in [0, pi/2]
79    const double zm = M_PI_4;
80    const double zb = M_PI_4;
81    double total = 0.0;
82    for (int i = 0; i < 76; i++){
83        const double alpha= Gauss76Z[i]*zm + zb;
84        double sin_alpha, cos_alpha; // slots to hold sincos function output
85        SINCOS(alpha, sin_alpha, cos_alpha);
86        const double Aq = _fq(q, h, radius_bell, radius, half_length, sin_alpha, cos_alpha);
87        total += Gauss76Wt[i] * Aq * Aq * sin_alpha;
88    }
89    // translate dx in [-1,1] to dx in [lower,upper]
90    const double form = total*zm;
91
92    //Contrast
93    const double s = (sld - solvent_sld);
94    return 1.0e-4 * s * s * form;
95}
96
97
98double Iqxy(double qx, double qy,
99        double sld, double solvent_sld,