source: sasview/sansmodels/src/c_models/binaryHS.cpp @ 046af80

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 046af80 was 82c11d3, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

refactored bunch of models

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