[339ce67] | 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 | #include <math.h> |
---|
| 22 | #include "models.hh" |
---|
| 23 | #include "parameters.hh" |
---|
| 24 | #include <stdio.h> |
---|
| 25 | using namespace std; |
---|
| 26 | |
---|
| 27 | extern "C" { |
---|
| 28 | #include "libCylinder.h" |
---|
| 29 | #include "lamellarPC.h" |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | LamellarPCrystalModel :: LamellarPCrystalModel() { |
---|
| 33 | scale = Parameter(1.0); |
---|
| 34 | thickness = Parameter(33.0, true); |
---|
| 35 | thickness.set_min(0.0); |
---|
| 36 | Nlayers = Parameter(20.0, true); |
---|
| 37 | Nlayers.set_min(0.0); |
---|
| 38 | spacing = Parameter(250); |
---|
| 39 | pd_spacing = Parameter(0.0); |
---|
| 40 | sld_layer = Parameter(1.0e-6); |
---|
| 41 | sld_solvent = Parameter(6.34e-6); |
---|
| 42 | background = Parameter(0.0); |
---|
| 43 | |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | /** |
---|
| 47 | * Function to evaluate 1D scattering function |
---|
| 48 | * The NIST IGOR library is used for the actual calculation. |
---|
| 49 | * @param q: q-value |
---|
| 50 | * @return: function value |
---|
| 51 | */ |
---|
| 52 | double LamellarPCrystalModel :: operator()(double q) { |
---|
| 53 | double dp[8]; |
---|
| 54 | |
---|
| 55 | // Fill parameter array for IGOR library |
---|
| 56 | // Add the background after averaging |
---|
| 57 | dp[0] = scale(); |
---|
| 58 | dp[1] = thickness(); |
---|
| 59 | dp[2] = Nlayers(); |
---|
| 60 | dp[3] = spacing(); |
---|
| 61 | dp[4] = pd_spacing(); |
---|
| 62 | dp[5] = sld_layer(); |
---|
| 63 | dp[6] = sld_solvent(); |
---|
| 64 | dp[7] = 0.0; // Do not apply background here. |
---|
| 65 | |
---|
| 66 | // Get the dispersion points for the head thickness |
---|
| 67 | vector<WeightPoint> weights_thickness; |
---|
| 68 | thickness.get_weights(weights_thickness); |
---|
| 69 | |
---|
| 70 | // Let's provide from the func which is more accurate especially for small q region. |
---|
| 71 | // Get the dispersion points for the tail length |
---|
| 72 | //vector<WeightPoint> weights_spacing; |
---|
| 73 | //spacing.get_weights(weights_spacing); |
---|
| 74 | |
---|
| 75 | // Perform the computation, with all weight points |
---|
| 76 | double sum = 0.0; |
---|
| 77 | double norm = 0.0; |
---|
| 78 | |
---|
| 79 | // Loop over thickness and spacing weight points |
---|
| 80 | for(int i=0; i< (int)weights_thickness.size(); i++) { |
---|
| 81 | dp[1] = weights_thickness[i].value; |
---|
| 82 | //for (int j=0; j< (int)weights_spacing.size(); j++){ |
---|
| 83 | //dp[3] = weights_spacing[j].value; |
---|
| 84 | sum += weights_thickness[i].weight*Lamellar_ParaCrystal(dp, q); |
---|
| 85 | norm += weights_thickness[i].weight; |
---|
| 86 | //} |
---|
| 87 | } |
---|
| 88 | //apply norm and background |
---|
| 89 | return sum/norm + background(); |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | /** |
---|
| 93 | * Function to evaluate 2D scattering function |
---|
| 94 | * @param q_x: value of Q along x |
---|
| 95 | * @param q_y: value of Q along y |
---|
| 96 | * @return: function value |
---|
| 97 | */ |
---|
| 98 | |
---|
| 99 | double LamellarPCrystalModel :: operator()(double qx, double qy) { |
---|
| 100 | double q = sqrt(qx*qx + qy*qy); |
---|
| 101 | return (*this).operator()(q); |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * Function to evaluate 2D scattering function |
---|
| 106 | * @param pars: parameters of the lamellar |
---|
| 107 | * @param q: q-value |
---|
| 108 | * @param phi: angle phi |
---|
| 109 | * @return: function value |
---|
| 110 | */ |
---|
| 111 | double LamellarPCrystalModel :: evaluate_rphi(double q, double phi) { |
---|
| 112 | return (*this).operator()(q); |
---|
| 113 | } |
---|
| 114 | /** |
---|
| 115 | * Function to calculate effective radius |
---|
| 116 | * @return: effective radius value |
---|
| 117 | */ |
---|
| 118 | double LamellarPCrystalModel :: calculate_ER() { |
---|
| 119 | //NOT implemented yet!!! |
---|
[34c2649] | 120 | return 0.0; |
---|
[339ce67] | 121 | } |
---|