[fc0b7aa] | 1 | // Set OVERLAPPING to 1 in order to fill in the edges of the box, with |
---|
| 2 | // c endcaps and b overlapping a. With the proper choice of parameters, |
---|
| 3 | // (setting rim slds to sld, core sld to solvent, rim thickness to thickness |
---|
| 4 | // and subtracting 2*thickness from length, this should match the hollow |
---|
| 5 | // rectangular prism.) Set it to 0 for the documented behaviour. |
---|
| 6 | #define OVERLAPPING 0 |
---|
[becded3] | 7 | static double |
---|
| 8 | form_volume(double length_a, double length_b, double length_c, |
---|
| 9 | double thick_rim_a, double thick_rim_b, double thick_rim_c) |
---|
[44bd2be] | 10 | { |
---|
[fc0b7aa] | 11 | return |
---|
| 12 | #if OVERLAPPING |
---|
| 13 | // Hollow rectangular prism only includes the volume of the shell |
---|
| 14 | // so uncomment the next line when comparing. Solid rectangular |
---|
| 15 | // prism, or parallelepiped want filled cores, so comment when |
---|
| 16 | // comparing. |
---|
| 17 | //-length_a * length_b * length_c + |
---|
| 18 | (length_a + 2.0*thick_rim_a) * |
---|
| 19 | (length_b + 2.0*thick_rim_b) * |
---|
| 20 | (length_c + 2.0*thick_rim_c); |
---|
| 21 | #else |
---|
| 22 | length_a * length_b * length_c + |
---|
| 23 | 2.0 * thick_rim_a * length_b * length_c + |
---|
| 24 | 2.0 * length_a * thick_rim_b * length_c + |
---|
| 25 | 2.0 * length_a * length_b * thick_rim_c; |
---|
| 26 | #endif |
---|
[44bd2be] | 27 | } |
---|
| 28 | |
---|
[d277229] | 29 | static double |
---|
| 30 | radius_from_volume(double length_a, double length_b, double length_c, |
---|
| 31 | double thick_rim_a, double thick_rim_b, double thick_rim_c) |
---|
| 32 | { |
---|
[ee60aa7] | 33 | const double volume = form_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); |
---|
| 34 | return cbrt(volume/M_4PI_3); |
---|
[d277229] | 35 | } |
---|
| 36 | |
---|
| 37 | static double |
---|
| 38 | radius_from_crosssection(double length_a, double length_b, double thick_rim_a, double thick_rim_b) |
---|
| 39 | { |
---|
| 40 | const double area_xsec_paral = length_a*length_b + 2.0*thick_rim_a*length_b + 2.0*thick_rim_b*length_a; |
---|
| 41 | return sqrt(area_xsec_paral/M_PI); |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | static double |
---|
| 45 | effective_radius(int mode, double length_a, double length_b, double length_c, |
---|
| 46 | double thick_rim_a, double thick_rim_b, double thick_rim_c) |
---|
| 47 | { |
---|
[ee60aa7] | 48 | switch (mode) { |
---|
[d42dd4a] | 49 | default: |
---|
[ee60aa7] | 50 | case 1: // equivalent sphere |
---|
[d277229] | 51 | return radius_from_volume(length_a, length_b, length_c, thick_rim_a, thick_rim_b, thick_rim_c); |
---|
[ee60aa7] | 52 | case 2: // half outer length a |
---|
[a94046f] | 53 | return 0.5 * length_a + thick_rim_a; |
---|
[ee60aa7] | 54 | case 3: // half outer length b |
---|
[a94046f] | 55 | return 0.5 * length_b + thick_rim_b; |
---|
[ee60aa7] | 56 | case 4: // half outer length c |
---|
[a94046f] | 57 | return 0.5 * length_c + thick_rim_c; |
---|
[ee60aa7] | 58 | case 5: // equivalent circular cross-section |
---|
[d277229] | 59 | return radius_from_crosssection(length_a, length_b, thick_rim_a, thick_rim_b); |
---|
[ee60aa7] | 60 | case 6: // half outer ab diagonal |
---|
[a94046f] | 61 | return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b)); |
---|
[ee60aa7] | 62 | case 7: // half outer diagonal |
---|
[a94046f] | 63 | return 0.5*sqrt(square(length_a+ 2.0*thick_rim_a) + square(length_b+ 2.0*thick_rim_b) + square(length_c+ 2.0*thick_rim_c)); |
---|
[d277229] | 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
[71b751d] | 67 | static void |
---|
| 68 | Fq(double q, |
---|
| 69 | double *F1, |
---|
| 70 | double *F2, |
---|
[44bd2be] | 71 | double core_sld, |
---|
| 72 | double arim_sld, |
---|
| 73 | double brim_sld, |
---|
| 74 | double crim_sld, |
---|
| 75 | double solvent_sld, |
---|
[2222134] | 76 | double length_a, |
---|
| 77 | double length_b, |
---|
| 78 | double length_c, |
---|
| 79 | double thick_rim_a, |
---|
| 80 | double thick_rim_b, |
---|
| 81 | double thick_rim_c) |
---|
[44bd2be] | 82 | { |
---|
[3a1fc7d] | 83 | // Code converted from functions CSPPKernel and CSParallelepiped in libCylinder.c |
---|
[44bd2be] | 84 | // Did not understand the code completely, it should be rechecked (Miguel Gonzalez) |
---|
[e077231] | 85 | // Code is rewritten, the code is compliant with Diva Singh's thesis now (Dirk Honecker) |
---|
| 86 | // Code rewritten; cross checked against hollow rectangular prism and realspace (PAK) |
---|
[2a0b2b1] | 87 | |
---|
[4493288] | 88 | const double half_q = 0.5*q; |
---|
[2a0b2b1] | 89 | |
---|
[4493288] | 90 | const double tA = length_a + 2.0*thick_rim_a; |
---|
| 91 | const double tB = length_b + 2.0*thick_rim_b; |
---|
| 92 | const double tC = length_c + 2.0*thick_rim_c; |
---|
[14838a3] | 93 | |
---|
[4493288] | 94 | // Scale factors |
---|
[3a1fc7d] | 95 | const double dr0 = (core_sld-solvent_sld); |
---|
| 96 | const double drA = (arim_sld-solvent_sld); |
---|
| 97 | const double drB = (brim_sld-solvent_sld); |
---|
| 98 | const double drC = (crim_sld-solvent_sld); |
---|
[14838a3] | 99 | |
---|
| 100 | // outer integral (with gauss points), integration limits = 0, 1 |
---|
[dbf1a60] | 101 | // substitute d_cos_alpha for sin_alpha d_alpha |
---|
[71b751d] | 102 | double outer_sum_F1 = 0; //initialize integral |
---|
| 103 | double outer_sum_F2 = 0; //initialize integral |
---|
[74768cb] | 104 | for( int i=0; i<GAUSS_N; i++) { |
---|
[a261a83] | 105 | const double cos_alpha = 0.5 * ( GAUSS_Z[i] + 1.0 ); |
---|
[4493288] | 106 | const double mu = half_q * sqrt(1.0-cos_alpha*cos_alpha); |
---|
| 107 | const double siC = length_c * sas_sinx_x(length_c * cos_alpha * half_q); |
---|
| 108 | const double siCt = tC * sas_sinx_x(tC * cos_alpha * half_q); |
---|
[dbf1a60] | 109 | |
---|
| 110 | // inner integral (with gauss points), integration limits = 0, 1 |
---|
| 111 | // substitute beta = PI/2 u (so 2/PI * d_(PI/2 * beta) = d_beta) |
---|
[71b751d] | 112 | double inner_sum_F1 = 0.0; |
---|
| 113 | double inner_sum_F2 = 0.0; |
---|
[74768cb] | 114 | for(int j=0; j<GAUSS_N; j++) { |
---|
[dbf1a60] | 115 | const double u = 0.5 * ( GAUSS_Z[j] + 1.0 ); |
---|
[4493288] | 116 | double sin_beta, cos_beta; |
---|
[dbf1a60] | 117 | SINCOS(M_PI_2*u, sin_beta, cos_beta); |
---|
[4493288] | 118 | const double siA = length_a * sas_sinx_x(length_a * mu * sin_beta); |
---|
| 119 | const double siB = length_b * sas_sinx_x(length_b * mu * cos_beta); |
---|
| 120 | const double siAt = tA * sas_sinx_x(tA * mu * sin_beta); |
---|
| 121 | const double siBt = tB * sas_sinx_x(tB * mu * cos_beta); |
---|
[3a1fc7d] | 122 | |
---|
[fc0b7aa] | 123 | #if OVERLAPPING |
---|
[4493288] | 124 | const double f = dr0*siA*siB*siC |
---|
| 125 | + drA*(siAt-siA)*siB*siC |
---|
| 126 | + drB*siAt*(siBt-siB)*siC |
---|
| 127 | + drC*siAt*siBt*(siCt-siC); |
---|
[fc0b7aa] | 128 | #else |
---|
[4493288] | 129 | const double f = dr0*siA*siB*siC |
---|
| 130 | + drA*(siAt-siA)*siB*siC |
---|
| 131 | + drB*siA*(siBt-siB)*siC |
---|
| 132 | + drC*siA*siB*(siCt-siC); |
---|
[fc0b7aa] | 133 | #endif |
---|
| 134 | |
---|
[71b751d] | 135 | inner_sum_F1 += GAUSS_W[j] * f; |
---|
| 136 | inner_sum_F2 += GAUSS_W[j] * f * f; |
---|
[44bd2be] | 137 | } |
---|
[dbf1a60] | 138 | // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 |
---|
[71b751d] | 139 | // and sum up the outer integral |
---|
| 140 | outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * 0.5; |
---|
| 141 | outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * 0.5; |
---|
[44bd2be] | 142 | } |
---|
[dbf1a60] | 143 | // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 |
---|
[71b751d] | 144 | outer_sum_F1 *= 0.5; |
---|
| 145 | outer_sum_F2 *= 0.5; |
---|
[44bd2be] | 146 | |
---|
[14838a3] | 147 | //convert from [1e-12 A-1] to [cm-1] |
---|
[71b751d] | 148 | *F1 = 1.0e-2 * outer_sum_F1; |
---|
| 149 | *F2 = 1.0e-4 * outer_sum_F2; |
---|
[44bd2be] | 150 | } |
---|
| 151 | |
---|
[becded3] | 152 | static double |
---|
[108e70e] | 153 | Iqabc(double qa, double qb, double qc, |
---|
[44bd2be] | 154 | double core_sld, |
---|
| 155 | double arim_sld, |
---|
| 156 | double brim_sld, |
---|
| 157 | double crim_sld, |
---|
| 158 | double solvent_sld, |
---|
[2222134] | 159 | double length_a, |
---|
| 160 | double length_b, |
---|
| 161 | double length_c, |
---|
| 162 | double thick_rim_a, |
---|
| 163 | double thick_rim_b, |
---|
[becded3] | 164 | double thick_rim_c) |
---|
[44bd2be] | 165 | { |
---|
[14838a3] | 166 | // cspkernel in csparallelepiped recoded here |
---|
| 167 | const double dr0 = core_sld-solvent_sld; |
---|
| 168 | const double drA = arim_sld-solvent_sld; |
---|
| 169 | const double drB = brim_sld-solvent_sld; |
---|
| 170 | const double drC = crim_sld-solvent_sld; |
---|
| 171 | |
---|
[fc0b7aa] | 172 | const double tA = length_a + 2.0*thick_rim_a; |
---|
| 173 | const double tB = length_b + 2.0*thick_rim_b; |
---|
| 174 | const double tC = length_c + 2.0*thick_rim_c; |
---|
[4493288] | 175 | const double siA = length_a*sas_sinx_x(0.5*length_a*qa); |
---|
| 176 | const double siB = length_b*sas_sinx_x(0.5*length_b*qb); |
---|
| 177 | const double siC = length_c*sas_sinx_x(0.5*length_c*qc); |
---|
| 178 | const double siAt = tA*sas_sinx_x(0.5*tA*qa); |
---|
| 179 | const double siBt = tB*sas_sinx_x(0.5*tB*qb); |
---|
| 180 | const double siCt = tC*sas_sinx_x(0.5*tC*qc); |
---|
[fc0b7aa] | 181 | |
---|
| 182 | #if OVERLAPPING |
---|
[4493288] | 183 | const double f = dr0*siA*siB*siC |
---|
| 184 | + drA*(siAt-siA)*siB*siC |
---|
| 185 | + drB*siAt*(siBt-siB)*siC |
---|
| 186 | + drC*siAt*siBt*(siCt-siC); |
---|
[fc0b7aa] | 187 | #else |
---|
[4493288] | 188 | const double f = dr0*siA*siB*siC |
---|
| 189 | + drA*(siAt-siA)*siB*siC |
---|
| 190 | + drB*siA*(siBt-siB)*siC |
---|
| 191 | + drC*siA*siB*(siCt-siC); |
---|
[fc0b7aa] | 192 | #endif |
---|
[2a0b2b1] | 193 | |
---|
[44bd2be] | 194 | return 1.0e-4 * f * f; |
---|
| 195 | } |
---|