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 "refl.h" |
---|
10 | } |
---|
11 | |
---|
12 | ReflModel :: ReflModel() { |
---|
13 | n_layers = Parameter(1.0); |
---|
14 | scale = Parameter(1.0); |
---|
15 | thick_inter0 = Parameter(1.0); |
---|
16 | func_inter0 = Parameter(0); |
---|
17 | sld_sub0 = Parameter(2.07e-06); |
---|
18 | sld_medium = Parameter(1.0e-06); |
---|
19 | background = Parameter(0.0); |
---|
20 | |
---|
21 | |
---|
22 | sld_flat1 = Parameter(3.0e-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); |
---|
35 | thick_inter2 = Parameter(1); |
---|
36 | thick_inter3 = Parameter(1); |
---|
37 | thick_inter4 = Parameter(1); |
---|
38 | thick_inter5 = Parameter(1); |
---|
39 | thick_inter6 = Parameter(1); |
---|
40 | thick_inter7 = Parameter(1); |
---|
41 | thick_inter8 = Parameter(1); |
---|
42 | thick_inter9 = Parameter(1); |
---|
43 | thick_inter10 = Parameter(1); |
---|
44 | |
---|
45 | |
---|
46 | thick_flat1 = Parameter(15); |
---|
47 | thick_flat2 = Parameter(100); |
---|
48 | thick_flat3 = Parameter(100); |
---|
49 | thick_flat4 = Parameter(100); |
---|
50 | thick_flat5 = Parameter(100); |
---|
51 | thick_flat6 = Parameter(100); |
---|
52 | thick_flat7 = Parameter(100); |
---|
53 | thick_flat8 = Parameter(100); |
---|
54 | thick_flat9 = Parameter(100); |
---|
55 | thick_flat10 = Parameter(100); |
---|
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 | sldIM_flat1 = Parameter(0); |
---|
70 | sldIM_flat2 = Parameter(0); |
---|
71 | sldIM_flat3 = Parameter(0); |
---|
72 | sldIM_flat4 = Parameter(0); |
---|
73 | sldIM_flat5 = Parameter(0); |
---|
74 | sldIM_flat6 = Parameter(0); |
---|
75 | sldIM_flat7 = Parameter(0); |
---|
76 | sldIM_flat8 = Parameter(0); |
---|
77 | sldIM_flat9 = Parameter(0); |
---|
78 | sldIM_flat10 = Parameter(0); |
---|
79 | |
---|
80 | sldIM_sub0 = Parameter(0); |
---|
81 | sldIM_medium = Parameter(0); |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * Function to evaluate 1D NR function |
---|
86 | * @param q: q-value |
---|
87 | * @return: function value |
---|
88 | */ |
---|
89 | double ReflModel :: operator()(double q) { |
---|
90 | double dp[59]; |
---|
91 | // Fill parameter array for IGOR library |
---|
92 | // Add the background after averaging |
---|
93 | dp[0] = n_layers(); |
---|
94 | dp[1] = scale(); |
---|
95 | dp[2] = thick_inter0(); |
---|
96 | dp[3] = func_inter0(); |
---|
97 | dp[4] = sld_sub0(); |
---|
98 | dp[5] = sld_medium(); |
---|
99 | dp[6] = background(); |
---|
100 | |
---|
101 | dp[7] = sld_flat1(); |
---|
102 | dp[8] = sld_flat2(); |
---|
103 | dp[9] = sld_flat3(); |
---|
104 | dp[10] = sld_flat4(); |
---|
105 | dp[11] = sld_flat5(); |
---|
106 | dp[12] = sld_flat6(); |
---|
107 | dp[13] = sld_flat7(); |
---|
108 | dp[14] = sld_flat8(); |
---|
109 | dp[15] = sld_flat9(); |
---|
110 | dp[16] = sld_flat10(); |
---|
111 | |
---|
112 | dp[17] = thick_inter1(); |
---|
113 | dp[18] = thick_inter2(); |
---|
114 | dp[19] = thick_inter3(); |
---|
115 | dp[20] = thick_inter4(); |
---|
116 | dp[21] = thick_inter5(); |
---|
117 | dp[22] = thick_inter6(); |
---|
118 | dp[23] = thick_inter7(); |
---|
119 | dp[24] = thick_inter8(); |
---|
120 | dp[25] = thick_inter9(); |
---|
121 | dp[26] = thick_inter10(); |
---|
122 | |
---|
123 | dp[27] = thick_flat1(); |
---|
124 | dp[28] = thick_flat2(); |
---|
125 | dp[29] = thick_flat3(); |
---|
126 | dp[30] = thick_flat4(); |
---|
127 | dp[31] = thick_flat5(); |
---|
128 | dp[32] = thick_flat6(); |
---|
129 | dp[33] = thick_flat7(); |
---|
130 | dp[34] = thick_flat8(); |
---|
131 | dp[35] = thick_flat9(); |
---|
132 | dp[36] = thick_flat10(); |
---|
133 | |
---|
134 | dp[37] = func_inter1(); |
---|
135 | dp[38] = func_inter2(); |
---|
136 | dp[39] = func_inter3(); |
---|
137 | dp[40] = func_inter4(); |
---|
138 | dp[41] = func_inter5(); |
---|
139 | dp[42] = func_inter6(); |
---|
140 | dp[43] = func_inter7(); |
---|
141 | dp[44] = func_inter8(); |
---|
142 | dp[45] = func_inter9(); |
---|
143 | dp[46] = func_inter10(); |
---|
144 | |
---|
145 | dp[47] = sldIM_flat1(); |
---|
146 | dp[48] = sldIM_flat2(); |
---|
147 | dp[49] = sldIM_flat3(); |
---|
148 | dp[50] = sldIM_flat4(); |
---|
149 | dp[51] = sldIM_flat5(); |
---|
150 | dp[52] = sldIM_flat6(); |
---|
151 | dp[53] = sldIM_flat7(); |
---|
152 | dp[54] = sldIM_flat8(); |
---|
153 | dp[55] = sldIM_flat9(); |
---|
154 | dp[56] = sldIM_flat10(); |
---|
155 | |
---|
156 | dp[57] = sldIM_sub0(); |
---|
157 | dp[58] = sldIM_medium(); |
---|
158 | |
---|
159 | // Get the dispersion points for the radius |
---|
160 | //vector<WeightPoint> weights_thick; |
---|
161 | //thick_inter0.get_weights(weights_thick_inter0); |
---|
162 | |
---|
163 | |
---|
164 | return re_kernel(dp,q); |
---|
165 | } |
---|
166 | |
---|
167 | /** |
---|
168 | * Function to evaluate 2D NR 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 ReflModel :: 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 2D NR function |
---|
180 | * @param pars: parameters of the sphere |
---|
181 | * @param q: q-value |
---|
182 | * @param phi: angle phi |
---|
183 | * @return: function value |
---|
184 | */ |
---|
185 | double ReflModel :: evaluate_rphi(double q, double phi) { |
---|
186 | return (*this).operator()(q); |
---|
187 | } |
---|
188 | |
---|
189 | /** |
---|
190 | * Function to calculate effective radius |
---|
191 | * @return: effective radius value |
---|
192 | */ |
---|
193 | double ReflModel :: calculate_ER() { |
---|
194 | //NOT implemented yet!!! |
---|
195 | } |
---|