source: sasview/sansmodels/src/sans/models/c_models/vesicle.cpp @ 4785dec

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 4785dec was 5eb9154, checked in by Jae Cho <jhjcho@…>, 15 years ago

calculation of the effective radius are added

  • Property mode set to 100644
File size: 4.0 KB
RevLine 
[3d25331f]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"
[5eb9154]30        #include "vesicle.h"
[3d25331f]31}
32
33VesicleModel :: VesicleModel() {
34        scale      = Parameter(1.0);
[e2afadf]35        radius     = Parameter(100.0, true);
36        radius.set_min(0.0);
[42f193a]37        thickness  = Parameter(30.0, true);
38        thickness.set_min(0.0);
[3d25331f]39        core_sld   = Parameter(6.36e-6);
40        shell_sld   = Parameter(5.0e-7);
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 VesicleModel :: operator()(double q) {
51        double dp[6];
52
53        // Fill parameter array for IGOR library
54        // Add the background after averaging
55        dp[0] = scale();
[e2afadf]56        dp[1] = radius();
[3d25331f]57        dp[2] = thickness();
58        dp[3] = core_sld();
59        dp[4] = shell_sld();
[9188cc1]60        dp[5] = 0.0;
[42f193a]61
[3d25331f]62
63        // Get the dispersion points for the core radius
[e2afadf]64        vector<WeightPoint> weights_radius;
65        radius.get_weights(weights_radius);
[42f193a]66        // Get the dispersion points for the thickness
67        vector<WeightPoint> weights_thickness;
68        thickness.get_weights(weights_thickness);
[3d25331f]69
70        // Perform the computation, with all weight points
71        double sum = 0.0;
72        double norm = 0.0;
73
74        // Loop over radius weight points
[e2afadf]75        for(int i=0; i< (int)weights_radius.size(); i++) {
76                dp[1] = weights_radius[i].value;
77                for(int j=0; j< (int)weights_thickness.size(); j++) {
[42f193a]78                        dp[2] = weights_thickness[j].value;
[e2afadf]79                        sum += weights_radius[i].weight
[42f193a]80                                * weights_thickness[j].weight * VesicleForm(dp, q);
[e2afadf]81                        norm += weights_radius[i].weight * weights_thickness[j].weight;
[42f193a]82                }
[3d25331f]83        }
84        return sum/norm + background();
85}
86
87/**
88 * Function to evaluate 2D scattering function
89 * @param q_x: value of Q along x
90 * @param q_y: value of Q along y
91 * @return: function value
92 */
93double VesicleModel :: operator()(double qx, double qy) {
94        double q = sqrt(qx*qx + qy*qy);
95        return (*this).operator()(q);
96}
97
98/**
99 * Function to evaluate 2D scattering function
100 * @param pars: parameters of the vesicle
101 * @param q: q-value
102 * @param phi: angle phi
103 * @return: function value
104 */
105double VesicleModel :: evaluate_rphi(double q, double phi) {
106        return (*this).operator()(q);
107}
[5eb9154]108/**
109 * Function to calculate effective radius
110 * @param pars: parameters of the sphere
111 * @return: effective radius value
112 */
113double VesicleModel :: calculate_ER() {
114        VesicleParameters dp;
115
116        dp.radius     = radius();
117        dp.thickness  = thickness();
118
119        double rad_out = 0.0;
120
121        // Perform the computation, with all weight points
122        double sum = 0.0;
123        double norm = 0.0;
124
125
126        // Get the dispersion points for the major shell
127        vector<WeightPoint> weights_thickness;
128        thickness.get_weights(weights_thickness);
129
130        // Get the dispersion points for the minor shell
131        vector<WeightPoint> weights_radius ;
132        radius.get_weights(weights_radius);
133
134        // Loop over major shell weight points
135        for(int j=0; j< (int)weights_thickness.size(); j++) {
136                dp.thickness = weights_thickness[j].value;
137                for(int k=0; k< (int)weights_radius.size(); k++) {
138                        dp.radius = weights_radius[k].value;
139                        sum += weights_thickness[j].weight
140                                * weights_radius[k].weight*(dp.radius+dp.thickness);
141                        norm += weights_thickness[j].weight* weights_radius[k].weight;
142                }
143        }
144        if (norm != 0){
145                //return the averaged value
146                rad_out =  sum/norm;}
147        else{
148                //return normal value
149                rad_out = (dp.radius+dp.thickness);}
150
151        return rad_out;
152}
Note: See TracBrowser for help on using the repository browser.