[2a0b2b1] | 1 | static double |
---|
[251f54b] | 2 | form_volume(double radius_minor, double r_ratio, double length) |
---|
[a8b3cdb] | 3 | { |
---|
[a807206] | 4 | return M_PI * radius_minor * radius_minor * r_ratio * length; |
---|
[a8b3cdb] | 5 | } |
---|
| 6 | |
---|
[d277229] | 7 | static double |
---|
| 8 | radius_from_volume(double radius_minor, double r_ratio, double length) |
---|
| 9 | { |
---|
| 10 | const double volume_ellcyl = form_volume(radius_minor,r_ratio,length); |
---|
| 11 | return cbrt(0.75*volume_ellcyl/M_PI); |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | static double |
---|
| 15 | radius_from_min_dimension(double radius_minor, double r_ratio, double length) |
---|
| 16 | { |
---|
| 17 | const double rad_min = (r_ratio > 1.0 ? radius_minor : r_ratio*radius_minor); |
---|
| 18 | return (rad_min < length ? rad_min : length); |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | static double |
---|
| 22 | radius_from_max_dimension(double radius_minor, double r_ratio, double length) |
---|
| 23 | { |
---|
| 24 | const double rad_max = (r_ratio < 1.0 ? radius_minor : r_ratio*radius_minor); |
---|
| 25 | return (rad_max > length ? rad_max : length); |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | static double |
---|
| 29 | radius_from_diagonal(double radius_minor, double r_ratio, double length) |
---|
| 30 | { |
---|
| 31 | const double radius_max = (r_ratio > 1.0 ? radius_minor*r_ratio : radius_minor); |
---|
| 32 | return sqrt(radius_max*radius_max + 0.25*length*length); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | static double |
---|
| 36 | effective_radius(int mode, double radius_minor, double r_ratio, double length) |
---|
| 37 | { |
---|
| 38 | if (mode == 1) { |
---|
| 39 | return radius_from_volume(radius_minor, r_ratio, length); |
---|
| 40 | } else if (mode == 2) { |
---|
| 41 | return 0.5*radius_minor*(1.0 + r_ratio); |
---|
| 42 | } else if (mode == 3) { |
---|
| 43 | return (r_ratio > 1.0 ? radius_minor : r_ratio*radius_minor); |
---|
| 44 | } else if (mode == 4) { |
---|
| 45 | return (r_ratio < 1.0 ? radius_minor : r_ratio*radius_minor); |
---|
| 46 | } else if (mode == 5) { |
---|
| 47 | return sqrt(radius_minor*radius_minor*r_ratio); |
---|
| 48 | } else if (mode == 6) { |
---|
| 49 | return 0.5*length; |
---|
| 50 | } else if (mode == 7) { |
---|
| 51 | return radius_from_min_dimension(radius_minor,r_ratio,length); |
---|
| 52 | } else if (mode == 8) { |
---|
| 53 | return radius_from_max_dimension(radius_minor,r_ratio,length); |
---|
| 54 | } else { |
---|
| 55 | return radius_from_diagonal(radius_minor,r_ratio,length); |
---|
| 56 | } |
---|
| 57 | } |
---|
| 58 | |
---|
[71b751d] | 59 | static void |
---|
| 60 | Fq(double q, double *F1, double *F2, double radius_minor, double r_ratio, double length, |
---|
[68425bf] | 61 | double sld, double solvent_sld) |
---|
| 62 | { |
---|
[a8b3cdb] | 63 | // orientational average limits |
---|
[68425bf] | 64 | const double va = 0.0; |
---|
| 65 | const double vb = 1.0; |
---|
[a8b3cdb] | 66 | // inner integral limits |
---|
[68425bf] | 67 | const double vaj=0.0; |
---|
| 68 | const double vbj=M_PI; |
---|
[a8b3cdb] | 69 | |
---|
[68425bf] | 70 | const double radius_major = r_ratio * radius_minor; |
---|
| 71 | const double rA = 0.5*(square(radius_major) + square(radius_minor)); |
---|
| 72 | const double rB = 0.5*(square(radius_major) - square(radius_minor)); |
---|
[a8b3cdb] | 73 | |
---|
[68425bf] | 74 | //initialize integral |
---|
[71b751d] | 75 | double outer_sum_F1 = 0.0; |
---|
| 76 | double outer_sum_F2 = 0.0; |
---|
[74768cb] | 77 | for(int i=0;i<GAUSS_N;i++) { |
---|
[a8b3cdb] | 78 | //setup inner integral over the ellipsoidal cross-section |
---|
[74768cb] | 79 | const double cos_val = ( GAUSS_Z[i]*(vb-va) + va + vb )/2.0; |
---|
[68425bf] | 80 | const double sin_val = sqrt(1.0 - cos_val*cos_val); |
---|
| 81 | //const double arg = radius_minor*sin_val; |
---|
[71b751d] | 82 | double inner_sum_F1 = 0.0; |
---|
| 83 | double inner_sum_F2 = 0.0; |
---|
[74768cb] | 84 | for(int j=0;j<GAUSS_N;j++) { |
---|
| 85 | const double theta = ( GAUSS_Z[j]*(vbj-vaj) + vaj + vbj )/2.0; |
---|
[68425bf] | 86 | const double r = sin_val*sqrt(rA - rB*cos(theta)); |
---|
[592343f] | 87 | const double be = sas_2J1x_x(q*r); |
---|
[71b751d] | 88 | inner_sum_F1 += GAUSS_W[j] * be; |
---|
| 89 | inner_sum_F2 += GAUSS_W[j] * be * be; |
---|
[a8b3cdb] | 90 | } |
---|
| 91 | //now calculate the value of the inner integral |
---|
[71b751d] | 92 | inner_sum_F1 *= 0.5*(vbj-vaj); |
---|
| 93 | inner_sum_F2 *= 0.5*(vbj-vaj); |
---|
[a8b3cdb] | 94 | |
---|
| 95 | //now calculate outer integral |
---|
[1e7b0db0] | 96 | const double si = sas_sinx_x(q*0.5*length*cos_val); |
---|
[71b751d] | 97 | outer_sum_F1 += GAUSS_W[i] * inner_sum_F1 * si; |
---|
| 98 | outer_sum_F2 += GAUSS_W[i] * inner_sum_F2 * si * si; |
---|
[a8b3cdb] | 99 | } |
---|
[71b751d] | 100 | // correct limits and divide integral by pi |
---|
| 101 | outer_sum_F1 *= 0.5*(vb-va)/M_PI; |
---|
| 102 | outer_sum_F2 *= 0.5*(vb-va)/M_PI; |
---|
[a8b3cdb] | 103 | |
---|
[68425bf] | 104 | // scale by contrast and volume, and convert to to 1/cm units |
---|
[71b751d] | 105 | const double volume = form_volume(radius_minor, r_ratio, length); |
---|
| 106 | const double contrast = sld - solvent_sld; |
---|
| 107 | const double s = contrast*volume; |
---|
| 108 | *F1 = 1.0e-2*s*outer_sum_F1; |
---|
| 109 | *F2 = 1.0e-4*s*s*outer_sum_F2; |
---|
[a8b3cdb] | 110 | } |
---|
| 111 | |
---|
| 112 | |
---|
[2a0b2b1] | 113 | static double |
---|
[108e70e] | 114 | Iqabc(double qa, double qb, double qc, |
---|
[68425bf] | 115 | double radius_minor, double r_ratio, double length, |
---|
[becded3] | 116 | double sld, double solvent_sld) |
---|
[68425bf] | 117 | { |
---|
| 118 | // Compute: r = sqrt((radius_major*cos_nu)^2 + (radius_minor*cos_mu)^2) |
---|
| 119 | // Given: radius_major = r_ratio * radius_minor |
---|
[82592da] | 120 | const double qr = radius_minor*sqrt(square(r_ratio*qb) + square(qa)); |
---|
[2a0b2b1] | 121 | const double be = sas_2J1x_x(qr); |
---|
| 122 | const double si = sas_sinx_x(qc*0.5*length); |
---|
[71b751d] | 123 | const double fq = be * si; |
---|
| 124 | const double contrast = sld - solvent_sld; |
---|
| 125 | const double volume = form_volume(radius_minor, r_ratio, length); |
---|
| 126 | return 1.0e-4 * square(contrast * volume * fq); |
---|
[a8b3cdb] | 127 | } |
---|