[96656e3] | 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_adv.h" |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | ReflAdvModel :: ReflAdvModel() { |
---|
| 13 | n_layers = Parameter(1.0); |
---|
| 14 | scale = Parameter(1.0); |
---|
| 15 | thick_inter0 = Parameter(1.0); |
---|
| 16 | func_inter0 = Parameter(0); |
---|
| 17 | sld_bottom0 = Parameter(2.07e-06); |
---|
| 18 | sld_medium = 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(15.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 | 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 | nu_inter1 = Parameter(2.5); |
---|
| 81 | nu_inter2 = Parameter(2.5); |
---|
| 82 | nu_inter3 = Parameter(2.5); |
---|
| 83 | nu_inter4 = Parameter(2.5); |
---|
| 84 | nu_inter5 = Parameter(2.5); |
---|
| 85 | nu_inter6 = Parameter(2.5); |
---|
| 86 | nu_inter7 = Parameter(2.5); |
---|
| 87 | nu_inter8 = Parameter(2.5); |
---|
| 88 | nu_inter9 = Parameter(2.5); |
---|
| 89 | nu_inter10 = Parameter(2.5); |
---|
| 90 | |
---|
| 91 | sldIM_sub0 = Parameter(0.0); |
---|
| 92 | sldIM_medium = Parameter(0.0); |
---|
| 93 | npts_inter = Parameter(21.0); |
---|
| 94 | nu_inter0 = Parameter(2.5); |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | /** |
---|
| 98 | * Function to evaluate 1D NR function |
---|
| 99 | * @param q: q-value |
---|
| 100 | * @return: function value |
---|
| 101 | */ |
---|
| 102 | double ReflAdvModel :: operator()(double q) { |
---|
| 103 | double dp[71]; |
---|
| 104 | // Fill parameter array for IGOR library |
---|
| 105 | // Add the background after averaging |
---|
| 106 | dp[0] = n_layers(); |
---|
| 107 | dp[1] = scale(); |
---|
| 108 | dp[2] = thick_inter0(); |
---|
| 109 | dp[3] = func_inter0(); |
---|
| 110 | dp[4] = sld_bottom0(); |
---|
| 111 | dp[5] = sld_medium(); |
---|
| 112 | dp[6] = background(); |
---|
| 113 | |
---|
| 114 | dp[7] = sld_flat1(); |
---|
| 115 | dp[8] = sld_flat2(); |
---|
| 116 | dp[9] = sld_flat3(); |
---|
| 117 | dp[10] = sld_flat4(); |
---|
| 118 | dp[11] = sld_flat5(); |
---|
| 119 | dp[12] = sld_flat6(); |
---|
| 120 | dp[13] = sld_flat7(); |
---|
| 121 | dp[14] = sld_flat8(); |
---|
| 122 | dp[15] = sld_flat9(); |
---|
| 123 | dp[16] = sld_flat10(); |
---|
| 124 | |
---|
| 125 | dp[17] = thick_inter1(); |
---|
| 126 | dp[18] = thick_inter2(); |
---|
| 127 | dp[19] = thick_inter3(); |
---|
| 128 | dp[20] = thick_inter4(); |
---|
| 129 | dp[21] = thick_inter5(); |
---|
| 130 | dp[22] = thick_inter6(); |
---|
| 131 | dp[23] = thick_inter7(); |
---|
| 132 | dp[24] = thick_inter8(); |
---|
| 133 | dp[25] = thick_inter9(); |
---|
| 134 | dp[26] = thick_inter10(); |
---|
| 135 | |
---|
| 136 | dp[27] = thick_flat1(); |
---|
| 137 | dp[28] = thick_flat2(); |
---|
| 138 | dp[29] = thick_flat3(); |
---|
| 139 | dp[30] = thick_flat4(); |
---|
| 140 | dp[31] = thick_flat5(); |
---|
| 141 | dp[32] = thick_flat6(); |
---|
| 142 | dp[33] = thick_flat7(); |
---|
| 143 | dp[34] = thick_flat8(); |
---|
| 144 | dp[35] = thick_flat9(); |
---|
| 145 | dp[36] = thick_flat10(); |
---|
| 146 | |
---|
| 147 | dp[37] = func_inter1(); |
---|
| 148 | dp[38] = func_inter2(); |
---|
| 149 | dp[39] = func_inter3(); |
---|
| 150 | dp[40] = func_inter4(); |
---|
| 151 | dp[41] = func_inter5(); |
---|
| 152 | dp[42] = func_inter6(); |
---|
| 153 | dp[43] = func_inter7(); |
---|
| 154 | dp[44] = func_inter8(); |
---|
| 155 | dp[45] = func_inter9(); |
---|
| 156 | dp[46] = func_inter10(); |
---|
| 157 | |
---|
| 158 | dp[47] = sldIM_flat1(); |
---|
| 159 | dp[48] = sldIM_flat2(); |
---|
| 160 | dp[49] = sldIM_flat3(); |
---|
| 161 | dp[50] = sldIM_flat4(); |
---|
| 162 | dp[51] = sldIM_flat5(); |
---|
| 163 | dp[52] = sldIM_flat6(); |
---|
| 164 | dp[53] = sldIM_flat7(); |
---|
| 165 | dp[54] = sldIM_flat8(); |
---|
| 166 | dp[55] = sldIM_flat9(); |
---|
| 167 | dp[56] = sldIM_flat10(); |
---|
| 168 | |
---|
| 169 | dp[57] = nu_inter1(); |
---|
| 170 | dp[58] = nu_inter2(); |
---|
| 171 | dp[59] = nu_inter3(); |
---|
| 172 | dp[60] = nu_inter4(); |
---|
| 173 | dp[61] = nu_inter5(); |
---|
| 174 | dp[62] = nu_inter6(); |
---|
| 175 | dp[63] = nu_inter7(); |
---|
| 176 | dp[64] = nu_inter8(); |
---|
| 177 | dp[65] = nu_inter9(); |
---|
| 178 | dp[66] = nu_inter10(); |
---|
| 179 | |
---|
| 180 | dp[67] = sldIM_sub0(); |
---|
| 181 | dp[68] = sldIM_medium(); |
---|
| 182 | dp[69] = npts_inter(); |
---|
| 183 | dp[70] = nu_inter0(); |
---|
| 184 | // Get the dispersion points for the radius |
---|
| 185 | //vector<WeightPoint> weights_thick; |
---|
| 186 | //thick_inter0.get_weights(weights_thick_inter0); |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | return re_adv_kernel(dp,q); |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | /** |
---|
| 193 | * Function to evaluate 2D NR function |
---|
| 194 | * @param q_x: value of Q along x |
---|
| 195 | * @param q_y: value of Q along y |
---|
| 196 | * @return: function value |
---|
| 197 | */ |
---|
| 198 | double ReflAdvModel :: operator()(double qx, double qy) { |
---|
[aae7a8d] | 199 | // For 2D set qy as q, ignoring qx. |
---|
| 200 | double q = qy;//sqrt(qx*qx + qy*qy); |
---|
| 201 | if (q < 0.0){ |
---|
| 202 | return 0.0; |
---|
| 203 | } |
---|
[96656e3] | 204 | return (*this).operator()(q); |
---|
| 205 | } |
---|
| 206 | |
---|
| 207 | /** |
---|
| 208 | * Function to evaluate 2D NR function |
---|
| 209 | * @param pars: parameters of the sphere |
---|
| 210 | * @param q: q-value |
---|
| 211 | * @param phi: angle phi |
---|
| 212 | * @return: function value |
---|
| 213 | */ |
---|
| 214 | double ReflAdvModel :: evaluate_rphi(double q, double phi) { |
---|
| 215 | return (*this).operator()(q); |
---|
| 216 | } |
---|
| 217 | |
---|
| 218 | /** |
---|
| 219 | * Function to calculate effective radius |
---|
| 220 | * @return: effective radius value |
---|
| 221 | */ |
---|
| 222 | double ReflAdvModel :: calculate_ER() { |
---|
| 223 | //NOT implemented yet!!! |
---|
[34c2649] | 224 | return 0.0; |
---|
[96656e3] | 225 | } |
---|