source: sasview/sansmodels/src/sans/models/c_models/lamellarPS_HG.cpp @ 00c2141

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 00c2141 was 34c2649, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Re #4 Fixed warnings

  • Property mode set to 100644
File size: 5.0 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: 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>
28using namespace std;
29
30extern "C" {
31        #include "libCylinder.h"
32        #include "lamellarPS_HG.h"
33}
34
35LamellarPSHGModel :: LamellarPSHGModel() {
36        scale      = Parameter(1.0);
37        spacing    = Parameter(40.0, true);
38        spacing.set_min(0.0);
39        deltaT     = Parameter(10.0, true);
40        deltaT.set_min(0.0);
41        deltaH     = Parameter(2.0, true);
42        deltaH.set_min(0.0);
43        sld_tail    = Parameter(4e-7);
44        sld_head    = Parameter(2e-6);
45        sld_solvent   = Parameter(6e-6);
46        n_plates     = Parameter(30);
47        caille = Parameter(0.001);
48        background = Parameter(0.001);
49
50}
51
52/**
53 * Function to evaluate 1D scattering function
54 * The NIST IGOR library is used for the actual calculation.
55 * @param q: q-value
56 * @return: function value
57 */
58double LamellarPSHGModel :: operator()(double q) {
59        double dp[10];
60
61        // Fill parameter array for IGOR library
62        // Add the background after averaging
63        dp[0] = scale();
64        dp[1] = spacing();
65        dp[2] = deltaT();
66        dp[3] = deltaH();
67        dp[4] = sld_tail();
68        dp[5] = sld_head();
69        dp[6] = sld_solvent();
70        dp[7] = n_plates();
71        dp[8] = caille();
72        dp[9] = 0.0;
73
74
75        // Get the dispersion points for (deltaT) thickness of the tail
76        vector<WeightPoint> weights_deltaT;
77        deltaT.get_weights(weights_deltaT);
78
79        // Get the dispersion points for (deltaH) thickness of the head
80        vector<WeightPoint> weights_deltaH;
81        deltaH.get_weights(weights_deltaH);
82
83        // Get the dispersion points for spacing
84        vector<WeightPoint> weights_spacing;
85        spacing.get_weights(weights_spacing);
86
87        // Perform the computation, with all weight points
88        double sum = 0.0;
89        double norm = 0.0;
90
91        // Loop over deltaT  weight points
92        for(int i=0; i< (int)weights_deltaT.size(); i++) {
93                dp[2] = weights_deltaT[i].value;
94
95                // Loop over deltaH weight points
96                for(int j=0; j< (int)weights_deltaH.size(); j++) {
97                        dp[3] = weights_deltaH[j].value;
98                        // Loop over spacing weight points
99                        for(int k=0; k< (int)weights_spacing.size(); k++) {
100                                dp[1] = weights_spacing[k].value;
101
102                                sum += weights_deltaT[i].weight * weights_deltaH[j].weight *weights_spacing[k].weight
103                                                                *LamellarPS_HG(dp, q);
104                                norm += weights_deltaT[i].weight * weights_deltaH[j].weight * weights_spacing[k].weight;
105                        }
106                }
107        }
108        return sum/norm + background();
109}
110/**
111 * Function to evaluate 2D scattering function
112 * @param q_x: value of Q along x
113 * @param q_y: value of Q along y
114 * @return: function value
115 */
116double LamellarPSHGModel :: operator()(double qx, double qy) {
117        double q = sqrt(qx*qx + qy*qy);
118        return (*this).operator()(q);
119}
120
121/**
122 * Function to evaluate 2D scattering function
123 * @param pars: parameters of the lamellarPS_HG
124 * @param q: q-value
125 * @param phi: angle phi
126 * @return: function value
127 */
128double LamellarPSHGModel :: evaluate_rphi(double q, double phi) {
129        return (*this).operator()(q);
130}
131/**
132 * Function to calculate effective radius
133 * @return: effective radius value
134 */
135double LamellarPSHGModel :: calculate_ER() {
136//NOT implemented yet!!!
137        return 0.0;
138}
139
140/*
141double LamellarPSHGModel :: operator()(double qx, double qy) {
142        LamellarPSHGParameters dp;
143        // Fill parameter array
144        dp.scale      = scale();
145        dp.spacing   = spacing();
146        dp.deltaT  = deltaT();
147        dp.deltaH = deltaH();
148        dp.sld_tail   = sld_tail();
149        dp.sld_head = sld_head();
150        dp.sld_solvent   = sld_solvent();
151        dp.n_plates = n_plates();
152        dp.caille = caille();
153        dp.background    = background();
154
155        // Get the dispersion points for the deltaT
156        vector<WeightPoint> weights_deltaT;
157        deltaT.get_weights(weights_deltaT);
158
159        // Get the dispersion points for the deltaH
160        vector<WeightPoint> weights_deltaH;
161        deltaH.get_weights(weights_deltaH);
162
163        // Perform the computation, with all weight points
164        double sum = 0.0;
165        double norm = 0.0;
166
167        // Loop over deltaT weight points
168        for(int i=0; i< (int)weights_deltaT.size(); i++) {
169                dp.deltaT = weights_deltaT[i].value;
170
171                // Loop over deltaH weight points
172                for(int j=0; j< (int)weights_deltaH.size(); j++) {
173                        dp.deltaH = weights_deltaH[j].value;
174
175                        sum += weights_deltaT[i].weight *weights_deltaH[j].weight *lamellarPS_HG_analytical_2DXY(&dp, qx, qy);
176                        norm += weights_deltaT[i].weight * weights_deltaH[j].weight;
177                }
178        }
179        return sum/norm + background();
180}
181*/
182
183
Note: See TracBrowser for help on using the repository browser.