1 | |
---|
2 | #include <math.h> |
---|
3 | #include "models.hh" |
---|
4 | #include "parameters.hh" |
---|
5 | #include <stdio.h> |
---|
6 | using namespace std; |
---|
7 | |
---|
8 | extern "C" { |
---|
9 | #include "spheresld.h" |
---|
10 | } |
---|
11 | |
---|
12 | SphereSLDModel :: SphereSLDModel() { |
---|
13 | n_shells = Parameter(1.0); |
---|
14 | scale = Parameter(1.0); |
---|
15 | thick_inter0 = Parameter(1.0); |
---|
16 | func_inter0 = Parameter(0); |
---|
17 | sld_core0 = Parameter(2.07e-06); |
---|
18 | sld_solv = Parameter(1.0e-06); |
---|
19 | background = Parameter(0.0); |
---|
20 | |
---|
21 | |
---|
22 | sld_flat1 = Parameter(2.7e-06); |
---|
23 | sld_flat2 = Parameter(3.5e-06); |
---|
24 | sld_flat3 = Parameter(4.0e-06); |
---|
25 | sld_flat4 = Parameter(3.5e-06); |
---|
26 | sld_flat5 = Parameter(4.0e-06); |
---|
27 | sld_flat6 = Parameter(3.5e-06); |
---|
28 | sld_flat7 = Parameter(4.0e-06); |
---|
29 | sld_flat8 = Parameter(3.5e-06); |
---|
30 | sld_flat9 = Parameter(4.0e-06); |
---|
31 | sld_flat10 = Parameter(3.5e-06); |
---|
32 | |
---|
33 | |
---|
34 | thick_inter1 = Parameter(1.0); |
---|
35 | thick_inter2 = Parameter(1.0); |
---|
36 | thick_inter3 = Parameter(1.0); |
---|
37 | thick_inter4 = Parameter(1.0); |
---|
38 | thick_inter5 = Parameter(1.0); |
---|
39 | thick_inter6 = Parameter(1.0); |
---|
40 | thick_inter7 = Parameter(1.0); |
---|
41 | thick_inter8 = Parameter(1.0); |
---|
42 | thick_inter9 = Parameter(1.0); |
---|
43 | thick_inter10 = Parameter(1.0); |
---|
44 | |
---|
45 | |
---|
46 | thick_flat1 = Parameter(100.0); |
---|
47 | thick_flat2 = Parameter(100.0); |
---|
48 | thick_flat3 = Parameter(100.0); |
---|
49 | thick_flat4 = Parameter(100.0); |
---|
50 | thick_flat5 = Parameter(100.0); |
---|
51 | thick_flat6 = Parameter(100.0); |
---|
52 | thick_flat7 = Parameter(100.0); |
---|
53 | thick_flat8 = Parameter(100.0); |
---|
54 | thick_flat9 = Parameter(100.0); |
---|
55 | thick_flat10 = Parameter(100.0); |
---|
56 | |
---|
57 | |
---|
58 | func_inter1 = Parameter(0); |
---|
59 | func_inter2 = Parameter(0); |
---|
60 | func_inter3 = Parameter(0); |
---|
61 | func_inter4 = Parameter(0); |
---|
62 | func_inter5 = Parameter(0); |
---|
63 | func_inter6 = Parameter(0); |
---|
64 | func_inter7 = Parameter(0); |
---|
65 | func_inter8 = Parameter(0); |
---|
66 | func_inter9 = Parameter(0); |
---|
67 | func_inter10 = Parameter(0); |
---|
68 | |
---|
69 | nu_inter1 = Parameter(2.5); |
---|
70 | nu_inter2 = Parameter(2.5); |
---|
71 | nu_inter3 = Parameter(2.5); |
---|
72 | nu_inter4 = Parameter(2.5); |
---|
73 | nu_inter5 = Parameter(2.5); |
---|
74 | nu_inter6 = Parameter(2.5); |
---|
75 | nu_inter7 = Parameter(2.5); |
---|
76 | nu_inter8 = Parameter(2.5); |
---|
77 | nu_inter9 = Parameter(2.5); |
---|
78 | nu_inter10 = Parameter(2.5); |
---|
79 | |
---|
80 | npts_inter = Parameter(35.0); |
---|
81 | nu_inter0 = Parameter(2.5); |
---|
82 | rad_core0 = Parameter(60.0); |
---|
83 | } |
---|
84 | |
---|
85 | /** |
---|
86 | * Function to evaluate 1D SphereSLD function |
---|
87 | * @param q: q-value |
---|
88 | * @return: function value |
---|
89 | */ |
---|
90 | double SphereSLDModel :: operator()(double q) { |
---|
91 | double dp[60]; |
---|
92 | // Fill parameter array for IGOR library |
---|
93 | // Add the background after averaging |
---|
94 | dp[0] = n_shells(); |
---|
95 | dp[1] = scale(); |
---|
96 | dp[2] = thick_inter0(); |
---|
97 | dp[3] = func_inter0(); |
---|
98 | dp[4] = sld_core0(); |
---|
99 | dp[5] = sld_solv(); |
---|
100 | dp[6] = background(); |
---|
101 | |
---|
102 | dp[7] = sld_flat1(); |
---|
103 | dp[8] = sld_flat2(); |
---|
104 | dp[9] = sld_flat3(); |
---|
105 | dp[10] = sld_flat4(); |
---|
106 | dp[11] = sld_flat5(); |
---|
107 | dp[12] = sld_flat6(); |
---|
108 | dp[13] = sld_flat7(); |
---|
109 | dp[14] = sld_flat8(); |
---|
110 | dp[15] = sld_flat9(); |
---|
111 | dp[16] = sld_flat10(); |
---|
112 | |
---|
113 | dp[17] = thick_inter1(); |
---|
114 | dp[18] = thick_inter2(); |
---|
115 | dp[19] = thick_inter3(); |
---|
116 | dp[20] = thick_inter4(); |
---|
117 | dp[21] = thick_inter5(); |
---|
118 | dp[22] = thick_inter6(); |
---|
119 | dp[23] = thick_inter7(); |
---|
120 | dp[24] = thick_inter8(); |
---|
121 | dp[25] = thick_inter9(); |
---|
122 | dp[26] = thick_inter10(); |
---|
123 | |
---|
124 | dp[27] = thick_flat1(); |
---|
125 | dp[28] = thick_flat2(); |
---|
126 | dp[29] = thick_flat3(); |
---|
127 | dp[30] = thick_flat4(); |
---|
128 | dp[31] = thick_flat5(); |
---|
129 | dp[32] = thick_flat6(); |
---|
130 | dp[33] = thick_flat7(); |
---|
131 | dp[34] = thick_flat8(); |
---|
132 | dp[35] = thick_flat9(); |
---|
133 | dp[36] = thick_flat10(); |
---|
134 | |
---|
135 | dp[37] = func_inter1(); |
---|
136 | dp[38] = func_inter2(); |
---|
137 | dp[39] = func_inter3(); |
---|
138 | dp[40] = func_inter4(); |
---|
139 | dp[41] = func_inter5(); |
---|
140 | dp[42] = func_inter6(); |
---|
141 | dp[43] = func_inter7(); |
---|
142 | dp[44] = func_inter8(); |
---|
143 | dp[45] = func_inter9(); |
---|
144 | dp[46] = func_inter10(); |
---|
145 | |
---|
146 | dp[47] = nu_inter1(); |
---|
147 | dp[48] = nu_inter2(); |
---|
148 | dp[49] = nu_inter3(); |
---|
149 | dp[50] = nu_inter4(); |
---|
150 | dp[51] = nu_inter5(); |
---|
151 | dp[52] = nu_inter6(); |
---|
152 | dp[53] = nu_inter7(); |
---|
153 | dp[54] = nu_inter8(); |
---|
154 | dp[55] = nu_inter9(); |
---|
155 | dp[56] = nu_inter10(); |
---|
156 | |
---|
157 | |
---|
158 | dp[57] = npts_inter(); |
---|
159 | dp[58] = nu_inter0(); |
---|
160 | dp[59] = rad_core0(); |
---|
161 | |
---|
162 | // No polydispersion supported in this model. |
---|
163 | |
---|
164 | return sphere_sld_kernel(dp,q); |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * Function to evaluate 2D SphereSLD function |
---|
169 | * @param q_x: value of Q along x |
---|
170 | * @param q_y: value of Q along y |
---|
171 | * @return: function value |
---|
172 | */ |
---|
173 | double SphereSLDModel :: operator()(double qx, double qy) { |
---|
174 | double q = sqrt(qx*qx + qy*qy); |
---|
175 | return (*this).operator()(q); |
---|
176 | } |
---|
177 | |
---|
178 | /** |
---|
179 | * Function to evaluate SphereSLD function |
---|
180 | * @param pars: parameters of the SphereSLD |
---|
181 | * @param q: q-value |
---|
182 | * @param phi: angle phi |
---|
183 | * @return: function value |
---|
184 | */ |
---|
185 | double SphereSLDModel :: evaluate_rphi(double q, double phi) { |
---|
186 | return (*this).operator()(q); |
---|
187 | } |
---|
188 | |
---|
189 | /** |
---|
190 | * Function to calculate TOTAL radius |
---|
191 | * ToDo: Find What is the effective radius for this model. |
---|
192 | * @return: effective radius value |
---|
193 | */ |
---|
194 | // No polydispersion supported in this model. |
---|
195 | // Calculate max radius assumming max_radius = effective radius |
---|
196 | // Note that this max radius is not affected by sld of layer, sld of interface, or |
---|
197 | // sld of solvent. |
---|
198 | double SphereSLDModel :: calculate_ER() { |
---|
199 | SphereSLDParameters dp; |
---|
200 | |
---|
201 | dp.n_shells = n_shells(); |
---|
202 | |
---|
203 | dp.rad_core0 = rad_core0(); |
---|
204 | dp.thick_flat1 = thick_flat1(); |
---|
205 | dp.thick_flat2 = thick_flat2(); |
---|
206 | dp.thick_flat3 = thick_flat3(); |
---|
207 | dp.thick_flat4 = thick_flat4(); |
---|
208 | dp.thick_flat5 = thick_flat5(); |
---|
209 | dp.thick_flat6 = thick_flat6(); |
---|
210 | dp.thick_flat7 = thick_flat7(); |
---|
211 | dp.thick_flat8 = thick_flat8(); |
---|
212 | dp.thick_flat9 = thick_flat9(); |
---|
213 | dp.thick_flat10 = thick_flat10(); |
---|
214 | |
---|
215 | dp.thick_inter0 = thick_inter0(); |
---|
216 | dp.thick_inter1 = thick_inter1(); |
---|
217 | dp.thick_inter2 = thick_inter2(); |
---|
218 | dp.thick_inter3 = thick_inter3(); |
---|
219 | dp.thick_inter4 = thick_inter4(); |
---|
220 | dp.thick_inter5 = thick_inter5(); |
---|
221 | dp.thick_inter6 = thick_inter6(); |
---|
222 | dp.thick_inter7 = thick_inter7(); |
---|
223 | dp.thick_inter8 = thick_inter8(); |
---|
224 | dp.thick_inter9 = thick_inter9(); |
---|
225 | dp.thick_inter10 = thick_inter10(); |
---|
226 | |
---|
227 | double rad_out = dp.rad_core0 + dp.thick_inter0; |
---|
228 | if (dp.n_shells > 0) |
---|
229 | rad_out += dp.thick_flat1 + dp.thick_inter1; |
---|
230 | if (dp.n_shells > 1) |
---|
231 | rad_out += dp.thick_flat2 + dp.thick_inter2; |
---|
232 | if (dp.n_shells > 2) |
---|
233 | rad_out += dp.thick_flat3 + dp.thick_inter3; |
---|
234 | if (dp.n_shells > 3) |
---|
235 | rad_out += dp.thick_flat4 + dp.thick_inter4; |
---|
236 | if (dp.n_shells > 4) |
---|
237 | rad_out += dp.thick_flat5 + dp.thick_inter5; |
---|
238 | if (dp.n_shells > 5) |
---|
239 | rad_out += dp.thick_flat6 + dp.thick_inter6; |
---|
240 | if (dp.n_shells > 6) |
---|
241 | rad_out += dp.thick_flat7 + dp.thick_inter7; |
---|
242 | if (dp.n_shells > 7) |
---|
243 | rad_out += dp.thick_flat8 + dp.thick_inter8; |
---|
244 | if (dp.n_shells > 8) |
---|
245 | rad_out += dp.thick_flat9 + dp.thick_inter9; |
---|
246 | if (dp.n_shells > 9) |
---|
247 | rad_out += dp.thick_flat10 + dp.thick_inter10; |
---|
248 | |
---|
249 | return rad_out; |
---|
250 | |
---|
251 | } |
---|