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