source: sasview/sansmodels/src/sans/models/c_models/vesicle.cpp @ 27953d1

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 27953d1 was 9188cc1, checked in by Jae Cho <jhjcho@…>, 15 years ago

corrected bkg values for polydispersity cal and add doc

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