[fcb33e4] | 1 | // NOTE that "length" here is the full height of the core! |
---|
[44e8a93] | 2 | static double |
---|
| 3 | form_volume(double r_minor, |
---|
[becded3] | 4 | double x_core, |
---|
| 5 | double thick_rim, |
---|
| 6 | double thick_face, |
---|
| 7 | double length) |
---|
[fcb33e4] | 8 | { |
---|
[44e8a93] | 9 | return M_PI*(r_minor+thick_rim)*(r_minor*x_core+thick_rim)*(length+2.0*thick_face); |
---|
[fcb33e4] | 10 | } |
---|
| 11 | |
---|
[d277229] | 12 | static double |
---|
| 13 | radius_from_volume(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
| 14 | { |
---|
| 15 | const double volume_bicelle = form_volume(r_minor, x_core, thick_rim,thick_face,length); |
---|
| 16 | return cbrt(0.75*volume_bicelle/M_PI); |
---|
| 17 | } |
---|
| 18 | |
---|
| 19 | static double |
---|
| 20 | radius_from_diagonal(double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
| 21 | { |
---|
| 22 | const double radius_max = (x_core < 1.0 ? r_minor : x_core*r_minor); |
---|
| 23 | const double radius_max_tot = radius_max + thick_rim; |
---|
| 24 | const double length_tot = length + 2.0*thick_face; |
---|
| 25 | return sqrt(radius_max_tot*radius_max_tot + 0.25*length_tot*length_tot); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | static double |
---|
| 29 | effective_radius(int mode, double r_minor, double x_core, double thick_rim, double thick_face, double length) |
---|
| 30 | { |
---|
[ee60aa7] | 31 | switch (mode) { |
---|
| 32 | case 1: // equivalent sphere |
---|
[d277229] | 33 | return radius_from_volume(r_minor, x_core, thick_rim, thick_face, length); |
---|
[ee60aa7] | 34 | case 2: // outer rim average radius |
---|
[d277229] | 35 | return 0.5*r_minor*(1.0 + x_core) + thick_rim; |
---|
[ee60aa7] | 36 | case 3: // outer rim min radius |
---|
[d277229] | 37 | return (x_core < 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); |
---|
[ee60aa7] | 38 | case 4: // outer max radius |
---|
[d277229] | 39 | return (x_core > 1.0 ? x_core*r_minor+thick_rim : r_minor+thick_rim); |
---|
[ee60aa7] | 40 | case 5: // half outer thickness |
---|
[d277229] | 41 | return 0.5*length + thick_face; |
---|
[ee60aa7] | 42 | case 6: // half diagonal |
---|
[d277229] | 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, |
---|
[becded3] | 51 | double r_minor, |
---|
| 52 | double x_core, |
---|
| 53 | double thick_rim, |
---|
| 54 | double thick_face, |
---|
| 55 | double length, |
---|
| 56 | double sld_core, |
---|
| 57 | double sld_face, |
---|
| 58 | double sld_rim, |
---|
| 59 | double sld_solvent) |
---|
[fcb33e4] | 60 | { |
---|
| 61 | // core_shell_bicelle_elliptical, RKH Dec 2016, based on elliptical_cylinder and core_shell_bicelle |
---|
[dedcf34] | 62 | // tested against limiting cases of cylinder, elliptical_cylinder, stacked_discs, and core_shell_bicelle |
---|
[fcb33e4] | 63 | const double halfheight = 0.5*length; |
---|
[44e8a93] | 64 | const double r_major = r_minor * x_core; |
---|
[dedcf34] | 65 | const double r2A = 0.5*(square(r_major) + square(r_minor)); |
---|
| 66 | const double r2B = 0.5*(square(r_major) - square(r_minor)); |
---|
[2a0b2b1] | 67 | const double vol1 = M_PI*r_minor*r_major*(2.0*halfheight); |
---|
| 68 | const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face); |
---|
| 69 | const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); |
---|
| 70 | const double dr1 = vol1*(sld_core-sld_face); |
---|
| 71 | const double dr2 = vol2*(sld_rim-sld_solvent); |
---|
| 72 | const double dr3 = vol3*(sld_face-sld_rim); |
---|
[fcb33e4] | 73 | |
---|
| 74 | //initialize integral |
---|
[71b751d] | 75 | double outer_total_F1 = 0.0; |
---|
| 76 | double outer_total_F2 = 0.0; |
---|
[74768cb] | 77 | for(int i=0;i<GAUSS_N;i++) { |
---|
[fcb33e4] | 78 | //setup inner integral over the ellipsoidal cross-section |
---|
[74768cb] | 79 | //const double cos_theta = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; |
---|
| 80 | const double cos_theta = ( GAUSS_Z[i] + 1.0 )/2.0; |
---|
[2a0b2b1] | 81 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
| 82 | const double qab = q*sin_theta; |
---|
| 83 | const double qc = q*cos_theta; |
---|
| 84 | const double si1 = sas_sinx_x(halfheight*qc); |
---|
| 85 | const double si2 = sas_sinx_x((halfheight+thick_face)*qc); |
---|
[71b751d] | 86 | double inner_total_F1 = 0; |
---|
| 87 | double inner_total_F2 = 0; |
---|
[74768cb] | 88 | for(int j=0;j<GAUSS_N;j++) { |
---|
[fcb33e4] | 89 | //76 gauss points for the inner integral (WAS 20 points,so this may make unecessarily slow, but playing safe) |
---|
[71b751d] | 90 | //const double beta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; |
---|
| 91 | const double beta = ( GAUSS_Z[j] +1.0)*M_PI_2; |
---|
| 92 | const double rr = sqrt(r2A - r2B*cos(beta)); |
---|
[2a0b2b1] | 93 | const double be1 = sas_2J1x_x(rr*qab); |
---|
| 94 | const double be2 = sas_2J1x_x((rr+thick_rim)*qab); |
---|
[71b751d] | 95 | const double f = dr1*si1*be1 + dr2*si2*be2 + dr3*si2*be1; |
---|
[2a0b2b1] | 96 | |
---|
[71b751d] | 97 | inner_total_F1 += GAUSS_W[j] * f; |
---|
| 98 | inner_total_F2 += GAUSS_W[j] * f * f; |
---|
[fcb33e4] | 99 | } |
---|
| 100 | //now calculate outer integral |
---|
[71b751d] | 101 | outer_total_F1 += GAUSS_W[i] * inner_total_F1; |
---|
| 102 | outer_total_F2 += GAUSS_W[i] * inner_total_F2; |
---|
[fcb33e4] | 103 | } |
---|
[71b751d] | 104 | // now complete change of integration variables (1-0)/(1-(-1))= 0.5 |
---|
| 105 | outer_total_F1 *= 0.25; |
---|
| 106 | outer_total_F2 *= 0.25; |
---|
[fcb33e4] | 107 | |
---|
[71b751d] | 108 | //convert from [1e-12 A-1] to [cm-1] |
---|
| 109 | *F1 = 1e-2*outer_total_F1; |
---|
| 110 | *F2 = 1e-4*outer_total_F2; |
---|
[fcb33e4] | 111 | } |
---|
| 112 | |
---|
[44e8a93] | 113 | static double |
---|
[108e70e] | 114 | Iqabc(double qa, double qb, double qc, |
---|
[becded3] | 115 | double r_minor, |
---|
| 116 | double x_core, |
---|
| 117 | double thick_rim, |
---|
| 118 | double thick_face, |
---|
| 119 | double length, |
---|
| 120 | double sld_core, |
---|
| 121 | double sld_face, |
---|
| 122 | double sld_rim, |
---|
| 123 | double sld_solvent) |
---|
[fcb33e4] | 124 | { |
---|
[2a0b2b1] | 125 | const double dr1 = sld_core-sld_face; |
---|
| 126 | const double dr2 = sld_rim-sld_solvent; |
---|
| 127 | const double dr3 = sld_face-sld_rim; |
---|
[44e8a93] | 128 | const double r_major = r_minor*x_core; |
---|
[fcb33e4] | 129 | const double halfheight = 0.5*length; |
---|
[44e8a93] | 130 | const double vol1 = M_PI*r_minor*r_major*length; |
---|
| 131 | const double vol2 = M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face); |
---|
| 132 | const double vol3 = M_PI*r_minor*r_major*2.0*(halfheight+thick_face); |
---|
[fcb33e4] | 133 | |
---|
[44e8a93] | 134 | // Compute effective radius in rotated coordinates |
---|
[82592da] | 135 | const double qr_hat = sqrt(square(r_major*qb) + square(r_minor*qa)); |
---|
| 136 | const double qrshell_hat = sqrt(square((r_major+thick_rim)*qb) |
---|
| 137 | + square((r_minor+thick_rim)*qa)); |
---|
[2a0b2b1] | 138 | const double be1 = sas_2J1x_x( qr_hat ); |
---|
| 139 | const double be2 = sas_2J1x_x( qrshell_hat ); |
---|
| 140 | const double si1 = sas_sinx_x( halfheight*qc ); |
---|
| 141 | const double si2 = sas_sinx_x( (halfheight + thick_face)*qc ); |
---|
| 142 | const double fq = vol1*dr1*si1*be1 + vol2*dr2*si2*be2 + vol3*dr3*si2*be1; |
---|
| 143 | return 1.0e-4 * fq*fq; |
---|
[fcb33e4] | 144 | } |
---|