1 | real form_volume(real radius, real thickness, real length); |
---|
2 | real Iq(real q, real core_sld, real shell_sld, real solvent_sld, |
---|
3 | real radius, real thickness, real length); |
---|
4 | real Iqxy(real qx, real qy, real core_sld, real shell_sld, real solvent_sld, |
---|
5 | real radius, real thickness, real length, real theta, real phi); |
---|
6 | |
---|
7 | // twovd = 2 * volume * delta_rho |
---|
8 | // besarg = q * R * sin(alpha) |
---|
9 | // siarg = q * L/2 * cos(alpha) |
---|
10 | real _cyl(real twovd, real besarg, real siarg); |
---|
11 | real _cyl(real twovd, real besarg, real siarg) |
---|
12 | { |
---|
13 | const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg); |
---|
14 | const real si = (siarg == REAL(0.0) ? REAL(1.0) : sin(siarg)/siarg); |
---|
15 | return twovd*si*bj; |
---|
16 | } |
---|
17 | |
---|
18 | real form_volume(real radius, real thickness, real length) |
---|
19 | { |
---|
20 | return M_PI*(radius+thickness)*(radius+thickness)*(length+2*thickness); |
---|
21 | } |
---|
22 | |
---|
23 | real Iq(real q, |
---|
24 | real core_sld, |
---|
25 | real shell_sld, |
---|
26 | real solvent_sld, |
---|
27 | real radius, |
---|
28 | real thickness, |
---|
29 | real length) |
---|
30 | { |
---|
31 | // precalculate constants |
---|
32 | const real core_qr = q*radius; |
---|
33 | const real core_qh = q*REAL(0.5)*length; |
---|
34 | const real core_twovd = REAL(2.0) * form_volume(radius,0,length) |
---|
35 | * (core_sld-shell_sld); |
---|
36 | const real shell_qr = q*(radius + thickness); |
---|
37 | const real shell_qh = q*(REAL(0.5)*length + thickness); |
---|
38 | const real shell_twovd = REAL(2.0) * form_volume(radius,thickness,length) |
---|
39 | * (shell_sld-solvent_sld); |
---|
40 | real total = REAL(0.0); |
---|
41 | // real lower=0, upper=M_PI_2; |
---|
42 | for (int i=0; i<76 ;i++) { |
---|
43 | // translate a point in [-1,1] to a point in [lower,upper] |
---|
44 | //const real alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0; |
---|
45 | real sn, cn; |
---|
46 | const real alpha = REAL(0.5)*(Gauss76Z[i]*M_PI_2 + M_PI_2); |
---|
47 | SINCOS(alpha, sn, cn); |
---|
48 | const real fq = _cyl(core_twovd, core_qr*sn, core_qh*cn) |
---|
49 | + _cyl(shell_twovd, shell_qr*sn, shell_qh*cn); |
---|
50 | total += Gauss76Wt[i] * fq * fq * sn; |
---|
51 | } |
---|
52 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
53 | //const real form = (upper-lower)/2.0*total; |
---|
54 | return REAL(1.0e-4) * total * M_PI_4; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | real Iqxy(real qx, real qy, |
---|
59 | real core_sld, |
---|
60 | real shell_sld, |
---|
61 | real solvent_sld, |
---|
62 | real radius, |
---|
63 | real thickness, |
---|
64 | real length, |
---|
65 | real theta, |
---|
66 | real phi) |
---|
67 | { |
---|
68 | real sn, cn; // slots to hold sincos function output |
---|
69 | |
---|
70 | // Compute angle alpha between q and the cylinder axis |
---|
71 | SINCOS(theta*M_PI_180, sn, cn); |
---|
72 | // # The following correction factor exists in sasview, but it can't be |
---|
73 | // # right, so we are leaving it out for now. |
---|
74 | // const real correction = fabs(cn)*M_PI_2; |
---|
75 | const real q = sqrt(qx*qx+qy*qy); |
---|
76 | const real cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); |
---|
77 | const real alpha = acos(cos_val); |
---|
78 | |
---|
79 | const real core_qr = q*radius; |
---|
80 | const real core_qh = q*REAL(0.5)*length; |
---|
81 | const real core_twovd = REAL(2.0) * form_volume(radius,0,length) |
---|
82 | * (core_sld-shell_sld); |
---|
83 | const real shell_qr = q*(radius + thickness); |
---|
84 | const real shell_qh = q*(REAL(0.5)*length + thickness); |
---|
85 | const real shell_twovd = REAL(2.0) * form_volume(radius,thickness,length) |
---|
86 | * (shell_sld-solvent_sld); |
---|
87 | |
---|
88 | SINCOS(alpha, sn, cn); |
---|
89 | const real fq = _cyl(core_twovd, core_qr*sn, core_qh*cn) |
---|
90 | + _cyl(shell_twovd, shell_qr*sn, shell_qh*cn); |
---|
91 | return REAL(1.0e-4) * fq * fq; |
---|
92 | } |
---|