source: sasmodels/sasmodels/models/core_shell_cylinder.c @ 1e7b0db0

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 1e7b0db0 was 1e7b0db0, checked in by wojciech, 8 years ago

sinc tranfered to sas_sinx_x

  • Property mode set to 100644
File size: 2.7 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// vd = volume * delta_rho
8// besarg = q * R * sin(alpha)
9// siarg = q * L/2 * cos(alpha)
10double _cyl(double vd, double besarg, double siarg);
11double _cyl(double vd, double besarg, double siarg)
12{
13    return vd * sas_sinx_x(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_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
33    const double shell_qr = q*(radius + thickness);
34    const double shell_qh = q*(0.5*length + thickness);
35    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
36    double total = 0.0;
37    // double lower=0, upper=M_PI_2;
38    for (int i=0; i<76 ;i++) {
39        // translate a point in [-1,1] to a point in [lower,upper]
40        //const double alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0;
41        double sn, cn;
42        const double alpha = 0.5*(Gauss76Z[i]*M_PI_2 + M_PI_2);
43        SINCOS(alpha, sn, cn);
44        const double fq = _cyl(core_vd, core_qr*sn, core_qh*cn)
45            + _cyl(shell_vd, shell_qr*sn, shell_qh*cn);
46        total += Gauss76Wt[i] * fq * fq * sn;
47    }
48    // translate dx in [-1,1] to dx in [lower,upper]
49    //const double form = (upper-lower)/2.0*total;
50    return 1.0e-4 * total * M_PI_4;
51}
52
53
54double Iqxy(double qx, double qy,
55    double core_sld,
56    double shell_sld,
57    double solvent_sld,
58    double radius,
59    double thickness,
60    double length,
61    double theta,
62    double phi)
63{
64    double q, sin_alpha, cos_alpha;
65    ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha);
66
67    const double core_qr = q*radius;
68    const double core_qh = q*0.5*length;
69    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
70    const double shell_qr = q*(radius + thickness);
71    const double shell_qh = q*(0.5*length + thickness);
72    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
73
74    const double fq = _cyl(core_vd, core_qr*sin_alpha, core_qh*cos_alpha)
75        + _cyl(shell_vd, shell_qr*sin_alpha, shell_qh*cos_alpha);
76    return 1.0e-4 * fq * fq;
77}
Note: See TracBrowser for help on using the repository browser.