[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 | |
---|
[becded3] | 29 | static double |
---|
| 30 | Iq(double q, |
---|
[44bd2be] | 31 | double core_sld, |
---|
| 32 | double arim_sld, |
---|
| 33 | double brim_sld, |
---|
| 34 | double crim_sld, |
---|
| 35 | double solvent_sld, |
---|
[2222134] | 36 | double length_a, |
---|
| 37 | double length_b, |
---|
| 38 | double length_c, |
---|
| 39 | double thick_rim_a, |
---|
| 40 | double thick_rim_b, |
---|
| 41 | double thick_rim_c) |
---|
[44bd2be] | 42 | { |
---|
[3a1fc7d] | 43 | // Code converted from functions CSPPKernel and CSParallelepiped in libCylinder.c |
---|
[44bd2be] | 44 | // Did not understand the code completely, it should be rechecked (Miguel Gonzalez) |
---|
[e077231] | 45 | // Code is rewritten, the code is compliant with Diva Singh's thesis now (Dirk Honecker) |
---|
| 46 | // Code rewritten; cross checked against hollow rectangular prism and realspace (PAK) |
---|
[2a0b2b1] | 47 | |
---|
[4493288] | 48 | const double half_q = 0.5*q; |
---|
[2a0b2b1] | 49 | |
---|
[4493288] | 50 | const double tA = length_a + 2.0*thick_rim_a; |
---|
| 51 | const double tB = length_b + 2.0*thick_rim_b; |
---|
| 52 | const double tC = length_c + 2.0*thick_rim_c; |
---|
[14838a3] | 53 | |
---|
[4493288] | 54 | // Scale factors |
---|
[3a1fc7d] | 55 | const double dr0 = (core_sld-solvent_sld); |
---|
| 56 | const double drA = (arim_sld-solvent_sld); |
---|
| 57 | const double drB = (brim_sld-solvent_sld); |
---|
| 58 | const double drC = (crim_sld-solvent_sld); |
---|
[14838a3] | 59 | |
---|
| 60 | // outer integral (with gauss points), integration limits = 0, 1 |
---|
[dbf1a60] | 61 | // substitute d_cos_alpha for sin_alpha d_alpha |
---|
[3a1fc7d] | 62 | double outer_sum = 0; //initialize integral |
---|
[74768cb] | 63 | for( int i=0; i<GAUSS_N; i++) { |
---|
[a261a83] | 64 | const double cos_alpha = 0.5 * ( GAUSS_Z[i] + 1.0 ); |
---|
[4493288] | 65 | const double mu = half_q * sqrt(1.0-cos_alpha*cos_alpha); |
---|
| 66 | const double siC = length_c * sas_sinx_x(length_c * cos_alpha * half_q); |
---|
| 67 | const double siCt = tC * sas_sinx_x(tC * cos_alpha * half_q); |
---|
[dbf1a60] | 68 | |
---|
| 69 | // inner integral (with gauss points), integration limits = 0, 1 |
---|
| 70 | // substitute beta = PI/2 u (so 2/PI * d_(PI/2 * beta) = d_beta) |
---|
[3a1fc7d] | 71 | double inner_sum = 0.0; |
---|
[74768cb] | 72 | for(int j=0; j<GAUSS_N; j++) { |
---|
[dbf1a60] | 73 | const double u = 0.5 * ( GAUSS_Z[j] + 1.0 ); |
---|
[4493288] | 74 | double sin_beta, cos_beta; |
---|
[dbf1a60] | 75 | SINCOS(M_PI_2*u, sin_beta, cos_beta); |
---|
[4493288] | 76 | const double siA = length_a * sas_sinx_x(length_a * mu * sin_beta); |
---|
| 77 | const double siB = length_b * sas_sinx_x(length_b * mu * cos_beta); |
---|
| 78 | const double siAt = tA * sas_sinx_x(tA * mu * sin_beta); |
---|
| 79 | const double siBt = tB * sas_sinx_x(tB * mu * cos_beta); |
---|
[3a1fc7d] | 80 | |
---|
[fc0b7aa] | 81 | #if OVERLAPPING |
---|
[4493288] | 82 | const double f = dr0*siA*siB*siC |
---|
| 83 | + drA*(siAt-siA)*siB*siC |
---|
| 84 | + drB*siAt*(siBt-siB)*siC |
---|
| 85 | + drC*siAt*siBt*(siCt-siC); |
---|
[fc0b7aa] | 86 | #else |
---|
[4493288] | 87 | const double f = dr0*siA*siB*siC |
---|
| 88 | + drA*(siAt-siA)*siB*siC |
---|
| 89 | + drB*siA*(siBt-siB)*siC |
---|
| 90 | + drC*siA*siB*(siCt-siC); |
---|
[fc0b7aa] | 91 | #endif |
---|
| 92 | |
---|
[74768cb] | 93 | inner_sum += GAUSS_W[j] * f * f; |
---|
[44bd2be] | 94 | } |
---|
[dbf1a60] | 95 | // now complete change of inner integration variable (1-0)/(1-(-1))= 0.5 |
---|
[3a1fc7d] | 96 | inner_sum *= 0.5; |
---|
[14838a3] | 97 | // now sum up the outer integral |
---|
[74768cb] | 98 | outer_sum += GAUSS_W[i] * inner_sum; |
---|
[44bd2be] | 99 | } |
---|
[dbf1a60] | 100 | // now complete change of outer integration variable (1-0)/(1-(-1))= 0.5 |
---|
[3a1fc7d] | 101 | outer_sum *= 0.5; |
---|
[44bd2be] | 102 | |
---|
[14838a3] | 103 | //convert from [1e-12 A-1] to [cm-1] |
---|
[3a1fc7d] | 104 | return 1.0e-4 * outer_sum; |
---|
[44bd2be] | 105 | } |
---|
| 106 | |
---|
[becded3] | 107 | static double |
---|
[108e70e] | 108 | Iqabc(double qa, double qb, double qc, |
---|
[44bd2be] | 109 | double core_sld, |
---|
| 110 | double arim_sld, |
---|
| 111 | double brim_sld, |
---|
| 112 | double crim_sld, |
---|
| 113 | double solvent_sld, |
---|
[2222134] | 114 | double length_a, |
---|
| 115 | double length_b, |
---|
| 116 | double length_c, |
---|
| 117 | double thick_rim_a, |
---|
| 118 | double thick_rim_b, |
---|
[becded3] | 119 | double thick_rim_c) |
---|
[44bd2be] | 120 | { |
---|
[14838a3] | 121 | // cspkernel in csparallelepiped recoded here |
---|
| 122 | const double dr0 = core_sld-solvent_sld; |
---|
| 123 | const double drA = arim_sld-solvent_sld; |
---|
| 124 | const double drB = brim_sld-solvent_sld; |
---|
| 125 | const double drC = crim_sld-solvent_sld; |
---|
| 126 | |
---|
[fc0b7aa] | 127 | const double tA = length_a + 2.0*thick_rim_a; |
---|
| 128 | const double tB = length_b + 2.0*thick_rim_b; |
---|
| 129 | const double tC = length_c + 2.0*thick_rim_c; |
---|
[4493288] | 130 | const double siA = length_a*sas_sinx_x(0.5*length_a*qa); |
---|
| 131 | const double siB = length_b*sas_sinx_x(0.5*length_b*qb); |
---|
| 132 | const double siC = length_c*sas_sinx_x(0.5*length_c*qc); |
---|
| 133 | const double siAt = tA*sas_sinx_x(0.5*tA*qa); |
---|
| 134 | const double siBt = tB*sas_sinx_x(0.5*tB*qb); |
---|
| 135 | const double siCt = tC*sas_sinx_x(0.5*tC*qc); |
---|
[fc0b7aa] | 136 | |
---|
| 137 | #if OVERLAPPING |
---|
[4493288] | 138 | const double f = dr0*siA*siB*siC |
---|
| 139 | + drA*(siAt-siA)*siB*siC |
---|
| 140 | + drB*siAt*(siBt-siB)*siC |
---|
| 141 | + drC*siAt*siBt*(siCt-siC); |
---|
[fc0b7aa] | 142 | #else |
---|
[4493288] | 143 | const double f = dr0*siA*siB*siC |
---|
| 144 | + drA*(siAt-siA)*siB*siC |
---|
| 145 | + drB*siA*(siBt-siB)*siC |
---|
| 146 | + drC*siA*siB*(siCt-siC); |
---|
[fc0b7aa] | 147 | #endif |
---|
[2a0b2b1] | 148 | |
---|
[44bd2be] | 149 | return 1.0e-4 * f * f; |
---|
| 150 | } |
---|