[cf404cb] | 1 | double _pearl_necklace_kernel(double q, double radius, double edge_separation, |
---|
| 2 | double thick_string, double num_pearls, double sld_pearl, |
---|
| 3 | double sld_string, double sld_solv); |
---|
| 4 | double form_volume(double radius, double edge_separation, |
---|
| 5 | double string_thickness, double number_of_pearls); |
---|
[cf85329] | 6 | |
---|
[cf404cb] | 7 | double Iq(double q, double radius, double edge_separation, |
---|
| 8 | double string_thickness, double number_of_pearls, double sld, |
---|
| 9 | double string_sld, double solvent_sld); |
---|
| 10 | |
---|
[2f5c6d4] | 11 | #define INVALID(v) (v.string_thickness >= v.radius || v.number_of_pearls <= 0) |
---|
| 12 | |
---|
[cf404cb] | 13 | // From Igor library |
---|
| 14 | double _pearl_necklace_kernel(double q, double radius, double edge_separation, double thick_string, |
---|
| 15 | double num_pearls, double sld_pearl, double sld_string, double sld_solv) |
---|
| 16 | { |
---|
[f12357f] | 17 | //relative slds |
---|
[cf404cb] | 18 | double contrast_pearl = sld_pearl - sld_solv; |
---|
| 19 | double contrast_string = sld_string - sld_solv; |
---|
[f12357f] | 20 | |
---|
| 21 | // number of string segments |
---|
| 22 | num_pearls = floor(num_pearls + 0.5); //Force integer number of pearls |
---|
| 23 | double num_strings = num_pearls - 1.0; |
---|
| 24 | |
---|
| 25 | //Pi |
---|
| 26 | double pi = 4.0*atan(1.0); |
---|
| 27 | |
---|
| 28 | // center to center distance between the neighboring pearls |
---|
| 29 | double A_s = edge_separation + 2.0 * radius; |
---|
| 30 | |
---|
| 31 | // Repeated Calculations |
---|
| 32 | double sincasq = sinc(q*A_s); |
---|
| 33 | double oneminussinc = 1 - sincasq; |
---|
| 34 | double q_r = q * radius; |
---|
| 35 | double q_edge = q * edge_separation; |
---|
| 36 | |
---|
| 37 | // each volume |
---|
| 38 | double string_vol = edge_separation * pi * thick_string * thick_string / 4.0; |
---|
| 39 | double pearl_vol = 4.0 / 3.0 * pi * radius * radius * radius; |
---|
[cf404cb] | 40 | |
---|
| 41 | //total volume |
---|
[f12357f] | 42 | double tot_vol; |
---|
| 43 | //each masses |
---|
[cf404cb] | 44 | double m_r= contrast_string * string_vol; |
---|
| 45 | double m_s= contrast_pearl * pearl_vol; |
---|
| 46 | double psi, gamma, beta; |
---|
| 47 | //form factors |
---|
[f12357f] | 48 | double sss, srr, srs; //cross |
---|
| 49 | double srr_1, srr_2, srr_3; |
---|
[cf404cb] | 50 | double form_factor; |
---|
[f12357f] | 51 | tot_vol = num_strings * string_vol; |
---|
| 52 | tot_vol += num_pearls * pearl_vol; |
---|
[cf404cb] | 53 | |
---|
| 54 | //sine functions of a pearl |
---|
[f12357f] | 55 | psi = sin(q_r); |
---|
| 56 | psi -= q_r * cos(q_r); |
---|
[cf404cb] | 57 | psi *= 3.0; |
---|
[f12357f] | 58 | psi /= q_r * q_r * q_r; |
---|
[cf404cb] | 59 | |
---|
| 60 | // Note take only 20 terms in Si series: 10 terms may be enough though. |
---|
[f12357f] | 61 | gamma = Si(q_edge); |
---|
| 62 | gamma /= (q_edge); |
---|
| 63 | beta = Si(q * (A_s - radius)); |
---|
| 64 | beta -= Si(q_r); |
---|
| 65 | beta /= q_edge; |
---|
[cf404cb] | 66 | |
---|
| 67 | // form factor for num_pearls |
---|
[f12357f] | 68 | sss = 1.0 - pow(sincasq, num_pearls); |
---|
| 69 | sss /= oneminussinc * oneminussinc; |
---|
| 70 | sss *= -sincasq; |
---|
| 71 | sss -= num_pearls / 2.0; |
---|
| 72 | sss += num_pearls / oneminussinc; |
---|
| 73 | sss *= 2.0 * m_s * psi * m_s * psi; |
---|
[cf404cb] | 74 | |
---|
| 75 | // form factor for num_strings (like thin rods) |
---|
[f12357f] | 76 | srr_1 = -sinc(q_edge/2.0) * sinc(q_edge/2.0); |
---|
[cf404cb] | 77 | |
---|
| 78 | srr_1 += 2.0 * gamma; |
---|
| 79 | srr_1 *= num_strings; |
---|
[f12357f] | 80 | srr_2 = 2.0/oneminussinc; |
---|
| 81 | srr_2 *= num_strings; |
---|
| 82 | srr_2 *= beta * beta; |
---|
| 83 | srr_3 = 1.0 - pow(sincasq, num_strings); |
---|
| 84 | srr_3 /= oneminussinc * oneminussinc; |
---|
| 85 | srr_3 *= beta * beta; |
---|
| 86 | srr_3 *= -2.0; |
---|
[cf404cb] | 87 | |
---|
| 88 | // total srr |
---|
| 89 | srr = srr_1 + srr_2 + srr_3; |
---|
[f12357f] | 90 | srr *= m_r * m_r; |
---|
[cf404cb] | 91 | |
---|
| 92 | // form factor for correlations |
---|
| 93 | srs = 1.0; |
---|
[f12357f] | 94 | srs -= pow(sincasq, num_strings); |
---|
| 95 | srs /= oneminussinc * oneminussinc; |
---|
| 96 | srs *= -sincasq; |
---|
| 97 | srs += num_strings/oneminussinc; |
---|
| 98 | srs *= 4.0; |
---|
| 99 | srs *= (m_r * m_s * beta * psi); |
---|
[cf404cb] | 100 | |
---|
| 101 | form_factor = sss + srr + srs; |
---|
| 102 | form_factor /= (tot_vol * 1.0e4); // norm by volume and A^-1 to cm^-1 |
---|
| 103 | |
---|
| 104 | return (form_factor); |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | double form_volume(double radius, double edge_separation, |
---|
| 108 | double string_thickness, double number_of_pearls) |
---|
| 109 | { |
---|
| 110 | double total_vol; |
---|
| 111 | |
---|
| 112 | double pi = 4.0*atan(1.0); |
---|
| 113 | double number_of_strings = number_of_pearls - 1.0; |
---|
| 114 | |
---|
[f12357f] | 115 | double string_vol = edge_separation * pi * string_thickness * string_thickness / 4.0; |
---|
| 116 | double pearl_vol = 4.0 / 3.0 * pi * radius * radius * radius; |
---|
[cf404cb] | 117 | |
---|
| 118 | total_vol = number_of_strings * string_vol; |
---|
| 119 | total_vol += number_of_pearls * pearl_vol; |
---|
| 120 | |
---|
| 121 | return(total_vol); |
---|
| 122 | } |
---|
| 123 | |
---|
| 124 | double Iq(double q, double radius, double edge_separation, |
---|
| 125 | double string_thickness, double number_of_pearls, double sld, |
---|
| 126 | double string_sld, double solvent_sld) |
---|
| 127 | { |
---|
[f12357f] | 128 | double value, tot_vol; |
---|
| 129 | |
---|
[cf404cb] | 130 | value = _pearl_necklace_kernel(q, radius, edge_separation, string_thickness, |
---|
| 131 | number_of_pearls, sld, string_sld, solvent_sld); |
---|
| 132 | tot_vol = form_volume(radius, edge_separation, string_thickness, number_of_pearls); |
---|
| 133 | |
---|
| 134 | return value*tot_vol; |
---|
| 135 | } |
---|