1 | // NOTE that "length" here is the full height of the core! |
---|
2 | static double |
---|
3 | form_volume(double r_minor, |
---|
4 | double x_core, |
---|
5 | double thick_rim, |
---|
6 | double thick_face, |
---|
7 | double length) |
---|
8 | { |
---|
9 | return M_PI*( (r_minor + thick_rim)*(r_minor*x_core + thick_rim)* length + |
---|
10 | square(r_minor)*x_core*2.0*thick_face ); |
---|
11 | } |
---|
12 | |
---|
13 | static double |
---|
14 | radius_from_excluded_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
15 | { |
---|
16 | const double r_equiv = sqrt((r_minor + thick_rim)*(r_minor*x_core + thick_rim)); |
---|
17 | const double length_tot = length + 2.0*thick_face; |
---|
18 | return 0.5*cbrt(0.75*r_equiv*(2.0*r_equiv*length_tot + (r_equiv + length_tot)*(M_PI*r_equiv + length_tot))); |
---|
19 | } |
---|
20 | |
---|
21 | static double |
---|
22 | radius_from_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
23 | { |
---|
24 | const double volume_bicelle = form_volume(r_minor, x_core, thick_rim,thick_face,length); |
---|
25 | return cbrt(volume_bicelle/M_4PI_3); |
---|
26 | } |
---|
27 | |
---|
28 | static double |
---|
29 | radius_from_diagonal(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
30 | { |
---|
31 | const double radius_max = (x_core < 1.0 ? r_minor : x_core*r_minor); |
---|
32 | const double radius_max_tot = radius_max + thick_rim; |
---|
33 | const double length_tot = length + 2.0*thick_face; |
---|
34 | return sqrt(radius_max_tot*radius_max_tot + 0.25*length_tot*length_tot); |
---|
35 | } |
---|
36 | |
---|
37 | static double |
---|
38 | radius_effective(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
39 | { |
---|
40 | switch (mode) { |
---|
41 | default: |
---|
42 | case 1: // equivalent cylinder excluded volume |
---|
43 | return radius_from_excluded_volume(r_minor, x_core, thick_rim, thick_face, length); |
---|
44 | case 2: // equivalent sphere |
---|
45 | return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); |
---|
46 | case 3: // outer rim average radius |
---|
47 | return 0.5*r_minor*(1.0 + x_core) + thick_rim; |
---|
48 | case 4: // outer rim min radius |
---|
49 | return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); |
---|
50 | case 5: // outer max radius |
---|
51 | return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); |
---|
52 | case 6: // half outer thickness |
---|
53 | return 0.5*length + thick_face; |
---|
54 | case 7: // half diagonal (this ignores the missing "corners", so may give unexpected answer if thick_face |
---|
55 | // or thick_rim is extremely large) |
---|
56 | return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | static void |
---|
61 | Fq(double q, |
---|
62 | double *F1, |
---|
63 | double *F2, |
---|
64 | double r_minor, |
---|
65 | double x_core, |
---|
66 | double thick_rim, |
---|
67 | double thick_face, |
---|
68 | double length, |
---|
69 | double rhoc, |
---|
70 | double rhoh, |
---|
71 | double rhor, |
---|
72 | double rhosolv, |
---|
73 | double sigma) |
---|
74 | { |
---|
75 | // core_shell_bicelle_elliptical_belt, RKH 5th Oct 2017, core_shell_bicelle_elliptical |
---|
76 | // tested briefly against limiting cases of cylinder, hollow cylinder & elliptical cylinder models |
---|
77 | // const double uplim = M_PI_4; |
---|
78 | const double halfheight = 0.5*length; |
---|
79 | //const double va = 0.0; |
---|
80 | //const double vb = 1.0; |
---|
81 | // inner integral limits |
---|
82 | //const double vaj=0.0; |
---|
83 | //const double vbj=M_PI; |
---|
84 | |
---|
85 | const double r_major = r_minor * x_core; |
---|
86 | const double r2A = 0.5*(square(r_major) + square(r_minor)); |
---|
87 | const double r2B = 0.5*(square(r_major) - square(r_minor)); |
---|
88 | const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight); |
---|
89 | const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight; |
---|
90 | const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); |
---|
91 | // dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face, |
---|
92 | const double dr1 = vol1*(-rhor - rhoh + rhoc + rhosolv); |
---|
93 | const double dr2 = vol2*(rhor-rhosolv); |
---|
94 | const double dr3 = vol3*(rhoh-rhosolv); |
---|
95 | |
---|
96 | //initialize integral |
---|
97 | double outer_total_F1 = 0.0; |
---|
98 | double outer_total_F2 = 0.0; |
---|
99 | for(int i=0;i<GAUSS_N;i++) { |
---|
100 | //setup inner integral over the ellipsoidal cross-section |
---|
101 | // since we generate these lots of times, why not store them somewhere? |
---|
102 | //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; |
---|
103 | const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0; |
---|
104 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
105 | const double qab = q*sin_theta; |
---|
106 | const double qc = q*cos_theta; |
---|
107 | const double si1 = sas_sinx_x(halfheight*qc); |
---|
108 | const double si2 = sas_sinx_x((halfheight+thick_face)*qc); |
---|
109 | double inner_total_F1 = 0; |
---|
110 | double inner_total_F2 = 0; |
---|
111 | for(int j=0;j<GAUSS_N;j++) { |
---|
112 | //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe) |
---|
113 | //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; |
---|
114 | const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2; |
---|
115 | const double rr = sqrt(r2A - r2B*cos(beta)); |
---|
116 | const double be1 = sas_2J1x_x(rr*qab); |
---|
117 | const double be2 = sas_2J1x_x((rr+thick_rim)*qab); |
---|
118 | const double f = dr1*si1*be1 + dr2*si1*be2 + dr3*si2*be1; |
---|
119 | |
---|
120 | inner_total_F1 += GAUSS_W[j] * f; |
---|
121 | inner_total_F2 += GAUSS_W[j] * f * f; |
---|
122 | } |
---|
123 | //now calculate outer integral |
---|
124 | outer_total_F1 += GAUSS_W[i] * inner_total_F1; |
---|
125 | outer_total_F2 += GAUSS_W[i] * inner_total_F2; |
---|
126 | } |
---|
127 | // now complete change of integration variables (1-0)/(1-(-1))= 0.5 |
---|
128 | outer_total_F1 *= 0.25; |
---|
129 | outer_total_F2 *= 0.25; |
---|
130 | |
---|
131 | //convert from [1e-12 A-1] to [cm-1] |
---|
132 | *F1 = 1e-2*outer_total_F1*exp(-0.25*square(q*sigma)); |
---|
133 | *F2 = 1e-4*outer_total_F2*exp(-0.5*square(q*sigma)); |
---|
134 | } |
---|
135 | |
---|
136 | static double |
---|
137 | Iqabc(double qa, double qb, double qc, |
---|
138 | double r_minor, |
---|
139 | double x_core, |
---|
140 | double thick_rim, |
---|
141 | double thick_face, |
---|
142 | double length, |
---|
143 | double rhoc, |
---|
144 | double rhoh, |
---|
145 | double rhor, |
---|
146 | double rhosolv, |
---|
147 | double sigma) |
---|
148 | { |
---|
149 | // integrated 2d seems to match 1d reasonably well, except perhaps at very high Q |
---|
150 | // Vol1,2,3 and dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face, |
---|
151 | const double dr1 = -rhor - rhoh + rhoc + rhosolv; |
---|
152 | const double dr2 = rhor-rhosolv; |
---|
153 | const double dr3 = rhoh-rhosolv; |
---|
154 | const double r_major = r_minor*x_core; |
---|
155 | const double halfheight = 0.5*length; |
---|
156 | const double vol1 = M_PI*r_minor*r_major*length; |
---|
157 | const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight; |
---|
158 | const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); |
---|
159 | |
---|
160 | // Compute effective radius in rotated coordinates |
---|
161 | const double qr_hat = sqrt(square(r_major*qb) + square(r_minor*qa)); |
---|
162 | // does this need to be changed for the "missing corners" where there there is no "belt" ? |
---|
163 | const double qrshell_hat = sqrt(square((r_major+thick_rim)*qb) |
---|
164 | + square((r_minor+thick_rim)*qa)); |
---|
165 | const double be1 = sas_2J1x_x( qr_hat ); |
---|
166 | const double be2 = sas_2J1x_x( qrshell_hat ); |
---|
167 | const double si1 = sas_sinx_x( halfheight*qc ); |
---|
168 | const double si2 = sas_sinx_x( (halfheight + thick_face)*qc ); |
---|
169 | const double fq = vol1*dr1*si1*be1 + vol2*dr2*si1*be2 + vol3*dr3*si2*be1; |
---|
170 | const double atten = exp(-0.5*(qa*qa + qb*qb + qc*qc)*(sigma*sigma)); |
---|
171 | return 1.0e-4 * fq*fq * atten; |
---|
172 | } |
---|