source: sasview/sansmodels/src/c_models/TwoYukawa.cpp @ 5eb663a

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 5eb663a was 318b5bbb, checked in by Jae Cho <jhjcho@…>, 12 years ago

Added polarization and magnetic stuffs

  • Property mode set to 100644
File size: 3.0 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>
25//#include <iostream>
26using namespace std;
27#include "TwoYukawa.h"
28
29extern "C" {
30#include "2Y_TwoYukawa.h"
31}
32
33TwoYukawaModel :: TwoYukawaModel() {
34        // Model parameters
35        volfraction = Parameter(0.2, true);
36        effect_radius = Parameter(50.0, true);
37        effect_radius.set_min(0.0);
38        scale_K1 = Parameter(6.0);
39        decayConst_Z1 = Parameter(10.0);
40        scale_K2 = Parameter(-1.0);
41        decayConst_Z2 = Parameter(2.0); 
42}
43
44/**
45 * Function to evaluate 1D scattering function
46 * The NIST IGOR library is used for the actual calculation.
47 * @param q: q-value
48 * @return: function value
49 */
50double TwoYukawaModel :: operator()(double q) 
51{
52  double dp[6];
53  // Fill parameter array for IGOR library
54  // Add the background after averaging
55  dp[0] = volfraction();
56  dp[1] = effect_radius();
57  dp[2] = scale_K1();
58  dp[3] = decayConst_Z1();
59  dp[4] = scale_K2();
60  dp[5] = decayConst_Z2();
61 
62  double ZERO = 1.0e-24;
63  if (fabs(dp[2]) < 0.001){
64        return ZERO;
65        }
66  if (fabs(dp[3]) < 0.001){
67        return ZERO;
68        }
69  if (fabs(dp[4]) < 0.001){
70        return ZERO;
71        }
72  if (fabs(dp[5]) < 0.001){
73        return ZERO;
74        }
75       
76  double a, b, c1, c2, d1, d2;
77  int check = 1;
78  double x_in = q * dp[1] *2.0;
79  int ok = 0;
80 
81  ok = TY_SolveEquations(dp[3], dp[5], dp[2], dp[4], dp[0], &a, &b, &c1, &c2, &d1, &d2, 0);
82  if (ok > 0 ){
83        //check = TY_CheckSolution(dp[3], dp[5], dp[2], dp[4], dp[0], &a, &b, &c1, &c2, &d1, &d2);
84    if (check > 0){
85        return SqTwoYukawa(x_in, dp[3], dp[5], dp[2], dp[4], dp[0], a, b, c1, c2, d1, d2);
86    }
87    else{
88        return ZERO;
89    }
90  }
91  else{
92     return ZERO;
93  }
94}
95
96/**
97 * Function to evaluate 2D scattering function
98 * @param q_x: value of Q along x
99 * @param q_y: value of Q along y
100 * @return: function value
101 */
102double TwoYukawaModel :: operator()(double qx, double qy)
103{
104  double q = sqrt(qx*qx + qy*qy);
105  return (*this).operator()(q);
106}
107
108/**
109 * Function to evaluate 2D scattering function
110 * @param pars: parameters of the cylinder
111 * @param q: q-value
112 * @param phi: angle phi
113 * @return: function value
114 */
115double TwoYukawaModel :: evaluate_rphi(double q, double phi)
116{
117  double qx = q*cos(phi);
118  double qy = q*sin(phi);
119  return (*this).operator()(qx, qy);
120}
121/**
122 * Function to calculate effective radius
123 * @return: effective radius value
124 */
125double TwoYukawaModel :: calculate_ER()
126{
127  return effect_radius();
128}
129double TwoYukawaModel :: calculate_VR()
130{
131  return 1.0;
132}
133
Note: See TracBrowser for help on using the repository browser.