[aea2e2a] | 1 | //#define INVALID(v) (v.radius_core >= v.radius) |
---|
| 2 | |
---|
[5bddd89] | 3 | static double |
---|
[e44432d] | 4 | shell_volume(double radius, double thickness, double length) |
---|
[ee60aa7] | 5 | { |
---|
[e44432d] | 6 | return M_PI*length*(square(radius+thickness) - radius*radius); |
---|
[ee60aa7] | 7 | } |
---|
| 8 | |
---|
[becded3] | 9 | static double |
---|
[5bddd89] | 10 | form_volume(double radius, double thickness, double length) |
---|
[aea2e2a] | 11 | { |
---|
[e44432d] | 12 | return M_PI*length*square(radius+thickness); |
---|
[aea2e2a] | 13 | } |
---|
| 14 | |
---|
[d277229] | 15 | static double |
---|
[99658f6] | 16 | radius_from_excluded_volume(double radius, double thickness, double length) |
---|
| 17 | { |
---|
| 18 | const double radius_tot = radius + thickness; |
---|
| 19 | return 0.5*cbrt(0.75*radius_tot*(2.0*radius_tot*length + (radius_tot + length)*(M_PI*radius_tot + length))); |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | static double |
---|
[d277229] | 23 | radius_from_volume(double radius, double thickness, double length) |
---|
| 24 | { |
---|
| 25 | const double volume_outer_cyl = M_PI*square(radius + thickness)*length; |
---|
[6d5601c] | 26 | return cbrt(volume_outer_cyl/M_4PI_3); |
---|
[d277229] | 27 | } |
---|
| 28 | |
---|
| 29 | static double |
---|
| 30 | radius_from_diagonal(double radius, double thickness, double length) |
---|
| 31 | { |
---|
| 32 | return sqrt(square(radius + thickness) + 0.25*square(length)); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | static double |
---|
[a34b811] | 36 | radius_effective(int mode, double radius, double thickness, double length) |
---|
[d277229] | 37 | { |
---|
[ee60aa7] | 38 | switch (mode) { |
---|
[d42dd4a] | 39 | default: |
---|
[99658f6] | 40 | case 1: // excluded volume |
---|
| 41 | return radius_from_excluded_volume(radius, thickness, length); |
---|
| 42 | case 2: // equivalent volume sphere |
---|
[d277229] | 43 | return radius_from_volume(radius, thickness, length); |
---|
[99658f6] | 44 | case 3: // outer radius |
---|
[d277229] | 45 | return radius + thickness; |
---|
[99658f6] | 46 | case 4: // half length |
---|
[d277229] | 47 | return 0.5*length; |
---|
[99658f6] | 48 | case 5: // half outer min dimension |
---|
[d277229] | 49 | return (radius + thickness < 0.5*length ? radius + thickness : 0.5*length); |
---|
[99658f6] | 50 | case 6: // half outer max dimension |
---|
[d277229] | 51 | return (radius + thickness > 0.5*length ? radius + thickness : 0.5*length); |
---|
[99658f6] | 52 | case 7: // half outer diagonal |
---|
[d277229] | 53 | return radius_from_diagonal(radius,thickness,length); |
---|
| 54 | } |
---|
| 55 | } |
---|
[aea2e2a] | 56 | |
---|
[e44432d] | 57 | static double |
---|
| 58 | _fq(double qab, double qc, |
---|
| 59 | double radius, double thickness, double length) |
---|
| 60 | { |
---|
| 61 | const double lam1 = sas_2J1x_x((radius+thickness)*qab); |
---|
| 62 | const double lam2 = sas_2J1x_x(radius*qab); |
---|
| 63 | const double gamma_sq = square(radius/(radius+thickness)); |
---|
| 64 | //Note: lim_{thickness -> 0} psi = sas_J0(radius*qab) |
---|
| 65 | //Note: lim_{radius -> 0} psi = sas_2J1x_x(thickness*qab) |
---|
| 66 | const double psi = (lam1 - gamma_sq*lam2)/(1.0 - gamma_sq); //SRK 10/19/00 |
---|
| 67 | const double t2 = sas_sinx_x(0.5*length*qc); |
---|
| 68 | return psi*t2; |
---|
| 69 | } |
---|
| 70 | |
---|
[71b751d] | 71 | static void |
---|
| 72 | Fq(double q, double *F1, double *F2, double radius, double thickness, double length, |
---|
[aea2e2a] | 73 | double sld, double solvent_sld) |
---|
| 74 | { |
---|
[5bddd89] | 75 | const double lower = 0.0; |
---|
[2a0b2b1] | 76 | const double upper = 1.0; //limits of numerical integral |
---|
[5bddd89] | 77 | |
---|
[71b751d] | 78 | double total_F1 = 0.0; //initialize intergral |
---|
| 79 | double total_F2 = 0.0; |
---|
[74768cb] | 80 | for (int i=0;i<GAUSS_N;i++) { |
---|
| 81 | const double cos_theta = 0.5*( GAUSS_Z[i] * (upper-lower) + lower + upper ); |
---|
[2a0b2b1] | 82 | const double sin_theta = sqrt(1.0 - cos_theta*cos_theta); |
---|
| 83 | const double form = _fq(q*sin_theta, q*cos_theta, |
---|
| 84 | radius, thickness, length); |
---|
[71b751d] | 85 | total_F1 += GAUSS_W[i] * form; |
---|
| 86 | total_F2 += GAUSS_W[i] * form * form; |
---|
[aea2e2a] | 87 | } |
---|
[71b751d] | 88 | total_F1 *= 0.5*(upper-lower); |
---|
| 89 | total_F2 *= 0.5*(upper-lower); |
---|
[e44432d] | 90 | const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length); |
---|
[71b751d] | 91 | *F1 = 1e-2 * s * total_F1; |
---|
| 92 | *F2 = 1e-4 * s*s * total_F2; |
---|
[5bddd89] | 93 | } |
---|
[aea2e2a] | 94 | |
---|
[71b751d] | 95 | |
---|
[becded3] | 96 | static double |
---|
[108e70e] | 97 | Iqac(double qab, double qc, |
---|
[5bddd89] | 98 | double radius, double thickness, double length, |
---|
[becded3] | 99 | double sld, double solvent_sld) |
---|
[5bddd89] | 100 | { |
---|
[2a0b2b1] | 101 | const double form = _fq(qab, qc, radius, thickness, length); |
---|
[e44432d] | 102 | const double s = (sld - solvent_sld) * shell_volume(radius, thickness, length); |
---|
[71b751d] | 103 | return 1.0e-4*square(s * form); |
---|
[aea2e2a] | 104 | } |
---|