source: sasmodels/sasmodels/models/core_shell_cylinder.c @ 5bddd89

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

use ORIENT macro for remaining symmetric models

  • Property mode set to 100644
File size: 2.9 KB
Line 
1double form_volume(double radius, double thickness, double length);
2double Iq(double q, double core_sld, double shell_sld, double solvent_sld,
3    double radius, double thickness, double length);
4double Iqxy(double qx, double qy, double core_sld, double shell_sld, double solvent_sld,
5    double radius, double thickness, double length, double theta, double phi);
6
7// twovd = 2 * volume * delta_rho
8// besarg = q * R * sin(alpha)
9// siarg = q * L/2 * cos(alpha)
10double _cyl(double twovd, double besarg, double siarg);
11double _cyl(double twovd, double besarg, double siarg)
12{
13    return twovd * sinc(siarg) * sas_J1c(besarg);
14}
15
16double form_volume(double radius, double thickness, double length)
17{
18    return M_PI*(radius+thickness)*(radius+thickness)*(length+2.0*thickness);
19}
20
21double Iq(double q,
22    double core_sld,
23    double shell_sld,
24    double solvent_sld,
25    double radius,
26    double thickness,
27    double length)
28{
29    // precalculate constants
30    const double core_qr = q*radius;
31    const double core_qh = q*0.5*length;
32    const double core_twovd = 2.0 * form_volume(radius,0,length)
33                            * (core_sld-shell_sld);
34    const double shell_qr = q*(radius + thickness);
35    const double shell_qh = q*(0.5*length + thickness);
36    const double shell_twovd = 2.0 * form_volume(radius,thickness,length)
37                             * (shell_sld-solvent_sld);
38    double total = 0.0;
39    // double lower=0, upper=M_PI_2;
40    for (int i=0; i<76 ;i++) {
41        // translate a point in [-1,1] to a point in [lower,upper]
42        //const double alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0;
43        double sn, cn;
44        const double alpha = 0.5*(Gauss76Z[i]*M_PI_2 + M_PI_2);
45        SINCOS(alpha, sn, cn);
46        const double fq = _cyl(core_twovd, core_qr*sn, core_qh*cn)
47            + _cyl(shell_twovd, shell_qr*sn, shell_qh*cn);
48        total += Gauss76Wt[i] * fq * fq * sn;
49    }
50    // translate dx in [-1,1] to dx in [lower,upper]
51    //const double form = (upper-lower)/2.0*total;
52    return 1.0e-4 * total * M_PI_4;
53}
54
55
56double Iqxy(double qx, double qy,
57    double core_sld,
58    double shell_sld,
59    double solvent_sld,
60    double radius,
61    double thickness,
62    double length,
63    double theta,
64    double phi)
65{
66    double q, sin_alpha, cos_alpha;
67    ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha);
68
69    const double core_qr = q*radius;
70    const double core_qh = q*0.5*length;
71    const double core_twovd = 2.0 * form_volume(radius,0,length)
72                            * (core_sld-shell_sld);
73    const double shell_qr = q*(radius + thickness);
74    const double shell_qh = q*(0.5*length + thickness);
75    const double shell_twovd = 2.0 * form_volume(radius,thickness,length)
76                             * (shell_sld-solvent_sld);
77
78    const double fq = _cyl(core_twovd, core_qr*sin_alpha, core_qh*cos_alpha)
79        + _cyl(shell_twovd, shell_qr*sin_alpha, shell_qh*cos_alpha);
80    return 1.0e-4 * fq * fq;
81}
Note: See TracBrowser for help on using the repository browser.