[a269378] | 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 | |
---|
| 13 | TeubnerStreyModel::TeubnerStreyModel() { |
---|
| 14 | scale = Parameter(0.1); |
---|
| 15 | c1 = Parameter(-30.0); |
---|
| 16 | c2 = Parameter(5000.0); |
---|
| 17 | background = Parameter(0.0); |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | double 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 | |
---|
| 34 | double TeubnerStreyModel::operator()(double qx,double qy) { |
---|
| 35 | double q = sqrt(qx*qx + qy*qy); |
---|
| 36 | return this->operator()(q); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | double TeubnerStreyModel::calculate_ER() { |
---|
[f8644dd] | 40 | // not implemented yet |
---|
[a269378] | 41 | return 0.0; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | double TeubnerStreyModel::calculate_VR() { |
---|
[f8644dd] | 45 | return 1.0; |
---|
[a269378] | 46 | } |
---|
| 47 | |
---|
| 48 | double TeubnerStreyModel::evaluate_rphi(double q,double phi) { |
---|
[f8644dd] | 49 | double qx = q*cos(phi); |
---|
| 50 | double qy = q*sin(phi); |
---|
| 51 | return this->operator()(qx, qy); |
---|
[a269378] | 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
[f8644dd] | 55 | |
---|
[a269378] | 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 | ***/ |
---|