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