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