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