source: sasview/sansmodels/src/c_models/teubner_strey.cpp @ 657e52c

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 657e52c was f8644dd, checked in by Kieran Campbell <kieranrcampbell@…>, 12 years ago

Fixed calculation functions to pass unit tests

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/**
2        This software was developed by Institut Laue-Langevin as part of
3        Distributed Data Analysis of Neutron Scattering Experiments (DANSE).
4
5        Copyright 2012 Institut Laue-Langevin
6
7**/
8
9#include <math.h>
10#include "parameters.hh"
11#include "teubner_strey.h"
12
13TeubnerStreyModel::TeubnerStreyModel() {
14  scale = Parameter(0.1);
15  c1 = Parameter(-30.0);
16  c2 = Parameter(5000.0);
17  background = Parameter(0.0);
18}
19
20double TeubnerStreyModel::operator()(double q) { 
21  double d_scale = scale();
22  double d_c1 = c1();
23  double d_c2 = c2();
24  double d_background = background();
25
26  double term1 = d_c1 * pow(q,2);
27  double term2 = d_c2 * pow(q,4);
28
29  return 1/(d_scale + term1 + term2) + d_background;
30
31}
32
33
34double TeubnerStreyModel::operator()(double qx,double qy) {
35  double q = sqrt(qx*qx + qy*qy);
36  return this->operator()(q);
37}
38
39double TeubnerStreyModel::calculate_ER() {
40  // not implemented yet
41  return 0.0;
42}
43
44double TeubnerStreyModel::calculate_VR() {
45  return 1.0;
46}
47
48double TeubnerStreyModel::evaluate_rphi(double q,double phi) {
49  double qx = q*cos(phi);
50  double qy = q*sin(phi);
51  return this->operator()(qx, qy);
52}
53
54
55
56/***
57    Notes
58
59    This file was ported from python to C++ at ILL Grenoble in
60    July 2012. In the original python file were two functions,
61    teubnerStreyLengths and teubnerStreyDistance that did not appear
62    to be used anywhere in the code. The source for them is below:
63
64    def teubnerStreyLengths(self):
65        """
66            Calculate the correlation length (L)
67            @return L: the correlation distance
68        """
69        return  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\
70                            +(self.params['c1']/(4*self.params['c2'])),-1/2 )
71    def teubnerStreyDistance(self):
72        """
73            Calculate the quasi-periodic repeat distance (D/(2*pi))
74            @return D: quasi-periodic repeat distance
75        """
76        return  math.pow( 1/2 * math.pow( (self.params['scale']/self.params['c2']), 1/2 )\
77                            -(self.params['c1']/(4*self.params['c2'])),-1/2 )
78
79
80***/
Note: See TracBrowser for help on using the repository browser.