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