1 | double form_volume(double radius, double length); |
---|
2 | double Iq(double q, double sld, double solvent_sld, double radius, double length); |
---|
3 | double Iqxy(double qx, double qy, double sld, double solvent_sld, |
---|
4 | double radius, double length, double theta, double phi); |
---|
5 | |
---|
6 | // twovd = 2 * volume * delta_rho |
---|
7 | // besarg = q * R * sin(alpha) |
---|
8 | // siarg = q * L/2 * cos(alpha) |
---|
9 | double _cyl(double besarg, double siarg); |
---|
10 | double _cyl(double besarg, double siarg) |
---|
11 | { |
---|
12 | const double bj = (besarg == 0.0 ? 0.5 : J1(besarg)/besarg); |
---|
13 | const double si = (siarg == 0.0 ? 1.0 : sin(siarg)/siarg); |
---|
14 | return si*bj; |
---|
15 | } |
---|
16 | |
---|
17 | double form_volume(double radius, double length) |
---|
18 | { |
---|
19 | return M_PI*radius*radius*length; |
---|
20 | } |
---|
21 | |
---|
22 | double Iq(double q, |
---|
23 | double sld, |
---|
24 | double solvent_sld, |
---|
25 | double radius, |
---|
26 | double length) |
---|
27 | { |
---|
28 | const double qr = q*radius; |
---|
29 | const double qh = q*0.5*length; |
---|
30 | double total = 0.0; |
---|
31 | // double lower=0, upper=M_PI_2; |
---|
32 | for (int i=0; i<76 ;i++) { |
---|
33 | // translate a point in [-1,1] to a point in [lower,upper] |
---|
34 | //const double alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0; |
---|
35 | const double alpha = M_PI_4*(Gauss76Z[i] + 1.0); |
---|
36 | double sn, cn; |
---|
37 | SINCOS(alpha, sn, cn); |
---|
38 | // For a bit of efficiency, we are moving the 2 V delta rho constant |
---|
39 | // factor, 2Vdrho, out of the loop, so this is fq/2Vdrho rather than fq. |
---|
40 | const double fq = _cyl(qr*sn, qh*cn); |
---|
41 | total += Gauss76Wt[i] * fq * fq * sn; |
---|
42 | } |
---|
43 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
44 | //const double form = (upper-lower)/2.0*total; |
---|
45 | const double twoVdrho = 2.0*(sld-solvent_sld)*form_volume(radius, length); |
---|
46 | return 1.0e-4 * twoVdrho * twoVdrho * total * M_PI_4; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | double Iqxy(double qx, double qy, |
---|
51 | double sld, |
---|
52 | double solvent_sld, |
---|
53 | double radius, |
---|
54 | double length, |
---|
55 | double theta, |
---|
56 | double phi) |
---|
57 | { |
---|
58 | // TODO: check that radius<0 and length<0 give zero scattering. |
---|
59 | // This should be the case since the polydispersity weight vector should |
---|
60 | // be zero length, and this function never called. |
---|
61 | double sn, cn; // slots to hold sincos function output |
---|
62 | |
---|
63 | // Compute angle alpha between q and the cylinder axis |
---|
64 | SINCOS(theta*M_PI_180, sn, cn); |
---|
65 | const double q = sqrt(qx*qx+qy*qy); |
---|
66 | const double cos_val = (q==0. ? 1.0 : (cn*cos(phi*M_PI_180)*qx + sn*qy)/q); |
---|
67 | const double alpha = acos(cos_val); |
---|
68 | SINCOS(alpha, sn, cn); |
---|
69 | //sn = sqrt(1.0 - cos_val*cos_val); |
---|
70 | //sn = 1.0 - 0.5*cos_val*cos_val; // if cos_val is very small |
---|
71 | //cn = cos_val; |
---|
72 | |
---|
73 | const double twovd = 2.0*(sld-solvent_sld)*form_volume(radius, length); |
---|
74 | const double fq = twovd * _cyl(q*radius*sn, q*0.5*length*cn); |
---|
75 | return 1.0e-4 * fq * fq; |
---|
76 | } |
---|