source: sasview/src/sas/models/c_extension/c_models/lamellar.cpp @ 60dca65c

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 60dca65c was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[230f479]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 "lamellar.h"
27
28/*  LamellarFFX  :  calculates the form factor of a lamellar structure - no S(q) effects included
29            -NO polydispersion included
30*/
31static double lamellar_kernel(double dp[], double q){
32  double scale,del,sld_bi,sld_sol,contr,bkg;    //local variables of coefficient wave
33  double inten, qval,Pq;
34  double Pi;
35
36
37  Pi = 4.0*atan(1.0);
38  scale = dp[0];
39  del = dp[1];
40  sld_bi = dp[2];
41  sld_sol = dp[3];
42  bkg = dp[4];
43  qval = q;
44  contr = sld_bi -sld_sol;
45
46  Pq = 2.0*contr*contr/qval/qval*(1.0-cos(qval*del));
47
48  inten = 2.0*Pi*scale*Pq/(qval*qval);    //this is now dimensionless...
49
50  inten /= del;     //normalize by the thickness (in A)
51
52  inten *= 1.0e8;   // 1/A to 1/cm
53
54  return(inten+bkg);
55}
56
57LamellarModel :: LamellarModel() {
58        scale      = Parameter(1.0);
59        bi_thick     = Parameter(50.0, true);
60        bi_thick.set_min(0.0);
61        sld_bi    = Parameter(1.0e-6);
62        sld_sol    = Parameter(6.3e-6);
63        background = Parameter(0.0);
64}
65
66/**
67 * Function to evaluate 1D scattering function
68 * The NIST IGOR library is used for the actual calculation.
69 * @param q: q-value
70 * @return: function value
71 */
72double LamellarModel :: operator()(double q) {
73        double dp[5];
74
75        // Fill parameter array for IGOR library
76        // Add the background after averaging
77        dp[0] = scale();
78        dp[1] = bi_thick();
79        dp[2] = sld_bi();
80        dp[3] = sld_sol();
81        dp[4] = 0.0;
82
83        // Get the dispersion points for the bi_thick
84        vector<WeightPoint> weights_bi_thick;
85        bi_thick.get_weights(weights_bi_thick);
86        // Perform the computation, with all weight points
87        double sum = 0.0;
88        double norm = 0.0;
89
90        // Loop over short_edgeA weight points
91        for(int i=0; i< (int)weights_bi_thick.size(); i++) {
92                dp[1] = weights_bi_thick[i].value;
93
94                sum += weights_bi_thick[i].weight * lamellar_kernel(dp, q);
95                norm += weights_bi_thick[i].weight;
96
97        }
98
99        return sum/norm + background();
100}
101
102/**
103 * Function to evaluate 2D scattering function
104 * @param q_x: value of Q along x
105 * @param q_y: value of Q along y
106 * @return: function value
107 */
108
109double LamellarModel :: 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 lamellar
117 * @param q: q-value
118 * @param phi: angle phi
119 * @return: function value
120 */
121double LamellarModel :: evaluate_rphi(double q, double phi) {
122        return (*this).operator()(q);
123}
124/**
125 * Function to calculate effective radius
126 * @return: effective radius value
127 */
128double LamellarModel :: calculate_ER() {
129//NOT implemented yet!!!
130        return 0.0;
131}
132double LamellarModel :: calculate_VR() {
133  return 1.0;
134}
Note: See TracBrowser for help on using the repository browser.