source: sasview/sansmodels/src/sans/models/c_models/lamellarPS.cpp @ 7a69683

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 7a69683 was 27a0771, checked in by Gervaise Alina <gervyh@…>, 15 years ago

add more models

  • Property mode set to 100644
File size: 3.5 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.h"
33}
34
35LamellarPSModel :: LamellarPSModel() {
36        scale      = Parameter(1.0);
37        spacing    = Parameter(400.0);
38        delta     = Parameter(30.0, true);
39        delta.set_min(0.0);
40        sigma    = Parameter(0.15, true);
41        contrast   = Parameter(5.3e-6);
42        n_plates     = Parameter(20.0);
43        caille = Parameter(0.1);
44        background = Parameter(0.0);
45
46}
47
48/**
49 * Function to evaluate 1D scattering function
50 * The NIST IGOR library is used for the actual calculation.
51 * @param q: q-value
52 * @return: function value
53 */
54double LamellarPSModel :: operator()(double q) {
55        double dp[8];
56
57        // Fill parameter array for IGOR library
58        // Add the background after averaging
59        dp[0] = scale();
60        dp[1] = spacing();
61        dp[2] = delta();
62        dp[3] = sigma();
63        dp[4] = contrast();
64        dp[5] = n_plates();
65        dp[6] = caille();
66        dp[7] = background();
67       
68
69        // Get the dispersion points for (delta) thickness
70        vector<WeightPoint> weights_delta;
71        delta.get_weights(weights_delta);
72       
73        // Perform the computation, with all weight points
74        double sum = 0.0;
75        double norm = 0.0;
76       
77        // Loop over short_edgeA weight points
78        for(int i=0; i< (int)weights_delta.size(); i++) {
79                dp[2] = weights_delta[i].value;
80
81                sum += weights_delta[i].weight * LamellarPS(dp, q);
82                norm += weights_delta[i].weight;
83                               
84        }
85        return sum/norm + background();
86}
87/**
88 * Function to evaluate 2D scattering function
89 * @param q_x: value of Q along x
90 * @param q_y: value of Q along y
91 * @return: function value
92 */
93double LamellarPSModel :: operator()(double qx, double qy) {
94        LamellarPSParameters dp;
95        // Fill parameter array
96        dp.scale      = scale();
97        dp.spacing   = spacing();
98        dp.delta  = delta();
99        dp.sigma = sigma();
100        dp.contrast   = contrast();
101        dp.n_plates = n_plates();
102        dp.caille = caille();
103        dp.background    = background();
104       
105
106        // Get the dispersion points for the delta
107        vector<WeightPoint> weights_delta;
108        delta.get_weights(weights_delta);
109
110        // Perform the computation, with all weight points
111        double sum = 0.0;
112        double norm = 0.0;
113
114        // Loop over radius weight points
115        for(int i=0; i< (int)weights_delta.size(); i++) {
116                dp.delta = weights_delta[i].value;
117
118                sum += weights_delta[i].weight *lamellarPS_analytical_2DXY(&dp, qx, qy);       
119                norm += weights_delta[i].weight;       
120        }
121       
122        return sum/norm + background();
123}
124
125
126/**
127 * Function to evaluate 2D scattering function
128 * @param pars: parameters of the cylinder
129 * @param q: q-value
130 * @param phi: angle phi
131 * @return: function value
132 */
133double LamellarPSModel :: evaluate_rphi(double q, double phi) {
134        double qx = q*cos(phi);
135        double qy = q*sin(phi);
136        return (*this).operator()(qx, qy);
137}
Note: See TracBrowser for help on using the repository browser.