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-2011, University of Tennessee |
---|
13 | ############################################################################## |
---|
14 | |
---|
15 | """ |
---|
16 | Provide functionality for a C extension model |
---|
17 | |
---|
18 | .. WARNING:: |
---|
19 | |
---|
20 | THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
21 | DO NOT MODIFY THIS FILE, MODIFY |
---|
22 | src\sans\models\include\triaxial_ellipsoid.h |
---|
23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
24 | """ |
---|
25 | |
---|
26 | from sans.models.BaseComponent import BaseComponent |
---|
27 | from sans.models.sans_extension.c_models import CTriaxialEllipsoidModel |
---|
28 | |
---|
29 | def create_TriaxialEllipsoidModel(): |
---|
30 | """ |
---|
31 | Create a model instance |
---|
32 | """ |
---|
33 | obj = TriaxialEllipsoidModel() |
---|
34 | # CTriaxialEllipsoidModel.__init__(obj) is called by |
---|
35 | # the TriaxialEllipsoidModel constructor |
---|
36 | return obj |
---|
37 | |
---|
38 | class TriaxialEllipsoidModel(CTriaxialEllipsoidModel, BaseComponent): |
---|
39 | """ |
---|
40 | Class that evaluates a TriaxialEllipsoidModel model. |
---|
41 | This file was auto-generated from src\sans\models\include\triaxial_ellipsoid.h. |
---|
42 | Refer to that file and the structure it contains |
---|
43 | for details of the model. |
---|
44 | |
---|
45 | List of default parameters: |
---|
46 | |
---|
47 | * scale = 1.0 |
---|
48 | * semi_axisA = 35.0 [A] |
---|
49 | * semi_axisB = 100.0 [A] |
---|
50 | * semi_axisC = 400.0 [A] |
---|
51 | * sldEll = 1e-06 [1/A^(2)] |
---|
52 | * sldSolv = 6.3e-06 [1/A^(2)] |
---|
53 | * background = 0.0 [1/cm] |
---|
54 | * axis_theta = 57.325 [deg] |
---|
55 | * axis_phi = 57.325 [deg] |
---|
56 | * axis_psi = 0.0 [deg] |
---|
57 | |
---|
58 | """ |
---|
59 | |
---|
60 | def __init__(self, multfactor=1): |
---|
61 | """ Initialization """ |
---|
62 | self.__dict__ = {} |
---|
63 | |
---|
64 | # Initialize BaseComponent first, then sphere |
---|
65 | BaseComponent.__init__(self) |
---|
66 | #apply(CTriaxialEllipsoidModel.__init__, (self,)) |
---|
67 | |
---|
68 | CTriaxialEllipsoidModel.__init__(self) |
---|
69 | self.is_multifunc = False |
---|
70 | |
---|
71 | ## Name of the model |
---|
72 | self.name = "TriaxialEllipsoidModel" |
---|
73 | ## Model description |
---|
74 | self.description = """ |
---|
75 | Note: During fitting ensure that the inequality A<B<C is not |
---|
76 | violated. Otherwise the calculation will |
---|
77 | not be correct. |
---|
78 | """ |
---|
79 | |
---|
80 | ## Parameter details [units, min, max] |
---|
81 | self.details = {} |
---|
82 | self.details['scale'] = ['', None, None] |
---|
83 | self.details['semi_axisA'] = ['[A]', None, None] |
---|
84 | self.details['semi_axisB'] = ['[A]', None, None] |
---|
85 | self.details['semi_axisC'] = ['[A]', None, None] |
---|
86 | self.details['sldEll'] = ['[1/A^(2)]', None, None] |
---|
87 | self.details['sldSolv'] = ['[1/A^(2)]', None, None] |
---|
88 | self.details['background'] = ['[1/cm]', None, None] |
---|
89 | self.details['axis_theta'] = ['[deg]', None, None] |
---|
90 | self.details['axis_phi'] = ['[deg]', None, None] |
---|
91 | self.details['axis_psi'] = ['[deg]', None, None] |
---|
92 | |
---|
93 | ## fittable parameters |
---|
94 | self.fixed = ['axis_psi.width', |
---|
95 | 'axis_phi.width', |
---|
96 | 'axis_theta.width', |
---|
97 | 'semi_axisA.width', |
---|
98 | 'semi_axisB.width', |
---|
99 | 'semi_axisC.width'] |
---|
100 | |
---|
101 | ## non-fittable parameters |
---|
102 | self.non_fittable = [] |
---|
103 | |
---|
104 | ## parameters with orientation |
---|
105 | self.orientation_params = ['axis_psi', |
---|
106 | 'axis_phi', |
---|
107 | 'axis_theta', |
---|
108 | 'axis_psi.width', |
---|
109 | 'axis_phi.width', |
---|
110 | 'axis_theta.width'] |
---|
111 | |
---|
112 | ## parameters with magnetism |
---|
113 | self.magnetic_params = [] |
---|
114 | |
---|
115 | self.category = None |
---|
116 | self.multiplicity_info = None |
---|
117 | |
---|
118 | def __setstate__(self, state): |
---|
119 | """ |
---|
120 | restore the state of a model from pickle |
---|
121 | """ |
---|
122 | self.__dict__, self.params, self.dispersion = state |
---|
123 | |
---|
124 | def __reduce_ex__(self, proto): |
---|
125 | """ |
---|
126 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
127 | c model. |
---|
128 | """ |
---|
129 | state = (self.__dict__, self.params, self.dispersion) |
---|
130 | return (create_TriaxialEllipsoidModel, tuple(), state, None, None) |
---|
131 | |
---|
132 | def clone(self): |
---|
133 | """ Return a identical copy of self """ |
---|
134 | return self._clone(TriaxialEllipsoidModel()) |
---|
135 | |
---|
136 | def run(self, x=0.0): |
---|
137 | """ |
---|
138 | Evaluate the model |
---|
139 | |
---|
140 | :param x: input q, or [q,phi] |
---|
141 | |
---|
142 | :return: scattering function P(q) |
---|
143 | |
---|
144 | """ |
---|
145 | return CTriaxialEllipsoidModel.run(self, x) |
---|
146 | |
---|
147 | def runXY(self, x=0.0): |
---|
148 | """ |
---|
149 | Evaluate the model in cartesian coordinates |
---|
150 | |
---|
151 | :param x: input q, or [qx, qy] |
---|
152 | |
---|
153 | :return: scattering function P(q) |
---|
154 | |
---|
155 | """ |
---|
156 | return CTriaxialEllipsoidModel.runXY(self, x) |
---|
157 | |
---|
158 | def evalDistribution(self, x): |
---|
159 | """ |
---|
160 | Evaluate the model in cartesian coordinates |
---|
161 | |
---|
162 | :param x: input q[], or [qx[], qy[]] |
---|
163 | |
---|
164 | :return: scattering function P(q[]) |
---|
165 | |
---|
166 | """ |
---|
167 | return CTriaxialEllipsoidModel.evalDistribution(self, x) |
---|
168 | |
---|
169 | def calculate_ER(self): |
---|
170 | """ |
---|
171 | Calculate the effective radius for P(q)*S(q) |
---|
172 | |
---|
173 | :return: the value of the effective radius |
---|
174 | |
---|
175 | """ |
---|
176 | return CTriaxialEllipsoidModel.calculate_ER(self) |
---|
177 | |
---|
178 | def calculate_VR(self): |
---|
179 | """ |
---|
180 | Calculate the volf ratio for P(q)*S(q) |
---|
181 | |
---|
182 | :return: the value of the volf ratio |
---|
183 | |
---|
184 | """ |
---|
185 | return CTriaxialEllipsoidModel.calculate_VR(self) |
---|
186 | |
---|
187 | def set_dispersion(self, parameter, dispersion): |
---|
188 | """ |
---|
189 | Set the dispersion object for a model parameter |
---|
190 | |
---|
191 | :param parameter: name of the parameter [string] |
---|
192 | :param dispersion: dispersion object of type DispersionModel |
---|
193 | |
---|
194 | """ |
---|
195 | return CTriaxialEllipsoidModel.set_dispersion(self, |
---|
196 | parameter, dispersion.cdisp) |
---|
197 | |
---|
198 | |
---|
199 | # End of file |
---|
200 | |
---|