source: sasmodels/sasmodels/models/core_shell_cylinder.c @ d86f0fc

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

lint reduction

  • Property mode set to 100644
File size: 2.2 KB
Line 
1// vd = volume * delta_rho
2// besarg = q * R * sin(theta)
3// siarg = q * L/2 * cos(theta)
4static double _cyl(double vd, double besarg, double siarg)
5{
6    return vd * sas_sinx_x(siarg) * sas_2J1x_x(besarg);
7}
8
9static double
10form_volume(double radius, double thickness, double length)
11{
12    return M_PI*square(radius+thickness)*(length+2.0*thickness);
13}
14
15static double
16Iq(double q,
17    double core_sld,
18    double shell_sld,
19    double solvent_sld,
20    double radius,
21    double thickness,
22    double length)
23{
24    // precalculate constants
25    const double core_r = radius;
26    const double core_h = 0.5*length;
27    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
28    const double shell_r = (radius + thickness);
29    const double shell_h = (0.5*length + thickness);
30    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
31    double total = 0.0;
32    for (int i=0; i<GAUSS_N ;i++) {
33        // translate a point in [-1,1] to a point in [0, pi/2]
34        //const double theta = ( GAUSS_Z[i]*(upper-lower) + upper + lower )/2.0;
35        double sin_theta, cos_theta;
36        const double theta = GAUSS_Z[i]*M_PI_4 + M_PI_4;
37        SINCOS(theta, sin_theta,  cos_theta);
38        const double qab = q*sin_theta;
39        const double qc = q*cos_theta;
40        const double fq = _cyl(core_vd, core_r*qab, core_h*qc)
41            + _cyl(shell_vd, shell_r*qab, shell_h*qc);
42        total += GAUSS_W[i] * fq * fq * sin_theta;
43    }
44    // translate dx in [-1,1] to dx in [lower,upper]
45    //const double form = (upper-lower)/2.0*total;
46    return 1.0e-4 * total * M_PI_4;
47}
48
49
50static double
51Iqac(double qab, double qc,
52    double core_sld,
53    double shell_sld,
54    double solvent_sld,
55    double radius,
56    double thickness,
57    double length)
58{
59    const double core_r = radius;
60    const double core_h = 0.5*length;
61    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
62    const double shell_r = (radius + thickness);
63    const double shell_h = (0.5*length + thickness);
64    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
65
66    const double fq = _cyl(core_vd, core_r*qab, core_h*qc)
67        + _cyl(shell_vd, shell_r*qab, shell_h*qc);
68    return 1.0e-4 * fq * fq;
69}
Note: See TracBrowser for help on using the repository browser.