source: sasmodels/sasmodels/models/cylinder_clone.c @ 32c160a

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 32c160a was 32c160a, checked in by Paul Kienzle <pkienzle@…>, 10 years ago

support ER/VR python kernels; move metadata to python

  • Property mode set to 100644
File size: 2.6 KB
Line 
1real form_volume(real radius, real length);
2real Iq(real q, real sld, real solvent_sld, real radius, real length);
3real Iqxy(real qx, real qy, real sld, real solvent_sld, real radius, real length, real theta, real phi);
4
5real form_volume(real radius, real length)
6{
7    return M_PI*radius*radius*length;
8}
9
10real Iq(real q,
11    real sldCyl,
12    real sldSolv,
13    real radius,
14    real length)
15{
16    const real h = REAL(0.5)*length;
17    real summ = REAL(0.0);
18    for (int i=0; i<76 ;i++) {
19        //const real zi = ( Gauss76Z[i]*(uplim-lolim) + uplim + lolim )/2.0;
20        const real zi = REAL(0.5)*(Gauss76Z[i]*M_PI_2 + M_PI_2);
21        summ += Gauss76Wt[i] * CylKernel(q, radius, h, zi);
22    }
23    //const real form = (uplim-lolim)/2.0*summ;
24    const real form = summ * M_PI_4;
25
26    // Multiply by contrast^2, normalize by cylinder volume and convert to cm-1
27    // NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
28    // The additional volume factor is for polydisperse volume normalization.
29    const real s = (sldCyl - sldSolv) * form_volume(radius, length);
30    return REAL(1.0e8) * form * s * s;
31}
32
33real Iqxy(real qx, real qy,
34    real sldCyl,
35    real sldSolv,
36    real radius,
37    real length,
38    real cyl_theta,
39    real cyl_phi)
40{
41    real sn, cn; // slots to hold sincos function output
42
43    // Compute angle alpha between q and the cylinder axis
44    SINCOS(cyl_theta*M_PI_180, sn, cn);
45    // # The following correction factor exists in sasview, but it can't be
46    // # right, so we are leaving it out for now.
47    // const real correction = fabs(cn)*M_PI_2;
48    const real q = sqrt(qx*qx+qy*qy);
49    const real cos_val = cn*cos(cyl_phi*M_PI_180)*(qx/q) + sn*(qy/q);
50    const real alpha = acos(cos_val);
51
52    // The following is CylKernel() / sin(alpha), but we are doing it in place
53    // to avoid sin(alpha)/sin(alpha) for alpha = 0.  It is also a teensy bit
54    // faster since we don't mulitply and divide sin(alpha).
55    SINCOS(alpha, sn, cn);
56    const real besarg = q*radius*sn;
57    const real siarg = REAL(0.5)*q*length*cn;
58    // lim_{x->0} J1(x)/x = 1/2,   lim_{x->0} sin(x)/x = 1
59    const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg);
60    const real si = (siarg == REAL(0.0) ? REAL(1.0) : sin(siarg)/siarg);
61    const real form = REAL(4.0)*bj*bj*si*si;
62
63    // Multiply by contrast^2, normalize by cylinder volume and convert to cm-1
64    // NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
65    // The additional volume factor is for polydisperse volume normalization.
66    const real s = (sldCyl - sldSolv) * form_volume(radius, length);
67    return REAL(1.0e8) * form * s * s; // * correction;
68}
Note: See TracBrowser for help on using the repository browser.