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

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

docu update

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