[27a0771] | 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 | * TODO: add 2D function |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #include <math.h> |
---|
| 25 | #include "models.hh" |
---|
| 26 | #include "parameters.hh" |
---|
| 27 | #include <stdio.h> |
---|
| 28 | using namespace std; |
---|
| 29 | |
---|
| 30 | extern "C" { |
---|
| 31 | #include "libCylinder.h" |
---|
| 32 | #include "lamellarPS.h" |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | LamellarPSModel :: LamellarPSModel() { |
---|
| 36 | scale = Parameter(1.0); |
---|
[b4679de] | 37 | spacing = Parameter(400.0, true); |
---|
| 38 | spacing.set_min(0.0); |
---|
| 39 | delta = Parameter(30.0); |
---|
[27a0771] | 40 | delta.set_min(0.0); |
---|
[b4679de] | 41 | sigma = Parameter(0.15); |
---|
| 42 | sigma.set_min(0.0); |
---|
[27a0771] | 43 | contrast = Parameter(5.3e-6); |
---|
| 44 | n_plates = Parameter(20.0); |
---|
| 45 | caille = Parameter(0.1); |
---|
| 46 | background = Parameter(0.0); |
---|
| 47 | |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | /** |
---|
| 51 | * Function to evaluate 1D scattering function |
---|
| 52 | * The NIST IGOR library is used for the actual calculation. |
---|
| 53 | * @param q: q-value |
---|
| 54 | * @return: function value |
---|
| 55 | */ |
---|
| 56 | double LamellarPSModel :: operator()(double q) { |
---|
| 57 | double dp[8]; |
---|
| 58 | |
---|
| 59 | // Fill parameter array for IGOR library |
---|
| 60 | // Add the background after averaging |
---|
| 61 | dp[0] = scale(); |
---|
| 62 | dp[1] = spacing(); |
---|
| 63 | dp[2] = delta(); |
---|
| 64 | dp[3] = sigma(); |
---|
| 65 | dp[4] = contrast(); |
---|
| 66 | dp[5] = n_plates(); |
---|
| 67 | dp[6] = caille(); |
---|
[b4679de] | 68 | dp[7] = 0.0; |
---|
| 69 | |
---|
[27a0771] | 70 | |
---|
| 71 | // Get the dispersion points for (delta) thickness |
---|
[b4679de] | 72 | vector<WeightPoint> weights_spacing; |
---|
| 73 | spacing.get_weights(weights_spacing); |
---|
| 74 | |
---|
[27a0771] | 75 | // Perform the computation, with all weight points |
---|
| 76 | double sum = 0.0; |
---|
| 77 | double norm = 0.0; |
---|
[b4679de] | 78 | |
---|
[27a0771] | 79 | // Loop over short_edgeA weight points |
---|
[b4679de] | 80 | for(int i=0; i< (int)weights_spacing.size(); i++) { |
---|
| 81 | dp[1] = weights_spacing[i].value; |
---|
| 82 | |
---|
| 83 | sum += weights_spacing[i].weight * LamellarPS(dp, q); |
---|
| 84 | norm += weights_spacing[i].weight; |
---|
[27a0771] | 85 | |
---|
| 86 | } |
---|
| 87 | return sum/norm + background(); |
---|
| 88 | } |
---|
| 89 | /** |
---|
| 90 | * Function to evaluate 2D scattering function |
---|
| 91 | * @param q_x: value of Q along x |
---|
| 92 | * @param q_y: value of Q along y |
---|
| 93 | * @return: function value |
---|
| 94 | */ |
---|
| 95 | double LamellarPSModel :: operator()(double qx, double qy) { |
---|
[b4679de] | 96 | double q = sqrt(qx*qx + qy*qy); |
---|
| 97 | return (*this).operator()(q); |
---|
[27a0771] | 98 | } |
---|
| 99 | |
---|
| 100 | /** |
---|
| 101 | * Function to evaluate 2D scattering function |
---|
| 102 | * @param pars: parameters of the cylinder |
---|
| 103 | * @param q: q-value |
---|
| 104 | * @param phi: angle phi |
---|
| 105 | * @return: function value |
---|
| 106 | */ |
---|
| 107 | double LamellarPSModel :: evaluate_rphi(double q, double phi) { |
---|
[b4679de] | 108 | return (*this).operator()(q); |
---|
[27a0771] | 109 | } |
---|