source: sasmodels/sasmodels/models/cylinder.c @ a7684e5

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

docu updates

  • 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 sld,
12    real solvent_sld,
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 = (sld - solvent_sld) * form_volume(radius, length);
30    return REAL(1.0e-4) * form * s * s;
31}
32
33
34real Iqxy(real qx, real qy,
35    real sld,
36    real solvent_sld,
37    real radius,
38    real length,
39    real theta,
40    real phi)
41{
42    real sn, cn; // slots to hold sincos function output
43
44    // Compute angle alpha between q and the cylinder axis
45    SINCOS(theta*M_PI_180, sn, cn);
46    // # The following correction factor exists in sasview, but it can't be
47    // # right, so we are leaving it out for now.
48    // const real correction = fabs(cn)*M_PI_2;
49    const real q = sqrt(qx*qx+qy*qy);
50    const real cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q);
51    const real alpha = acos(cos_val);
52
53    // The following is CylKernel() / sin(alpha), but we are doing it in place
54    // to avoid sin(alpha)/sin(alpha) for alpha = 0.  It is also a teensy bit
55    // faster since we don't mulitply and divide sin(alpha).
56    SINCOS(alpha, sn, cn);
57    const real besarg = q*radius*sn;
58    const real siarg = REAL(0.5)*q*length*cn;
59    // lim_{x->0} J1(x)/x = 1/2,   lim_{x->0} sin(x)/x = 1
60    const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg);
61    const real si = (siarg == REAL(0.0) ? REAL(1.0) : sin(siarg)/siarg);
62    const real form = REAL(4.0)*bj*bj*si*si;
63
64    // Multiply by contrast^2, normalize by cylinder volume and convert to cm-1
65    // NOTE that for this (Fournet) definition of the integral, one must MULTIPLY by Vcyl
66    // The additional volume factor is for polydisperse volume normalization.
67    const real s = (sld - solvent_sld) * form_volume(radius, length);
68    return REAL(1.0e-4) * form * s * s; // * correction;
69}
Note: See TracBrowser for help on using the repository browser.