[25579e8] | 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 | * TODO: refactor so that we pull in the old sansmodels.c_extensions |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | #include <math.h> |
---|
| 24 | #include "models.hh" |
---|
| 25 | #include "parameters.hh" |
---|
| 26 | #include <stdio.h> |
---|
| 27 | using namespace std; |
---|
| 28 | |
---|
| 29 | extern "C" { |
---|
| 30 | #include "libStructureFactor.h" |
---|
| 31 | #include "Hardsphere.h" |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | HardsphereStructure :: HardsphereStructure() { |
---|
[5eb9154] | 35 | effect_radius = Parameter(50.0, true); |
---|
| 36 | effect_radius.set_min(0.0); |
---|
[25579e8] | 37 | volfraction = Parameter(0.20, true); |
---|
| 38 | volfraction.set_min(0.0); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | /** |
---|
| 42 | * Function to evaluate 1D scattering function |
---|
| 43 | * The NIST IGOR library is used for the actual calculation. |
---|
| 44 | * @param q: q-value |
---|
| 45 | * @return: function value |
---|
| 46 | */ |
---|
| 47 | double HardsphereStructure :: operator()(double q) { |
---|
| 48 | double dp[2]; |
---|
| 49 | |
---|
| 50 | // Fill parameter array for IGOR library |
---|
| 51 | // Add the background after averaging |
---|
[5eb9154] | 52 | dp[0] = effect_radius(); |
---|
[25579e8] | 53 | dp[1] = volfraction(); |
---|
| 54 | |
---|
| 55 | // Get the dispersion points for the radius |
---|
| 56 | vector<WeightPoint> weights_rad; |
---|
[5eb9154] | 57 | effect_radius.get_weights(weights_rad); |
---|
[25579e8] | 58 | |
---|
| 59 | // Perform the computation, with all weight points |
---|
| 60 | double sum = 0.0; |
---|
| 61 | double norm = 0.0; |
---|
| 62 | |
---|
| 63 | // Loop over radius weight points |
---|
| 64 | for(int i=0; i<weights_rad.size(); i++) { |
---|
| 65 | dp[0] = weights_rad[i].value; |
---|
| 66 | |
---|
| 67 | sum += weights_rad[i].weight |
---|
| 68 | * HardSphereStruct(dp, q); |
---|
| 69 | norm += weights_rad[i].weight; |
---|
| 70 | } |
---|
| 71 | return sum/norm ; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | /** |
---|
| 75 | * Function to evaluate 2D scattering function |
---|
| 76 | * @param q_x: value of Q along x |
---|
| 77 | * @param q_y: value of Q along y |
---|
| 78 | * @return: function value |
---|
| 79 | */ |
---|
| 80 | double HardsphereStructure :: operator()(double qx, double qy) { |
---|
[770bab1] | 81 | double q = sqrt(qx*qx + qy*qy); |
---|
| 82 | return (*this).operator()(q); |
---|
[25579e8] | 83 | } |
---|
| 84 | |
---|
| 85 | /** |
---|
| 86 | * Function to evaluate 2D scattering function |
---|
| 87 | * @param pars: parameters of the cylinder |
---|
| 88 | * @param q: q-value |
---|
| 89 | * @param phi: angle phi |
---|
| 90 | * @return: function value |
---|
| 91 | */ |
---|
| 92 | double HardsphereStructure :: evaluate_rphi(double q, double phi) { |
---|
| 93 | double qx = q*cos(phi); |
---|
| 94 | double qy = q*sin(phi); |
---|
| 95 | return (*this).operator()(qx, qy); |
---|
[5eb9154] | 96 | } |
---|
| 97 | /** |
---|
| 98 | * Function to calculate effective radius |
---|
| 99 | * @return: effective radius value |
---|
| 100 | */ |
---|
| 101 | double HardsphereStructure :: calculate_ER() { |
---|
| 102 | //NOT implemented yet!!! |
---|
[6110bb8] | 103 | return 0.0; |
---|
[5eb9154] | 104 | } |
---|