source: sasview/src/sas/models/c_extension/c_models/lamellarPS_HG.cpp @ b9a5f0e

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since b9a5f0e was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 3.7 KB
Line 
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>
26using namespace std;
27#include "lamellarPS_HG.h"
28
29extern "C" {
30        #include "libCylinder.h"
31}
32
33LamellarPSHGModel :: LamellarPSHGModel() {
34        scale      = Parameter(1.0);
35        spacing    = Parameter(40.0, true);
36        spacing.set_min(0.0);
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 */
56double 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();
70        dp[9] = 0.0;
71
72
73        // Get the dispersion points for (deltaT) thickness of the tail
74        vector<WeightPoint> weights_deltaT;
75        deltaT.get_weights(weights_deltaT);
76
77        // Get the dispersion points for (deltaH) thickness of the head
78        vector<WeightPoint> weights_deltaH;
79        deltaH.get_weights(weights_deltaH);
80
81        // Get the dispersion points for spacing
82        vector<WeightPoint> weights_spacing;
83        spacing.get_weights(weights_spacing);
84
85        // Perform the computation, with all weight points
86        double sum = 0.0;
87        double norm = 0.0;
88
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;
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                        }
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 */
114double LamellarPSHGModel :: operator()(double qx, double qy) {
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 */
126double LamellarPSHGModel :: evaluate_rphi(double q, double phi) {
127        return (*this).operator()(q);
128}
129/**
130 * Function to calculate effective radius
131 * @return: effective radius value
132 */
133double LamellarPSHGModel :: calculate_ER() {
134//NOT implemented yet!!!
135        return 0.0;
136}
137double LamellarPSHGModel :: calculate_VR() {
138  return 1.0;
139}
Note: See TracBrowser for help on using the repository browser.