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
RevLine 
[994d77f]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);
[ce27e21]5
[3f832f9]6double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha);
7double _ellipsoid_kernel(double q, double rpolar, double requatorial, double sin_alpha)
[ce27e21]8{
[994d77f]9    double ratio = rpolar/requatorial;
10    const double u = q*requatorial*sqrt(1.0
[3f832f9]11                   + sin_alpha*sin_alpha*(ratio*ratio - 1.0));
[9c461c7]12    const double f = sph_j1c(u);
[513efc5]13
[5d4777d]14    return f*f;
[ce27e21]15}
16
[994d77f]17double form_volume(double rpolar, double requatorial)
[ce27e21]18{
[994d77f]19    return 1.333333333333333*M_PI*rpolar*requatorial*requatorial;
[ce27e21]20}
21
[994d77f]22double Iq(double q,
23    double sld,
24    double solvent_sld,
25    double rpolar,
26    double requatorial)
[ce27e21]27{
[994d77f]28    //const double lower = 0.0;
29    //const double upper = 1.0;
30    double total = 0.0;
[ce27e21]31    for (int i=0;i<76;i++) {
[3f832f9]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);
[ce27e21]35    }
[994d77f]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;
[ce27e21]40}
41
[994d77f]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)
[ce27e21]49{
[994d77f]50    double sn, cn;
[ce27e21]51
[994d77f]52    const double q = sqrt(qx*qx + qy*qy);
[ce27e21]53    SINCOS(theta*M_PI_180, sn, cn);
[3f832f9]54    // TODO: check if this is actually sin(alpha), not cos(alpha)
[994d77f]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);
[ce27e21]58
[994d77f]59    return 1.0e-4 * form * s * s;
[ce27e21]60}
61
Note: See TracBrowser for help on using the repository browser.