source: sasview/src/sas/models/c_extension/c_models/binaryHS_PSF11.cpp @ 50a77df

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 50a77df was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 3.7 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 "parameters.hh"
24#include <stdio.h>
25using namespace std;
26
27extern "C" {
28        #include "libSphere.h"
29}
30
31class BinaryHSPSF11Model{
32public:
33  // Model parameters
34  Parameter l_radius;
35  Parameter s_radius;
36  Parameter vol_frac_ls;
37  Parameter vol_frac_ss;
38  Parameter ls_sld;
39  Parameter ss_sld;
40  Parameter solvent_sld;
41  Parameter background;
42
43  //Constructor
44  BinaryHSPSF11Model();
45
46  //Operators to get I(Q)
47  double operator()(double q);
48  double operator()(double qx , double qy);
49  double calculate_ER();
50  double calculate_VR();
51  double evaluate_rphi(double q, double phi);
52};
53
54BinaryHSPSF11Model :: BinaryHSPSF11Model() {
55
56        l_radius     = Parameter(160.0, true);
57        l_radius.set_min(0.0);
58        s_radius    = Parameter(25.0, true);
59        s_radius.set_min(0.0);
60        vol_frac_ls  = Parameter(0.2);
61        vol_frac_ss  = Parameter(0.1);
62        ls_sld      = Parameter(3.5e-6);
63        ss_sld     = Parameter(5e-7);
64        solvent_sld   = Parameter(6.36e-6);
65        background = Parameter(0.0);
66}
67
68/**
69 * Function to evaluate 1D scattering function
70 * The NIST IGOR library is used for the actual calculation.
71 * @param q: q-value
72 * @return: function value
73 */
74double BinaryHSPSF11Model :: operator()(double q) {
75        double dp[8];
76
77        // Fill parameter array for IGOR library
78        // Add the background after averaging
79        dp[0] = l_radius();
80        dp[1] = s_radius();
81        dp[2] = vol_frac_ls();
82        dp[3] = vol_frac_ss();
83        dp[4] = ls_sld();
84        dp[5] = ss_sld();
85        dp[6] = solvent_sld();
86        dp[7] = 0.0;
87
88
89        // Get the dispersion points for the large radius
90        vector<WeightPoint> weights_l_radius;
91        l_radius.get_weights(weights_l_radius);
92
93        // Get the dispersion points for the small radius
94        vector<WeightPoint> weights_s_radius;
95        s_radius.get_weights(weights_s_radius);
96
97        // Perform the computation, with all weight points
98        double sum = 0.0;
99        double norm = 0.0;
100
101        // Loop over larger radius weight points
102        for(int i=0; i< (int)weights_l_radius.size(); i++) {
103                dp[0] = weights_l_radius[i].value;
104
105                // Loop over small radius weight points
106                for(int j=0; j< (int)weights_s_radius.size(); j++) {
107                        dp[1] = weights_s_radius[j].value;
108
109
110                        sum += weights_l_radius[i].weight *weights_s_radius[j].weight * BinaryHS_PSF11(dp, q);
111                        norm += weights_l_radius[i].weight *weights_s_radius[j].weight;
112                }
113        }
114        return sum/norm + background();
115}
116
117/**
118 * Function to evaluate 2D scattering function
119 * @param q_x: value of Q along x
120 * @param q_y: value of Q along y
121 * @return: function value
122 */
123double BinaryHSPSF11Model :: operator()(double qx, double qy) {
124        double q = sqrt(qx*qx + qy*qy);
125        return (*this).operator()(q);
126}
127
128/**
129 * Function to evaluate 2D scattering function
130 * @param pars: parameters of the vesicle
131 * @param q: q-value
132 * @param phi: angle phi
133 * @return: function value
134 */
135double BinaryHSPSF11Model :: evaluate_rphi(double q, double phi) {
136        return (*this).operator()(q);
137}
138/**
139 * Function to calculate effective radius
140 * @return: effective radius value
141 */
142double BinaryHSPSF11Model :: calculate_ER() {
143//NOT implemented yet!!!
144        return 0.0;
145}
146double BinaryHSPSF11Model :: calculate_VR() {
147  return 1.0;
148}
Note: See TracBrowser for help on using the repository browser.