/** This software was developed by the University of Tennessee as part of the Distributed Data Analysis of Neutron Scattering Experiments (DANSE) project funded by the US National Science Foundation. If you use DANSE applications to do scientific research that leads to publication, we ask that you acknowledge the use of the software with the following sentence: "This work benefited from DANSE software developed under NSF award DMR-0520547." copyright 2008, University of Tennessee */ /** * Scattering model classes * The classes use the IGOR library found in * sansmodels/src/libigor * * TODO: refactor so that we pull in the old sansmodels.c_extensions */ #include #include "models.hh" #include "parameters.hh" #include using namespace std; extern "C" { #include "libCylinder.h" #include "elliptical_cylinder.h" } EllipticalCylinderModel :: EllipticalCylinderModel() { scale = Parameter(1.0); r_minor = Parameter(20.0, true); r_minor.set_min(0.0); r_ratio = Parameter(1.5, true); r_ratio.set_min(0.0); length = Parameter(400.0, true); length.set_min(0.0); contrast = Parameter(3.e-6); background = Parameter(0.0); cyl_theta = Parameter(1.57, true); cyl_phi = Parameter(0.0, true); cyl_psi = Parameter(0.0, true); } /** * Function to evaluate 1D scattering function * The NIST IGOR library is used for the actual calculation. * @param q: q-value * @return: function value */ double EllipticalCylinderModel :: operator()(double q) { double dp[6]; dp[0] = scale(); dp[1] = r_minor(); dp[2] = r_ratio(); dp[3] = length(); dp[4] = contrast(); dp[5] = 0.0; // Get the dispersion points for the r_minor vector weights_rad; r_minor.get_weights(weights_rad); // Get the dispersion points for the r_ratio vector weights_rat; r_ratio.get_weights(weights_rat); // Get the dispersion points for the length vector weights_len; length.get_weights(weights_len); // Perform the computation, with all weight points double sum = 0.0; double norm = 0.0; // Loop over r_minor weight points for(int i=0; i weights_rad; r_minor.get_weights(weights_rad); // Get the dispersion points for the r_ratio vector weights_rat; r_ratio.get_weights(weights_rat); // Get the dispersion points for the length vector weights_len; length.get_weights(weights_len); // Get angular averaging for theta vector weights_theta; cyl_theta.get_weights(weights_theta); // Get angular averaging for phi vector weights_phi; cyl_phi.get_weights(weights_phi); // Get angular averaging for psi vector weights_psi; cyl_psi.get_weights(weights_psi); // Perform the computation, with all weight points double sum = 0.0; double norm = 0.0; // Loop over minor radius weight points for(int i=0; i1) { _ptvalue *= sin(weights_theta[k].value); } sum += _ptvalue; norm += weights_rad[i].weight * weights_len[j].weight * weights_rat[m].weight * weights_theta[k].weight * weights_phi[l].weight * weights_psi[o].weight; } } } } } } // Averaging in theta needs an extra normalization // factor to account for the sin(theta) term in the // integration (see documentation). if (weights_theta.size()>1) norm = norm / asin(1.0); return sum/norm + background(); } /** * Function to evaluate 2D scattering function * @param pars: parameters of the cylinder * @param q: q-value * @param phi: angle phi * @return: function value */ double EllipticalCylinderModel :: evaluate_rphi(double q, double phi) { double qx = q*cos(phi); double qy = q*sin(phi); return (*this).operator()(qx, qy); }