Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
57 lines (50 sloc) 1.49 KB
#define INVALID(v) (v.radius<0 || v.length<0)
static double
form_volume(double radius, double length)
{
return M_PI*radius*radius*length;
}
static double
fq(double qab, double qc, double radius, double length)
{
return sas_2J1x_x(qab*radius) * sas_sinx_x(qc*0.5*length);
}
static double
orient_avg_1D(double q, double radius, double length)
{
// translate a point in [-1,1] to a point in [0, pi/2]
const double zm = M_PI_4;
const double zb = M_PI_4;
double total = 0.0;
for (int i=0; i<GAUSS_N ;i++) {
const double theta = GAUSS_Z[i]*zm + zb;
double sin_theta, cos_theta; // slots to hold sincos function output
// theta (theta,phi) the projection of the cylinder on the detector plane
SINCOS(theta , sin_theta, cos_theta);
const double form = fq(q*sin_theta, q*cos_theta, radius, length);
total += GAUSS_W[i] * form * form * sin_theta;
}
// translate dx in [-1,1] to dx in [lower,upper]
return total*zm;
}
static double
Iq(double q,
double sld,
double solvent_sld,
double radius,
double length)
{
const double s = (sld - solvent_sld) * form_volume(radius, length);
return 1.0e-4 * s * s * orient_avg_1D(q, radius, length);
}
static double
Iqac(double qab, double qc,
double sld,
double solvent_sld,
double radius,
double length)
{
const double s = (sld-solvent_sld) * form_volume(radius, length);
const double form = fq(qab, qc, radius, length);
return 1.0e-4 * square(s * form);
}