source: sasview/sansmodels/src/sans/models/c_models/multishell.cpp @ d8a2e31

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

some corrections on dips-parameters and adding 2D cal

  • Property mode set to 100644
File size: 3.3 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 */
21
22#include <math.h>
23#include "models.hh"
24#include "parameters.hh"
25#include <stdio.h>
26using namespace std;
27
28extern "C" {
29        #include "libSphere.h"
30}
31
32MultiShellModel :: MultiShellModel() {
33        scale      = Parameter(1.0);
34        core_radius     = Parameter(60.0, true);
35        core_radius.set_min(0.0);
36        s_thickness  = Parameter(10.0, true);
37        s_thickness.set_min(0.0);
38        w_thickness   = Parameter(10.0, true);
39        w_thickness.set_min(0.0);
40        core_sld   = Parameter(6.4e-6);
41        shell_sld   = Parameter(4.0e-7);
42        n_pairs   = Parameter(2);
43        background = Parameter(0.0);
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 */
52double MultiShellModel :: 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] = core_radius();
59        dp[2] = s_thickness();
60        dp[3] = w_thickness();
61        dp[4] = core_sld();
62        dp[5] = shell_sld();
63        dp[6] = n_pairs();
64        dp[7] = 0.0;
65
66        // Get the dispersion points for the core radius
67        vector<WeightPoint> weights_core_radius;
68        core_radius.get_weights(weights_core_radius);
69
70        // Get the dispersion points for the s_thickness
71        vector<WeightPoint> weights_s_thickness;
72        s_thickness.get_weights(weights_s_thickness);
73
74        // Get the dispersion points for the w_thickness
75        vector<WeightPoint> weights_w_thickness;
76        w_thickness.get_weights(weights_w_thickness);
77
78        // Perform the computation, with all weight points
79        double sum = 0.0;
80        double norm = 0.0;
81
82        // Loop over radius weight points
83        for(int i=0; i< (int)weights_core_radius.size(); i++) {
84                dp[1] = weights_core_radius[i].value;
85                for(int j=0; j< (int)weights_s_thickness.size(); j++){
86                        dp[2] = weights_s_thickness[j].value;
87                        for(int k=0; k< (int)weights_w_thickness.size(); k++){
88                                dp[3] = weights_w_thickness[k].value;
89
90                                sum += weights_core_radius[i].weight*weights_s_thickness[j].weight
91                                        *weights_w_thickness[k].weight* MultiShell(dp, q);
92                                norm += weights_core_radius[i].weight*weights_s_thickness[j].weight
93                                        *weights_w_thickness[k].weight;
94                        }
95                }
96        }
97        return sum/norm + background();
98}
99
100/**
101 * Function to evaluate 2D scattering function
102 * @param q_x: value of Q along x
103 * @param q_y: value of Q along y
104 * @return: function value
105 */
106double MultiShellModel :: operator()(double qx, double qy) {
107        double q = sqrt(qx*qx + qy*qy);
108        return (*this).operator()(q);
109}
110
111/**
112 * Function to evaluate 2D scattering function
113 * @param pars: parameters of the multishell
114 * @param q: q-value
115 * @param phi: angle phi
116 * @return: function value
117 */
118double MultiShellModel :: evaluate_rphi(double q, double phi) {
119        return (*this).operator()(q);
120}
Note: See TracBrowser for help on using the repository browser.