[129bdc4] | 1 | // NOTE that "length" here is the full height of the core! |
---|
| 2 | static double |
---|
| 3 | form_volume(double r_minor, |
---|
| 4 | double x_core, |
---|
| 5 | double thick_rim, |
---|
| 6 | double thick_face, |
---|
| 7 | double length) |
---|
| 8 | { |
---|
[74768cb] | 9 | return M_PI*( (r_minor + thick_rim)*(r_minor*x_core + thick_rim)* length + |
---|
[129bdc4] | 10 | square(r_minor)*x_core*2.0*thick_face ); |
---|
| 11 | } |
---|
| 12 | |
---|
[d277229] | 13 | static double |
---|
| 14 | radius_from_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
| 15 | { |
---|
| 16 | const double volume_bicelle = form_volume(r_minor, x_core, thick_rim,thick_face,length); |
---|
| 17 | return cbrt(0.75*volume_bicelle/M_PI); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | static double |
---|
| 21 | radius_from_diagonal(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
| 22 | { |
---|
| 23 | const double radius_max = (x_core < 1.0 ? r_minor : x_core*r_minor); |
---|
| 24 | const double radius_max_tot = radius_max + thick_rim; |
---|
| 25 | const double length_tot = length + 2.0*thick_face; |
---|
| 26 | return sqrt(radius_max_tot*radius_max_tot + 0.25*length_tot*length_tot); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | static double |
---|
| 30 | effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
| 31 | { |
---|
| 32 | if (mode == 1) { |
---|
| 33 | return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); |
---|
| 34 | } else if (mode == 2) { |
---|
| 35 | return 0.5*r_minor*(1.0 + x_core) + thick_rim; |
---|
| 36 | } else if (mode == 3) { |
---|
| 37 | return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); |
---|
| 38 | } else if (mode == 4) { |
---|
| 39 | return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); |
---|
| 40 | } else if (mode ==5) { |
---|
| 41 | return 0.5*length + thick_face; |
---|
| 42 | } else { |
---|
| 43 | return radius_from_diagonal(r_minor,x_core,thick_rim,thick_face,length); |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | |
---|
[71b751d] | 47 | static void |
---|
| 48 | Fq(double q, |
---|
| 49 | double *F1, |
---|
| 50 | double *F2, |
---|
[129bdc4] | 51 | double r_minor, |
---|
| 52 | double x_core, |
---|
| 53 | double thick_rim, |
---|
| 54 | double thick_face, |
---|
| 55 | double length, |
---|
| 56 | double rhoc, |
---|
| 57 | double rhoh, |
---|
| 58 | double rhor, |
---|
| 59 | double rhosolv, |
---|
| 60 | double sigma) |
---|
| 61 | { |
---|
| 62 | // core_shell_bicelle_elliptical_belt, RKH 5th Oct 2017, core_shell_bicelle_elliptical |
---|
| 63 | // tested briefly against limiting cases of cylinder, hollow cylinder & elliptical cylinder models |
---|
| 64 | // const double uplim = M_PI_4; |
---|
| 65 | const double halfheight = 0.5*length; |
---|
| 66 | //const double va = 0.0; |
---|
| 67 | //const double vb = 1.0; |
---|
| 68 | // inner integral limits |
---|
| 69 | //const double vaj=0.0; |
---|
| 70 | //const double vbj=M_PI; |
---|
| 71 | |
---|
| 72 | const double r_major = r_minor * x_core; |
---|
| 73 | const double r2A = 0.5*(square(r_major) + square(r_minor)); |
---|
| 74 | const double r2B = 0.5*(square(r_major) - square(r_minor)); |
---|
[71b751d] | 75 | const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight); |
---|
| 76 | const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight; |
---|
| 77 | const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); |
---|
[129bdc4] | 78 | // dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face, |
---|
[71b751d] | 79 | const double dr1 = vol1*(-rhor - rhoh + rhoc + rhosolv); |
---|
| 80 | const double dr2 = vol2*(rhor-rhosolv); |
---|
| 81 | const double dr3 = vol3*(rhoh-rhosolv); |
---|
| 82 | |
---|
[129bdc4] | 83 | //initialize integral |
---|
[71b751d] | 84 | double outer_total_F1 = 0.0; |
---|
| 85 | double outer_total_F2 = 0.0; |
---|
[74768cb] | 86 | for(int i=0;i<GAUSS_N;i++) { |
---|
[129bdc4] | 87 | //setup inner integral over the ellipsoidal cross-section |
---|
| 88 | // since we generate these lots of times, why not store them somewhere? |
---|
[71b751d] | 89 | //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; |
---|
| 90 | const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0; |
---|
| 91 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
| 92 | const double qab = q*sin_theta; |
---|
| 93 | const double qc = q*cos_theta; |
---|
| 94 | const double si1 = sas_sinx_x(halfheight*qc); |
---|
| 95 | const double si2 = sas_sinx_x((halfheight+thick_face)*qc); |
---|
| 96 | double inner_total_F1 = 0; |
---|
| 97 | double inner_total_F2 = 0; |
---|
[74768cb] | 98 | for(int j=0;j<GAUSS_N;j++) { |
---|
[129bdc4] | 99 | //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe) |
---|
[74768cb] | 100 | //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; |
---|
| 101 | const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2; |
---|
[129bdc4] | 102 | const double rr = sqrt(r2A - r2B*cos(beta)); |
---|
[71b751d] | 103 | const double be1 = sas_2J1x_x(rr*qab); |
---|
| 104 | const double be2 = sas_2J1x_x((rr+thick_rim)*qab); |
---|
| 105 | const double f = dr1*si1*be1 + dr2*si1*be2 + dr3*si2*be1; |
---|
| 106 | |
---|
| 107 | inner_total_F1 += GAUSS_W[j] * f; |
---|
| 108 | inner_total_F2 += GAUSS_W[j] * f * f; |
---|
[129bdc4] | 109 | } |
---|
| 110 | //now calculate outer integral |
---|
[71b751d] | 111 | outer_total_F1 += GAUSS_W[i] * inner_total_F1; |
---|
| 112 | outer_total_F2 += GAUSS_W[i] * inner_total_F2; |
---|
[129bdc4] | 113 | } |
---|
[71b751d] | 114 | // now complete change of integration variables (1-0)/(1-(-1))= 0.5 |
---|
| 115 | outer_total_F1 *= 0.25; |
---|
| 116 | outer_total_F2 *= 0.25; |
---|
[129bdc4] | 117 | |
---|
[71b751d] | 118 | //convert from [1e-12 A-1] to [cm-1] |
---|
| 119 | *F1 = 1e-2*outer_total_F1*exp(-0.25*square(q*sigma)); |
---|
| 120 | *F2 = 1e-4*outer_total_F2*exp(-0.5*square(q*sigma)); |
---|
[129bdc4] | 121 | } |
---|
| 122 | |
---|
| 123 | static double |
---|
[108e70e] | 124 | Iqabc(double qa, double qb, double qc, |
---|
[129bdc4] | 125 | double r_minor, |
---|
| 126 | double x_core, |
---|
| 127 | double thick_rim, |
---|
| 128 | double thick_face, |
---|
| 129 | double length, |
---|
| 130 | double rhoc, |
---|
| 131 | double rhoh, |
---|
| 132 | double rhor, |
---|
| 133 | double rhosolv, |
---|
| 134 | double sigma) |
---|
| 135 | { |
---|
[82592da] | 136 | // integrated 2d seems to match 1d reasonably well, except perhaps at very high Q |
---|
[129bdc4] | 137 | // Vol1,2,3 and dr1,2,3 are now for Vcore, Vcore+rim, Vcore+face, |
---|
| 138 | const double dr1 = -rhor - rhoh + rhoc + rhosolv; |
---|
| 139 | const double dr2 = rhor-rhosolv; |
---|
| 140 | const double dr3 = rhoh-rhosolv; |
---|
| 141 | const double r_major = r_minor*x_core; |
---|
| 142 | const double halfheight = 0.5*length; |
---|
| 143 | const double vol1 = M_PI*r_minor*r_major*length; |
---|
| 144 | const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*halfheight; |
---|
| 145 | const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); |
---|
| 146 | |
---|
| 147 | // Compute effective radius in rotated coordinates |
---|
[82592da] | 148 | const double qr_hat = sqrt(square(r_major*qb) + square(r_minor*qa)); |
---|
[129bdc4] | 149 | // does this need to be changed for the "missing corners" where there there is no "belt" ? |
---|
[82592da] | 150 | const double qrshell_hat = sqrt(square((r_major+thick_rim)*qb) |
---|
| 151 | + square((r_minor+thick_rim)*qa)); |
---|
[129bdc4] | 152 | const double be1 = sas_2J1x_x( qr_hat ); |
---|
| 153 | const double be2 = sas_2J1x_x( qrshell_hat ); |
---|
| 154 | const double si1 = sas_sinx_x( halfheight*qc ); |
---|
| 155 | const double si2 = sas_sinx_x( (halfheight + thick_face)*qc ); |
---|
[71b751d] | 156 | const double fq = vol1*dr1*si1*be1 + vol2*dr2*si1*be2 + vol3*dr3*si2*be1; |
---|
| 157 | const double atten = exp(-0.5*(qa*qa + qb*qb + qc*qc)*(sigma*sigma)); |
---|
| 158 | return 1.0e-4 * fq*fq * atten; |
---|
[129bdc4] | 159 | } |
---|