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