/** 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 * */ #include #include "models.hh" #include "parameters.hh" #include using namespace std; extern "C" { #include "libCylinder.h" #include "barbell.h" } BarBellModel :: BarBellModel() { scale = Parameter(1.0); rad_bar = Parameter(20.0); rad_bar.set_min(0.0); len_bar = Parameter(400.0, true); len_bar.set_min(0.0); rad_bell = Parameter(40.0); rad_bell.set_min(0.0); sld_barbell = Parameter(1.0e-6); sld_solv = Parameter(6.3e-6); background = Parameter(0.0); theta = Parameter(0.0, true); phi = 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 BarBellModel :: operator()(double q) { double dp[7]; // Fill parameter array for IGOR library // Add the background after averaging dp[0] = scale(); dp[1] = rad_bar(); dp[2] = len_bar(); dp[3] = rad_bell(); dp[4] = sld_barbell(); dp[5] = sld_solv(); dp[6] = 0.0; // Get the dispersion points for the rad_bar vector weights_rad_bar; rad_bar.get_weights(weights_rad_bar); // Get the dispersion points for the len_bar vector weights_len_bar; len_bar.get_weights(weights_len_bar); // Get the dispersion points for the rad_bell vector weights_rad_bell; rad_bell.get_weights(weights_rad_bell); // Perform the computation, with all weight points double sum = 0.0; double norm = 0.0; double vol = 0.0; double pi,hDist,result; double vol_i = 0.0; pi = 4.0*atan(1.0); // Loop over radius weight points for(size_t i=0; i weights_rad_bar; rad_bar.get_weights(weights_rad_bar); // Get the dispersion points for the len_bar vector weights_len_bar; len_bar.get_weights(weights_len_bar); // Get the dispersion points for the rad_bell vector weights_rad_bell; rad_bell.get_weights(weights_rad_bell); // Get angular averaging for theta vector weights_theta; theta.get_weights(weights_theta); // Get angular averaging for phi vector weights_phi; phi.get_weights(weights_phi); // Perform the computation, with all weight points double sum = 0.0; double norm = 0.0; double norm_vol = 0.0; double vol = 0.0; double pi,hDist; double vol_i = 0.0; pi = 4.0*atan(1.0); // Loop over radius weight points for(size_t i=0; i1) { _ptvalue *= fabs(sin(weights_theta[l].value*pi/180.0)); } sum += _ptvalue; // This model dose not need the volume of spheres correction!!! //Find average volume vol += weights_rad_bar[i].weight * weights_len_bar[j].weight * weights_rad_bell[k].weight * vol_i; //Find norm for volume norm_vol += weights_rad_bar[i].weight * weights_len_bar[j].weight * weights_rad_bell[k].weight; norm += weights_rad_bar[i].weight * weights_len_bar[j].weight * weights_rad_bell[k].weight * weights_theta[l].weight * weights_phi[m].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); if (vol != 0.0 && norm_vol != 0.0) { //Re-normalize by avg volume sum = sum/(vol/norm_vol);} return sum/norm + background(); } /** * Function to evaluate 2D scattering function * @param pars: parameters of the SCCrystal * @param q: q-value * @param phi: angle phi * @return: function value */ double BarBellModel :: evaluate_rphi(double q, double phi) { return (*this).operator()(q); } /** * Function to calculate effective radius * @return: effective radius value */ double BarBellModel :: calculate_ER() { //NOT implemented yet!!! return 0.0; }