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

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 f82fe3c was f9bf661, checked in by Jae Cho <jhjcho@…>, 15 years ago

updated documents

  • Property mode set to 100644
File size: 4.9 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}
138
139/*
140double LamellarPSHGModel :: operator()(double qx, double qy) {
141        LamellarPSHGParameters dp;
142        // Fill parameter array
143        dp.scale      = scale();
144        dp.spacing   = spacing();
145        dp.deltaT  = deltaT();
146        dp.deltaH = deltaH();
147        dp.sld_tail   = sld_tail();
148        dp.sld_head = sld_head();
149        dp.sld_solvent   = sld_solvent();
150        dp.n_plates = n_plates();
151        dp.caille = caille();
152        dp.background    = background();
153
154        // Get the dispersion points for the deltaT
155        vector<WeightPoint> weights_deltaT;
156        deltaT.get_weights(weights_deltaT);
157
158        // Get the dispersion points for the deltaH
159        vector<WeightPoint> weights_deltaH;
160        deltaH.get_weights(weights_deltaH);
161
162        // Perform the computation, with all weight points
163        double sum = 0.0;
164        double norm = 0.0;
165
166        // Loop over deltaT weight points
167        for(int i=0; i< (int)weights_deltaT.size(); i++) {
168                dp.deltaT = weights_deltaT[i].value;
169
170                // Loop over deltaH weight points
171                for(int j=0; j< (int)weights_deltaH.size(); j++) {
172                        dp.deltaH = weights_deltaH[j].value;
173
174                        sum += weights_deltaT[i].weight *weights_deltaH[j].weight *lamellarPS_HG_analytical_2DXY(&dp, qx, qy);
175                        norm += weights_deltaT[i].weight * weights_deltaH[j].weight;
176                }
177        }
178        return sum/norm + background();
179}
180*/
181
182
Note: See TracBrowser for help on using the repository browser.