source: sasmodels/sasmodels/models/ellipsoid.c @ 50e1e40

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 50e1e40 was 50e1e40, checked in by Paul Kienzle <pkienzle@…>, 8 years ago

use lib functions to simplify barbell, capped_cylinder, cylinder, ellipsoid, triaxial_ellipsoid; fix barbell calculation

  • Property mode set to 100644
File size: 2.0 KB
Line 
1double form_volume(double rpolar, double requatorial);
2double Iq(double q, double sld, double solvent_sld, double rpolar, double requatorial);
3double Iqxy(double qx, double qy, double sld, double solvent_sld,
4    double rpolar, double requatorial, double theta, double phi);
5
6double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha);
7double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha)
8{
9    double ratio = rpolar/requatorial;
10    const double u = q*requatorial*sqrt(1.0
11                   + sin_alpha*sin_alpha*(ratio*ratio - 1.0));
12    const double f = sph_j1c(u);
13
14    return f*f;
15}
16
17double form_volume(double rpolar, double requatorial)
18{
19    return M_4PI_3*rpolar*requatorial*requatorial;
20}
21
22double Iq(double q,
23    double sld,
24    double solvent_sld,
25    double rpolar,
26    double requatorial)
27{
28    // translate a point in [-1,1] to a point in [0, 1]
29    const double zm = 0.5;
30    const double zb = 0.5;
31    double total = 0.0;
32    for (int i=0;i<76;i++) {
33        //const double sin_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2;
34        const double sin_alpha = Gauss76Z[i]*zm + zb;
35        total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, sin_alpha);
36    }
37    // translate dx in [-1,1] to dx in [lower,upper]
38    const double form = total*zm;
39    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);
40    return 1.0e-4 * s * s * form;
41}
42
43double Iqxy(double qx, double qy,
44    double sld,
45    double solvent_sld,
46    double rpolar,
47    double requatorial,
48    double theta,
49    double phi)
50{
51    double sn, cn;
52
53    const double q = sqrt(qx*qx + qy*qy);
54    SINCOS(theta*M_PI_180, sn, cn);
55    // TODO: check if this is actually sin(alpha), not cos(alpha)
56    const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);
57    const double form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha);
58    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);
59
60    return 1.0e-4 * form * s * s;
61}
62
Note: See TracBrowser for help on using the repository browser.