[6b38781] | 1 | /** |
---|
| 2 | This software was developed by the University of Tennessee as part of the |
---|
| 3 | Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
| 4 | project funded by the US National Science Foundation. |
---|
| 5 | |
---|
| 6 | If you use DANSE applications to do scientific research that leads to |
---|
| 7 | publication, we ask that you acknowledge the use of the software with the |
---|
| 8 | following sentence: |
---|
| 9 | |
---|
| 10 | "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
| 11 | |
---|
| 12 | copyright 2008, University of Tennessee |
---|
| 13 | */ |
---|
| 14 | |
---|
| 15 | /** |
---|
| 16 | * Scattering model classes |
---|
| 17 | * The classes use the IGOR library found in |
---|
| 18 | * sansmodels/src/libigor |
---|
| 19 | * |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include <math.h> |
---|
| 23 | #include "parameters.hh" |
---|
| 24 | #include <stdio.h> |
---|
| 25 | using namespace std; |
---|
[0ba3b08] | 26 | #include "DiamEllip.h" |
---|
[6b38781] | 27 | |
---|
| 28 | extern "C" { |
---|
| 29 | #include "libStructureFactor.h" |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | DiamEllipFunc :: DiamEllipFunc() { |
---|
| 33 | radius_a = Parameter(20.0, true); |
---|
| 34 | radius_a.set_min(0.0); |
---|
| 35 | radius_b = Parameter(400, true); |
---|
| 36 | radius_b.set_min(0.0); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Function to evaluate 1D scattering function |
---|
| 41 | * The NIST IGOR library is used for the actual calculation. |
---|
| 42 | * @param q: q-value |
---|
| 43 | * @return: function value |
---|
| 44 | */ |
---|
| 45 | double DiamEllipFunc :: operator()(double q) { |
---|
| 46 | double dp[2]; |
---|
| 47 | |
---|
| 48 | // Fill parameter array for IGOR library |
---|
| 49 | // Add the background after averaging |
---|
| 50 | dp[0] = radius_a(); |
---|
| 51 | dp[1] = radius_b(); |
---|
| 52 | |
---|
| 53 | // Get the dispersion points for the radius a |
---|
| 54 | vector<WeightPoint> weights_rad_a; |
---|
| 55 | radius_a.get_weights(weights_rad_a); |
---|
| 56 | |
---|
| 57 | // Get the dispersion points for the radius b |
---|
| 58 | vector<WeightPoint> weights_rad_b; |
---|
| 59 | radius_b.get_weights(weights_rad_b); |
---|
| 60 | |
---|
| 61 | // Perform the computation, with all weight points |
---|
| 62 | double sum = 0.0; |
---|
| 63 | double norm = 0.0; |
---|
| 64 | |
---|
| 65 | // Loop over radius weight points |
---|
[a24f530] | 66 | for(size_t i=0; i<weights_rad_a.size(); i++) { |
---|
[6b38781] | 67 | dp[0] = weights_rad_a[i].value; |
---|
| 68 | // Loop over length weight points |
---|
[a24f530] | 69 | for(size_t j=0; j<weights_rad_b.size(); j++) { |
---|
[6b38781] | 70 | dp[1] = weights_rad_b[j].value; |
---|
| 71 | |
---|
| 72 | sum += weights_rad_a[i].weight*weights_rad_b[j].weight |
---|
[5eb9154] | 73 | * DiamEllip(dp[0], dp[1]); |
---|
[6b38781] | 74 | norm += weights_rad_a[i].weight*weights_rad_b[j].weight; |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | return sum/norm ; |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | /** |
---|
| 81 | * Function to evaluate 2D scattering function |
---|
| 82 | * @param q_x: value of Q along x |
---|
| 83 | * @param q_y: value of Q along y |
---|
| 84 | * @return: function value |
---|
| 85 | */ |
---|
| 86 | double DiamEllipFunc :: operator()(double qx, double qy) { |
---|
[770bab1] | 87 | double q = sqrt(qx*qx + qy*qy); |
---|
| 88 | return (*this).operator()(q); |
---|
[6b38781] | 89 | } |
---|
| 90 | /** |
---|
| 91 | * Function to evaluate 2D scattering function |
---|
| 92 | * @param pars: parameters of the cylinder |
---|
| 93 | * @param q: q-value |
---|
| 94 | * @param phi: angle phi |
---|
| 95 | * @return: function value |
---|
| 96 | */ |
---|
| 97 | double DiamEllipFunc :: evaluate_rphi(double q, double phi) { |
---|
| 98 | double qx = q*cos(phi); |
---|
| 99 | double qy = q*sin(phi); |
---|
| 100 | return (*this).operator()(qx, qy); |
---|
| 101 | } |
---|
[5eb9154] | 102 | /** |
---|
| 103 | * Function to calculate effective radius |
---|
| 104 | * @return: effective radius value |
---|
| 105 | */ |
---|
| 106 | double DiamEllipFunc :: calculate_ER() { |
---|
| 107 | //NOT implemented yet!!! |
---|
[6110bb8] | 108 | return 0.0; |
---|
[5eb9154] | 109 | } |
---|
[e08bd5b] | 110 | double DiamEllipFunc :: calculate_VR() { |
---|
| 111 | return 1.0; |
---|
| 112 | } |
---|