[03cac08] | 1 | #define INVALID(v) (v.radius<0 || v.length<0) |
---|
| 2 | |
---|
[2a0b2b1] | 3 | static double |
---|
| 4 | form_volume(double radius, double length) |
---|
[14de349] | 5 | { |
---|
| 6 | return M_PI*radius*radius*length; |
---|
| 7 | } |
---|
| 8 | |
---|
[2a0b2b1] | 9 | static double |
---|
[71b751d] | 10 | _fq(double qab, double qc, double radius, double length) |
---|
[14de349] | 11 | { |
---|
[2a0b2b1] | 12 | return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length); |
---|
[0d6e865] | 13 | } |
---|
[50e1e40] | 14 | |
---|
[71b751d] | 15 | static void |
---|
| 16 | Fq(double q, |
---|
| 17 | double *F1, |
---|
| 18 | double *F2, |
---|
| 19 | double sld, |
---|
| 20 | double solvent_sld, |
---|
| 21 | double radius, |
---|
| 22 | double length) |
---|
[0d6e865] | 23 | { |
---|
[50e1e40] | 24 | // translate a point in [-1,1] to a point in [0, pi/2] |
---|
| 25 | const double zm = M_PI_4; |
---|
[2a0b2b1] | 26 | const double zb = M_PI_4; |
---|
[50e1e40] | 27 | |
---|
[71b751d] | 28 | double total_F1 = 0.0; |
---|
| 29 | double total_F2 = 0.0; |
---|
[74768cb] | 30 | for (int i=0; i<GAUSS_N ;i++) { |
---|
| 31 | const double theta = GAUSS_Z[i]*zm + zb; |
---|
[2a0b2b1] | 32 | double sin_theta, cos_theta; // slots to hold sincos function output |
---|
| 33 | // theta (theta,phi) the projection of the cylinder on the detector plane |
---|
| 34 | SINCOS(theta , sin_theta, cos_theta); |
---|
[71b751d] | 35 | const double form = _fq(q*sin_theta, q*cos_theta, radius, length); |
---|
| 36 | total_F1 += GAUSS_W[i] * form * sin_theta; |
---|
| 37 | total_F2 += GAUSS_W[i] * form * form * sin_theta; |
---|
[14de349] | 38 | } |
---|
[ff7119b] | 39 | // translate dx in [-1,1] to dx in [lower,upper] |
---|
[71b751d] | 40 | total_F1 *= zm; |
---|
| 41 | total_F2 *= zm; |
---|
[50e1e40] | 42 | const double s = (sld - solvent_sld) * form_volume(radius, length); |
---|
[71b751d] | 43 | *F1 = 1e-2 * s * total_F1; |
---|
| 44 | *F2 = 1e-4 * s * s * total_F2; |
---|
[14de349] | 45 | } |
---|
| 46 | |
---|
[71b751d] | 47 | |
---|
| 48 | |
---|
[2a0b2b1] | 49 | static double |
---|
[108e70e] | 50 | Iqac(double qab, double qc, |
---|
[994d77f] | 51 | double sld, |
---|
| 52 | double solvent_sld, |
---|
| 53 | double radius, |
---|
[becded3] | 54 | double length) |
---|
[14de349] | 55 | { |
---|
[71b751d] | 56 | const double form = _fq(qab, qc, radius, length); |
---|
[50e1e40] | 57 | const double s = (sld-solvent_sld) * form_volume(radius, length); |
---|
[73e08ae] | 58 | return 1.0e-4 * square(s * form); |
---|
[14de349] | 59 | } |
---|
[71b751d] | 60 | |
---|