[35aface] | 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); |
---|
[0164899a] | 17 | sld_bottom0 = Parameter(2.07e-06); |
---|
[35aface] | 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 | } |
---|
| 70 | |
---|
| 71 | /** |
---|
| 72 | * Function to evaluate 1D NR function |
---|
| 73 | * @param q: q-value |
---|
| 74 | * @return: function value |
---|
| 75 | */ |
---|
| 76 | double ReflModel :: operator()(double q) { |
---|
[0164899a] | 77 | double dp[47]; |
---|
[35aface] | 78 | // Fill parameter array for IGOR library |
---|
| 79 | // Add the background after averaging |
---|
| 80 | dp[0] = n_layers(); |
---|
| 81 | dp[1] = scale(); |
---|
| 82 | dp[2] = thick_inter0(); |
---|
| 83 | dp[3] = func_inter0(); |
---|
[0164899a] | 84 | dp[4] = sld_bottom0(); |
---|
[35aface] | 85 | dp[5] = sld_medium(); |
---|
| 86 | dp[6] = background(); |
---|
| 87 | |
---|
| 88 | dp[7] = sld_flat1(); |
---|
| 89 | dp[8] = sld_flat2(); |
---|
| 90 | dp[9] = sld_flat3(); |
---|
| 91 | dp[10] = sld_flat4(); |
---|
| 92 | dp[11] = sld_flat5(); |
---|
| 93 | dp[12] = sld_flat6(); |
---|
| 94 | dp[13] = sld_flat7(); |
---|
| 95 | dp[14] = sld_flat8(); |
---|
| 96 | dp[15] = sld_flat9(); |
---|
| 97 | dp[16] = sld_flat10(); |
---|
| 98 | |
---|
| 99 | dp[17] = thick_inter1(); |
---|
| 100 | dp[18] = thick_inter2(); |
---|
| 101 | dp[19] = thick_inter3(); |
---|
| 102 | dp[20] = thick_inter4(); |
---|
| 103 | dp[21] = thick_inter5(); |
---|
| 104 | dp[22] = thick_inter6(); |
---|
| 105 | dp[23] = thick_inter7(); |
---|
| 106 | dp[24] = thick_inter8(); |
---|
| 107 | dp[25] = thick_inter9(); |
---|
| 108 | dp[26] = thick_inter10(); |
---|
| 109 | |
---|
| 110 | dp[27] = thick_flat1(); |
---|
| 111 | dp[28] = thick_flat2(); |
---|
| 112 | dp[29] = thick_flat3(); |
---|
| 113 | dp[30] = thick_flat4(); |
---|
| 114 | dp[31] = thick_flat5(); |
---|
| 115 | dp[32] = thick_flat6(); |
---|
| 116 | dp[33] = thick_flat7(); |
---|
| 117 | dp[34] = thick_flat8(); |
---|
| 118 | dp[35] = thick_flat9(); |
---|
| 119 | dp[36] = thick_flat10(); |
---|
| 120 | |
---|
| 121 | dp[37] = func_inter1(); |
---|
| 122 | dp[38] = func_inter2(); |
---|
| 123 | dp[39] = func_inter3(); |
---|
| 124 | dp[40] = func_inter4(); |
---|
| 125 | dp[41] = func_inter5(); |
---|
| 126 | dp[42] = func_inter6(); |
---|
| 127 | dp[43] = func_inter7(); |
---|
| 128 | dp[44] = func_inter8(); |
---|
| 129 | dp[45] = func_inter9(); |
---|
| 130 | dp[46] = func_inter10(); |
---|
| 131 | |
---|
| 132 | // Get the dispersion points for the radius |
---|
| 133 | //vector<WeightPoint> weights_thick; |
---|
| 134 | //thick_inter0.get_weights(weights_thick_inter0); |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | return re_kernel(dp,q); |
---|
| 138 | } |
---|
| 139 | |
---|
| 140 | /** |
---|
| 141 | * Function to evaluate 2D NR function |
---|
| 142 | * @param q_x: value of Q along x |
---|
| 143 | * @param q_y: value of Q along y |
---|
| 144 | * @return: function value |
---|
| 145 | */ |
---|
| 146 | double ReflModel :: operator()(double qx, double qy) { |
---|
[aae7a8d] | 147 | // For 2D set qy as q, ignoring qx. |
---|
| 148 | double q = qy;//sqrt(qx*qx + qy*qy); |
---|
| 149 | if (q < 0.0){ |
---|
| 150 | return 0.0; |
---|
| 151 | } |
---|
[35aface] | 152 | return (*this).operator()(q); |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | /** |
---|
| 156 | * Function to evaluate 2D NR function |
---|
| 157 | * @param pars: parameters of the sphere |
---|
| 158 | * @param q: q-value |
---|
| 159 | * @param phi: angle phi |
---|
| 160 | * @return: function value |
---|
| 161 | */ |
---|
| 162 | double ReflModel :: evaluate_rphi(double q, double phi) { |
---|
| 163 | return (*this).operator()(q); |
---|
| 164 | } |
---|
| 165 | |
---|
| 166 | /** |
---|
| 167 | * Function to calculate effective radius |
---|
| 168 | * @return: effective radius value |
---|
| 169 | */ |
---|
| 170 | double ReflModel :: calculate_ER() { |
---|
| 171 | //NOT implemented yet!!! |
---|
| 172 | } |
---|