source: sasmodels/sasmodels/models/ellipsoid.c @ 9c461c7

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 9c461c7 was 9c461c7, checked in by piotr, 8 years ago
  1. Code review from PK: renamed J1c to sph_j1c
  2. Fixed mass_fractal
  • 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 1.333333333333333*M_PI*rpolar*requatorial*requatorial;
20}
21
22double Iq(double q,
23    double sld,
24    double solvent_sld,
25    double rpolar,
26    double requatorial)
27{
28    //const double lower = 0.0;
29    //const double upper = 1.0;
30    double total = 0.0;
31    for (int i=0;i<76;i++) {
32        //const double sin_alpha = (Gauss76Z[i]*(upper-lower) + upper + lower)/2;
33        const double sin_alpha = 0.5*(Gauss76Z[i] + 1.0);
34        total += Gauss76Wt[i] * _ellipsoid_kernel(q, rpolar, requatorial, sin_alpha);
35    }
36    //const double form = (upper-lower)/2*total;
37    const double form = 0.5*total;
38    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);
39    return 1.0e-4 * form * s * s;
40}
41
42double Iqxy(double qx, double qy,
43    double sld,
44    double solvent_sld,
45    double rpolar,
46    double requatorial,
47    double theta,
48    double phi)
49{
50    double sn, cn;
51
52    const double q = sqrt(qx*qx + qy*qy);
53    SINCOS(theta*M_PI_180, sn, cn);
54    // TODO: check if this is actually sin(alpha), not cos(alpha)
55    const double cos_alpha = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);
56    const double form = _ellipsoid_kernel(q, rpolar, requatorial, cos_alpha);
57    const double s = (sld - solvent_sld) * form_volume(rpolar, requatorial);
58
59    return 1.0e-4 * form * s * s;
60}
61
Note: See TracBrowser for help on using the repository browser.