source: sasmodels/sasmodels/models/core_shell_cylinder.c @ 592343f

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 592343f was 592343f, checked in by wojciech, 7 years ago

sas_J1c translated to sas_2J1x_x

  • Property mode set to 100644
File size: 2.7 KB
RevLine 
[994d77f]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);
[5d4777d]6
[9aa4881]7// vd = volume * delta_rho
[5d4777d]8// besarg = q * R * sin(alpha)
9// siarg = q * L/2 * cos(alpha)
[9aa4881]10double _cyl(double vd, double besarg, double siarg);
11double _cyl(double vd, double besarg, double siarg)
[5d4777d]12{
[592343f]13    return vd * sas_sinx_x(siarg) * sas_2J1x_x(besarg);
[5d4777d]14}
15
[994d77f]16double form_volume(double radius, double thickness, double length)
[5d4777d]17{
[5bddd89]18    return M_PI*(radius+thickness)*(radius+thickness)*(length+2.0*thickness);
[5d4777d]19}
20
[994d77f]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)
[5d4777d]28{
29    // precalculate constants
[994d77f]30    const double core_qr = q*radius;
31    const double core_qh = q*0.5*length;
[9aa4881]32    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
[994d77f]33    const double shell_qr = q*(radius + thickness);
34    const double shell_qh = q*(0.5*length + thickness);
[9aa4881]35    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
[994d77f]36    double total = 0.0;
37    // double lower=0, upper=M_PI_2;
[5d4777d]38    for (int i=0; i<76 ;i++) {
39        // translate a point in [-1,1] to a point in [lower,upper]
[994d77f]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);
[5d4777d]43        SINCOS(alpha, sn, cn);
[9aa4881]44        const double fq = _cyl(core_vd, core_qr*sn, core_qh*cn)
45            + _cyl(shell_vd, shell_qr*sn, shell_qh*cn);
[5d4777d]46        total += Gauss76Wt[i] * fq * fq * sn;
47    }
48    // translate dx in [-1,1] to dx in [lower,upper]
[994d77f]49    //const double form = (upper-lower)/2.0*total;
50    return 1.0e-4 * total * M_PI_4;
[5d4777d]51}
52
53
[994d77f]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)
[5d4777d]63{
[5bddd89]64    double q, sin_alpha, cos_alpha;
65    ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sin_alpha, cos_alpha);
[5d4777d]66
[994d77f]67    const double core_qr = q*radius;
68    const double core_qh = q*0.5*length;
[9aa4881]69    const double core_vd = form_volume(radius,0,length) * (core_sld-shell_sld);
[994d77f]70    const double shell_qr = q*(radius + thickness);
71    const double shell_qh = q*(0.5*length + thickness);
[9aa4881]72    const double shell_vd = form_volume(radius,thickness,length) * (shell_sld-solvent_sld);
[5d4777d]73
[9aa4881]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);
[994d77f]76    return 1.0e-4 * fq * fq;
[5d4777d]77}
Note: See TracBrowser for help on using the repository browser.