source: sasmodels/sasmodels/models/cylinder.c @ 2a0b2b1

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

restructure all 2D models to work with (qa,qb,qc) = rotate(qx,qy) rather than working with angles directly in preparation for revised jitter algorithm

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[03cac08]1#define INVALID(v) (v.radius<0 || v.length<0)
2
[2a0b2b1]3static double
4form_volume(double radius, double length)
[14de349]5{
6    return M_PI*radius*radius*length;
7}
8
[2a0b2b1]9static double
10fq(double qab, double qc, double radius, double length)
[14de349]11{
[2a0b2b1]12    return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length);
[0d6e865]13}
[50e1e40]14
[2a0b2b1]15static double
16orient_avg_1D(double q, double radius, double length)
[0d6e865]17{
[50e1e40]18    // translate a point in [-1,1] to a point in [0, pi/2]
19    const double zm = M_PI_4;
[2a0b2b1]20    const double zb = M_PI_4;
[50e1e40]21
[994d77f]22    double total = 0.0;
[14de349]23    for (int i=0; i<76 ;i++) {
[2a0b2b1]24        const double theta = Gauss76Z[i]*zm + zb;
25        double sin_theta, cos_theta; // slots to hold sincos function output
26        // theta (theta,phi) the projection of the cylinder on the detector plane
27        SINCOS(theta , sin_theta, cos_theta);
28        const double form = fq(q*sin_theta, q*cos_theta, radius, length);
29        total += Gauss76Wt[i] * form * form * sin_theta;
[14de349]30    }
[ff7119b]31    // translate dx in [-1,1] to dx in [lower,upper]
[0d6e865]32    return total*zm;
33}
34
[2a0b2b1]35static double
36Iq(double q,
[0d6e865]37    double sld,
38    double solvent_sld,
39    double radius,
40    double length)
41{
[50e1e40]42    const double s = (sld - solvent_sld) * form_volume(radius, length);
[0d6e865]43    return 1.0e-4 * s * s * orient_avg_1D(q, radius, length);
[14de349]44}
45
[2a0b2b1]46static double
47Iqxy(double qx, double qy,
[994d77f]48    double sld,
49    double solvent_sld,
50    double radius,
51    double length,
52    double theta,
53    double phi)
[14de349]54{
[11ca2ab]55    double q, sin_alpha, cos_alpha;
56    ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha);
[2a0b2b1]57    const double qab = q*sin_alpha;
58    const double qc = q*cos_alpha;
[50e1e40]59    const double s = (sld-solvent_sld) * form_volume(radius, length);
[2a0b2b1]60    const double form = fq(qab, qc, radius, length);
[73e08ae]61    return 1.0e-4 * square(s * form);
[14de349]62}
Note: See TracBrowser for help on using the repository browser.