source: sasview/sansmodels/src/c_models/lamellarPC.cpp @ d555416

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 d555416 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.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
21#include <math.h>
22#include "parameters.hh"
23#include <stdio.h>
24using namespace std;
25#include "lamellarPC.h"
26
27extern "C" {
28#include "libCylinder.h"
29}
30
31LamellarPCrystalModel :: LamellarPCrystalModel() {
32  scale      = Parameter(1.0);
33  thickness     = Parameter(33.0, true);
34  thickness.set_min(0.0);
35  Nlayers    = Parameter(20.0, true);
36  Nlayers.set_min(0.0);
37  spacing   = Parameter(250);
38  pd_spacing   = Parameter(0.0);
39  sld_layer  = Parameter(1.0e-6);
40  sld_solvent    = Parameter(6.34e-6);
41  background = Parameter(0.0);
42
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 LamellarPCrystalModel :: operator()(double q) {
52  double dp[8];
53
54  // Fill parameter array for IGOR library
55  // Add the background after averaging
56  dp[0] = scale();
57  dp[1] = thickness();
58  dp[2] = Nlayers();
59  dp[3] = spacing();
60  dp[4] = pd_spacing();
61  dp[5] = sld_layer();
62  dp[6] = sld_solvent();
63  dp[7] = 0.0; // Do not apply background here.
64
65  // Get the dispersion points for the head thickness
66  vector<WeightPoint> weights_thickness;
67  thickness.get_weights(weights_thickness);
68
69  // Let's provide from the func which is more accurate especially for small q region.
70  // Get the dispersion points for the tail length
71  //vector<WeightPoint> weights_spacing;
72  //spacing.get_weights(weights_spacing);
73
74  // Perform the computation, with all weight points
75  double sum = 0.0;
76  double norm = 0.0;
77
78  // Loop over thickness and spacing weight points
79  for(int i=0; i< (int)weights_thickness.size(); i++) {
80    dp[1] = weights_thickness[i].value;
81    //for (int j=0; j< (int)weights_spacing.size(); j++){
82    //dp[3] = weights_spacing[j].value;
83    sum += weights_thickness[i].weight*Lamellar_ParaCrystal(dp, q);
84    norm += weights_thickness[i].weight;
85    //}
86  }
87  //apply norm and background
88  return sum/norm + background();
89}
90
91/**
92 * Function to evaluate 2D scattering function
93 * @param q_x: value of Q along x
94 * @param q_y: value of Q along y
95 * @return: function value
96 */
97
98double LamellarPCrystalModel :: operator()(double qx, double qy) {
99  double q = sqrt(qx*qx + qy*qy);
100  return (*this).operator()(q);
101}
102
103/**
104 * Function to evaluate 2D scattering function
105 * @param pars: parameters of the lamellar
106 * @param q: q-value
107 * @param phi: angle phi
108 * @return: function value
109 */
110double LamellarPCrystalModel :: evaluate_rphi(double q, double phi) {
111  return (*this).operator()(q);
112}
113/**
114 * Function to calculate effective radius
115 * @return: effective radius value
116 */
117double LamellarPCrystalModel :: calculate_ER() {
118  //NOT implemented yet!!!
119  return 0.0;
120}
121double LamellarPCrystalModel :: calculate_VR() {
122  return 1.0;
123}
Note: See TracBrowser for help on using the repository browser.