source: sasview/sansmodels/src/sans/models/c_models/flexiblecylinder.cpp @ 8e91f01

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 8e91f01 was 2cc633b, checked in by Jae Cho <jhjcho@…>, 15 years ago

FIXED A BUG

  • Property mode set to 100644
File size: 3.4 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 *      TODO: refactor so that we pull in the old sansmodels.c_extensions
21 *      TODO: add 2d
22 */
23
24#include <math.h>
25#include "models.hh"
26#include "parameters.hh"
27#include <stdio.h>
28using namespace std;
29
30extern "C" {
31        #include "libCylinder.h"
32        #include "flexible_cylinder.h"
33}
34
35FlexibleCylinderModel :: FlexibleCylinderModel() {
36        scale      = Parameter(1.0);
37        length     = Parameter(1000.0, true);
38        length.set_min(0.0);
39        kuhn_length = Parameter(100.0, true);
40        kuhn_length.set_min(0.0);
41        radius  = Parameter(20.0, true);
42        radius.set_min(0.0);
43        contrast   = Parameter(5.3e-6);
44        background = Parameter(0.0001);
45}
46
47/**
48 * Function to evaluate 1D scattering function
49 * The NIST IGOR library is used for the actual calculation.
50 * @param q: q-value
51 * @return: function value
52 */
53double FlexibleCylinderModel :: operator()(double q) {
54        double dp[6];
55
56        // Fill parameter array for IGOR library
57        // Add the background after averaging
58        dp[0] = scale();
59        dp[1] = length();
60        dp[2] = kuhn_length();
61        dp[3] = radius();
62        dp[4] = contrast();
63        dp[5] = background();
64
65        // Get the dispersion points for the length
66        vector<WeightPoint> weights_len;
67        length.get_weights(weights_len);
68
69        // Get the dispersion points for the kuhn_length
70        vector<WeightPoint> weights_kuhn;
71        kuhn_length.get_weights(weights_kuhn);
72
73        // Get the dispersion points for the radius
74        vector<WeightPoint> weights_rad;
75        radius.get_weights(weights_rad);
76
77        // Perform the computation, with all weight points
78        double sum = 0.0;
79        double norm = 0.0;
80
81        // Loop over semi axis A weight points
82        for(int i=0; i< (int)weights_len.size(); i++) {
83                dp[1] = weights_len[i].value;
84
85                // Loop over semi axis B weight points
86                for(int j=0; j< (int)weights_kuhn.size(); j++) {
87                        dp[2] = weights_kuhn[j].value;
88
89                        // Loop over semi axis C weight points
90                        for(int k=0; k< (int)weights_rad.size(); k++) {
91                                dp[3] = weights_rad[k].value;
92
93                                sum += weights_len[i].weight
94                                        * weights_kuhn[j].weight*weights_rad[k].weight * FlexExclVolCyl(dp, q);
95                                norm += weights_len[i].weight
96                                        * weights_kuhn[j].weight*weights_rad[k].weight;
97                        }
98                }
99        }
100        return sum/norm + background();
101}
102
103/**
104 * Function to evaluate 2D scattering function
105 * @param q_x: value of Q along x
106 * @param q_y: value of Q along y
107 * @return: function value
108 */
109double FlexibleCylinderModel :: operator()(double qx, double qy) {
110        double q = sqrt(qx*qx + qy*qy);
111        return (*this).operator()(q);
112}
113
114/**
115 * Function to evaluate 2D scattering function
116 * @param pars: parameters of the triaxial ellipsoid
117 * @param q: q-value
118 * @param phi: angle phi
119 * @return: function value
120 */
121double FlexibleCylinderModel :: evaluate_rphi(double q, double phi) {
122        //double qx = q*cos(phi);
123        //double qy = q*sin(phi);
124        return (*this).operator()(q);
125}
Note: See TracBrowser for help on using the repository browser.