source: sasview/sansmodels/src/c_models/HayterMSA.cpp @ 4e0dfe4

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 4e0dfe4 was e08bd5b, checked in by Jae Cho <jhjcho@…>, 13 years ago

c models fix: scale fix for P*S

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[25579e8]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 */
22
23#include <math.h>
24#include "parameters.hh"
25#include <stdio.h>
26using namespace std;
[0ba3b08]27#include "HayterMSA.h"
[25579e8]28
29extern "C" {
[0ba3b08]30#include "libStructureFactor.h"
[25579e8]31}
32
33HayterMSAStructure :: HayterMSAStructure() {
[0ba3b08]34  effect_radius      = Parameter(20.75, true);
35  effect_radius.set_min(0.0);
36  charge      = Parameter(19.0, true);
37  volfraction = Parameter(0.0192, true);
38  volfraction.set_min(0.0);
39  temperature = Parameter(318.16, true);
40  temperature.set_min(0.0);
41  saltconc   = Parameter(0.0);
42  dielectconst  = Parameter(71.08);
[25579e8]43}
44
45/**
46 * Function to evaluate 1D scattering function
47 * The NIST IGOR library is used for the actual calculation.
48 * @param q: q-value
49 * @return: function value
50 */
51double HayterMSAStructure :: operator()(double q) {
[0ba3b08]52  double dp[6];
53
54  // Fill parameter array for IGOR library
55  // Add the background after averaging
56  dp[0] = 2.0*effect_radius();
57  dp[1] = fabs(charge());
58  dp[2] = volfraction();
59  dp[3] = temperature();
60  dp[4] = saltconc();
61  dp[5] = dielectconst();
62
63  // Get the dispersion points for the radius
64  vector<WeightPoint> weights_rad;
65  effect_radius.get_weights(weights_rad);
66
67  // Perform the computation, with all weight points
68  double sum = 0.0;
69  double norm = 0.0;
70
71  // Loop over radius weight points
72  for(size_t i=0; i<weights_rad.size(); i++) {
73    dp[0] = 2.0*weights_rad[i].value;
74
75    sum += weights_rad[i].weight
76        * HayterPenfoldMSA(dp, q);
77    norm += weights_rad[i].weight;
78  }
79  return sum/norm ;
[25579e8]80}
81
82/**
83 * Function to evaluate 2D scattering function
84 * @param q_x: value of Q along x
85 * @param q_y: value of Q along y
86 * @return: function value
87 */
88double HayterMSAStructure :: operator()(double qx, double qy) {
[0ba3b08]89  double q = sqrt(qx*qx + qy*qy);
90  return (*this).operator()(q);
[25579e8]91}
92
93/**
94 * Function to evaluate 2D scattering function
95 * @param pars: parameters of the cylinder
96 * @param q: q-value
97 * @param phi: angle phi
98 * @return: function value
99 */
100double HayterMSAStructure :: evaluate_rphi(double q, double phi) {
[0ba3b08]101  double qx = q*cos(phi);
102  double qy = q*sin(phi);
103  return (*this).operator()(qx, qy);
[25579e8]104}
[5eb9154]105/**
106 * Function to calculate effective radius
107 * @return: effective radius value
108 */
109double HayterMSAStructure :: calculate_ER() {
[0ba3b08]110  //NOT implemented yet!!!
[6110bb8]111  return 0.0;
[5eb9154]112}
[e08bd5b]113double HayterMSAStructure :: calculate_VR() {
114  return 1.0;
115}
Note: See TracBrowser for help on using the repository browser.