source: sasview/sansmodels/src/sans/models/c_models/coreshellsphere.cpp @ 87fbc60

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 87fbc60 was 0f5bc9f, checked in by Mathieu Doucet <doucetm@…>, 16 years ago

Update of all C models to the new style of C++ models

  • Property mode set to 100644
File size: 2.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 */
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
32CoreShellModel :: CoreShellModel() {
33        scale      = Parameter(1.0);
34        radius     = Parameter(60.0, true);
35        radius.set_min(0.0);
36        thickness  = Parameter(10.0, true);
37        thickness.set_min(0.0);
38        core_sld   = Parameter(1.e-6);
39        shell_sld  = Parameter(2.e-6);
40        solvent_sld = Parameter(3.e-6);
41        background = Parameter(0.0);
42}
43
44/**
45 * Function to evaluate 1D scattering function
46 * The NIST IGOR library is used for the actual calculation.
47 * @param q: q-value
48 * @return: function value
49 */
50double CoreShellModel :: operator()(double q) {
51        double dp[7];
52
53        // Fill parameter array for IGOR library
54        // Add the background after averaging
55
56        dp[0] = scale();
57        dp[1] = radius();
58        dp[2] = thickness();
59        dp[3] = core_sld();
60        dp[4] = shell_sld();
61        dp[5] = solvent_sld();
62        dp[6] = 0.0;
63
64
65        // Get the dispersion points for the radius
66        vector<WeightPoint> weights_rad;
67        radius.get_weights(weights_rad);
68
69        // Get the dispersion points for the thickness
70        vector<WeightPoint> weights_thick;
71        thickness.get_weights(weights_thick);
72
73        // Perform the computation, with all weight points
74        double sum = 0.0;
75        double norm = 0.0;
76
77        // Loop over radius weight points
78        for(int i=0; i<weights_rad.size(); i++) {
79                dp[1] = weights_rad[i].value;
80
81                // Loop over thickness weight points
82                for(int j=0; j<weights_thick.size(); j++) {
83                        dp[2] = weights_thick[j].value;
84
85                        sum += weights_rad[i].weight
86                                * weights_thick[j].weight * CoreShellForm(dp, q);
87                        norm += weights_rad[i].weight
88                                * weights_thick[j].weight;
89                }
90        }
91        return sum/norm + background();
92}
93
94/**
95 * Function to evaluate 2D scattering function
96 * @param q_x: value of Q along x
97 * @param q_y: value of Q along y
98 * @return: function value
99 */
100double CoreShellModel :: operator()(double qx, double qy) {
101        double q = sqrt(qx*qx + qy*qy);
102        return (*this).operator()(q);
103}
104
105/**
106 * Function to evaluate 2D scattering function
107 * @param pars: parameters of the sphere
108 * @param q: q-value
109 * @param phi: angle phi
110 * @return: function value
111 */
112double CoreShellModel :: evaluate_rphi(double q, double phi) {
113        return (*this).operator()(q);
114}
Note: See TracBrowser for help on using the repository browser.