[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: add 2D function |
---|
| 21 | */ |
---|
| 22 | |
---|
| 23 | #include <math.h> |
---|
| 24 | #include "parameters.hh" |
---|
| 25 | #include <stdio.h> |
---|
| 26 | using namespace std; |
---|
[82c11d3] | 27 | #include "lamellarPS_HG.h" |
---|
[27a0771] | 28 | |
---|
| 29 | extern "C" { |
---|
| 30 | #include "libCylinder.h" |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | LamellarPSHGModel :: LamellarPSHGModel() { |
---|
| 34 | scale = Parameter(1.0); |
---|
[96b59384] | 35 | spacing = Parameter(40.0, true); |
---|
| 36 | spacing.set_min(0.0); |
---|
[27a0771] | 37 | deltaT = Parameter(10.0, true); |
---|
| 38 | deltaT.set_min(0.0); |
---|
| 39 | deltaH = Parameter(2.0, true); |
---|
| 40 | deltaH.set_min(0.0); |
---|
| 41 | sld_tail = Parameter(4e-7); |
---|
| 42 | sld_head = Parameter(2e-6); |
---|
| 43 | sld_solvent = Parameter(6e-6); |
---|
| 44 | n_plates = Parameter(30); |
---|
| 45 | caille = Parameter(0.001); |
---|
| 46 | background = Parameter(0.001); |
---|
| 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 LamellarPSHGModel :: operator()(double q) { |
---|
| 57 | double dp[10]; |
---|
| 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] = deltaT(); |
---|
| 64 | dp[3] = deltaH(); |
---|
| 65 | dp[4] = sld_tail(); |
---|
| 66 | dp[5] = sld_head(); |
---|
| 67 | dp[6] = sld_solvent(); |
---|
| 68 | dp[7] = n_plates(); |
---|
| 69 | dp[8] = caille(); |
---|
[96b59384] | 70 | dp[9] = 0.0; |
---|
| 71 | |
---|
[27a0771] | 72 | |
---|
| 73 | // Get the dispersion points for (deltaT) thickness of the tail |
---|
| 74 | vector<WeightPoint> weights_deltaT; |
---|
| 75 | deltaT.get_weights(weights_deltaT); |
---|
[96b59384] | 76 | |
---|
[27a0771] | 77 | // Get the dispersion points for (deltaH) thickness of the head |
---|
| 78 | vector<WeightPoint> weights_deltaH; |
---|
| 79 | deltaH.get_weights(weights_deltaH); |
---|
| 80 | |
---|
[96b59384] | 81 | // Get the dispersion points for spacing |
---|
| 82 | vector<WeightPoint> weights_spacing; |
---|
| 83 | spacing.get_weights(weights_spacing); |
---|
| 84 | |
---|
[27a0771] | 85 | // Perform the computation, with all weight points |
---|
| 86 | double sum = 0.0; |
---|
| 87 | double norm = 0.0; |
---|
[96b59384] | 88 | |
---|
[27a0771] | 89 | // Loop over deltaT weight points |
---|
| 90 | for(int i=0; i< (int)weights_deltaT.size(); i++) { |
---|
| 91 | dp[2] = weights_deltaT[i].value; |
---|
| 92 | |
---|
| 93 | // Loop over deltaH weight points |
---|
| 94 | for(int j=0; j< (int)weights_deltaH.size(); j++) { |
---|
| 95 | dp[3] = weights_deltaH[j].value; |
---|
[96b59384] | 96 | // Loop over spacing weight points |
---|
| 97 | for(int k=0; k< (int)weights_spacing.size(); k++) { |
---|
| 98 | dp[1] = weights_spacing[k].value; |
---|
| 99 | |
---|
| 100 | sum += weights_deltaT[i].weight * weights_deltaH[j].weight *weights_spacing[k].weight |
---|
| 101 | *LamellarPS_HG(dp, q); |
---|
| 102 | norm += weights_deltaT[i].weight * weights_deltaH[j].weight * weights_spacing[k].weight; |
---|
| 103 | } |
---|
[27a0771] | 104 | } |
---|
| 105 | } |
---|
| 106 | return sum/norm + background(); |
---|
| 107 | } |
---|
| 108 | /** |
---|
| 109 | * Function to evaluate 2D scattering function |
---|
| 110 | * @param q_x: value of Q along x |
---|
| 111 | * @param q_y: value of Q along y |
---|
| 112 | * @return: function value |
---|
| 113 | */ |
---|
| 114 | double LamellarPSHGModel :: operator()(double qx, double qy) { |
---|
[96b59384] | 115 | double q = sqrt(qx*qx + qy*qy); |
---|
| 116 | return (*this).operator()(q); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | /** |
---|
| 120 | * Function to evaluate 2D scattering function |
---|
| 121 | * @param pars: parameters of the lamellarPS_HG |
---|
| 122 | * @param q: q-value |
---|
| 123 | * @param phi: angle phi |
---|
| 124 | * @return: function value |
---|
| 125 | */ |
---|
| 126 | double LamellarPSHGModel :: evaluate_rphi(double q, double phi) { |
---|
| 127 | return (*this).operator()(q); |
---|
| 128 | } |
---|
[5eb9154] | 129 | /** |
---|
| 130 | * Function to calculate effective radius |
---|
| 131 | * @return: effective radius value |
---|
| 132 | */ |
---|
| 133 | double LamellarPSHGModel :: calculate_ER() { |
---|
| 134 | //NOT implemented yet!!! |
---|
[34c2649] | 135 | return 0.0; |
---|
[5eb9154] | 136 | } |
---|
[e08bd5b] | 137 | double LamellarPSHGModel :: calculate_VR() { |
---|
| 138 | return 1.0; |
---|
| 139 | } |
---|