source: sasview/sansmodels/src/sans/models/c_models/vesicle.cpp @ 2cc633b

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 2cc633b was 3d25331f, checked in by Gervaise Alina <gervyh@…>, 15 years ago

add more model 1d and 2 D

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