[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 "SquareWell.h" |
---|
[25579e8] | 27 | |
---|
| 28 | extern "C" { |
---|
[0ba3b08] | 29 | #include "libStructureFactor.h" |
---|
[25579e8] | 30 | } |
---|
| 31 | |
---|
| 32 | SquareWellStructure :: SquareWellStructure() { |
---|
[0ba3b08] | 33 | effect_radius = Parameter(50.0, true); |
---|
| 34 | effect_radius.set_min(0.0); |
---|
| 35 | volfraction = Parameter(0.04, true); |
---|
| 36 | volfraction.set_min(0.0); |
---|
| 37 | welldepth = Parameter(1.50); |
---|
| 38 | wellwidth = Parameter(1.20); |
---|
[25579e8] | 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 SquareWellStructure :: operator()(double q) { |
---|
[0ba3b08] | 48 | double dp[4]; |
---|
| 49 | |
---|
| 50 | // Fill parameter array for IGOR library |
---|
| 51 | // Add the background after averaging |
---|
| 52 | dp[0] = effect_radius(); |
---|
| 53 | dp[1] = volfraction(); |
---|
| 54 | dp[2] = welldepth(); |
---|
| 55 | dp[3] = wellwidth(); |
---|
| 56 | |
---|
| 57 | // Get the dispersion points for the radius |
---|
| 58 | vector<WeightPoint> weights_rad; |
---|
| 59 | effect_radius.get_weights(weights_rad); |
---|
| 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 |
---|
| 66 | for(size_t i=0; i<weights_rad.size(); i++) { |
---|
| 67 | dp[0] = weights_rad[i].value; |
---|
| 68 | |
---|
| 69 | sum += weights_rad[i].weight |
---|
| 70 | * SquareWellStruct(dp, q); |
---|
| 71 | norm += weights_rad[i].weight; |
---|
| 72 | } |
---|
| 73 | return sum/norm ; |
---|
[25579e8] | 74 | } |
---|
| 75 | |
---|
| 76 | /** |
---|
| 77 | * Function to evaluate 2D scattering function |
---|
| 78 | * @param q_x: value of Q along x |
---|
| 79 | * @param q_y: value of Q along y |
---|
| 80 | * @return: function value |
---|
| 81 | */ |
---|
| 82 | double SquareWellStructure :: operator()(double qx, double qy) { |
---|
[0ba3b08] | 83 | double q = sqrt(qx*qx + qy*qy); |
---|
| 84 | return (*this).operator()(q); |
---|
[25579e8] | 85 | } |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * Function to evaluate 2D scattering function |
---|
| 89 | * @param pars: parameters of the cylinder |
---|
| 90 | * @param q: q-value |
---|
| 91 | * @param phi: angle phi |
---|
| 92 | * @return: function value |
---|
| 93 | */ |
---|
| 94 | double SquareWellStructure :: evaluate_rphi(double q, double phi) { |
---|
[0ba3b08] | 95 | double qx = q*cos(phi); |
---|
| 96 | double qy = q*sin(phi); |
---|
| 97 | return (*this).operator()(qx, qy); |
---|
[25579e8] | 98 | } |
---|
[5eb9154] | 99 | /** |
---|
| 100 | * Function to calculate effective radius |
---|
| 101 | * @return: effective radius value |
---|
| 102 | */ |
---|
| 103 | double SquareWellStructure :: calculate_ER() { |
---|
[0ba3b08] | 104 | //NOT implemented yet!!! |
---|
[6110bb8] | 105 | return 0.0; |
---|
[5eb9154] | 106 | } |
---|
[e08bd5b] | 107 | double SquareWellStructure :: calculate_VR() { |
---|
| 108 | return 1.0; |
---|
| 109 | } |
---|