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\onion.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 COnionModel |
---|
28 | |
---|
29 | def create_OnionModel(): |
---|
30 | """ |
---|
31 | Create a model instance |
---|
32 | """ |
---|
33 | obj = OnionModel() |
---|
34 | # COnionModel.__init__(obj) is called by |
---|
35 | # the OnionModel constructor |
---|
36 | return obj |
---|
37 | |
---|
38 | class OnionModel(COnionModel, BaseComponent): |
---|
39 | """ |
---|
40 | Class that evaluates a OnionModel model. |
---|
41 | This file was auto-generated from src\sans\models\include\onion.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 | * n_shells = 1.0 |
---|
48 | * scale = 1.0 |
---|
49 | * rad_core0 = 200.0 [A] |
---|
50 | * sld_core0 = 1e-06 [1/A^(2)] |
---|
51 | * sld_solv = 6.4e-06 [1/A^(2)] |
---|
52 | * background = 0.0 [1/cm] |
---|
53 | * sld_out_shell1 = 2e-06 [1/A^(2)] |
---|
54 | * sld_out_shell2 = 2.5e-06 [1/A^(2)] |
---|
55 | * sld_out_shell3 = 3e-06 [1/A^(2)] |
---|
56 | * sld_out_shell4 = 3.5e-06 [1/A^(2)] |
---|
57 | * sld_out_shell5 = 4e-06 [1/A^(2)] |
---|
58 | * sld_out_shell6 = 4.5e-06 [1/A^(2)] |
---|
59 | * sld_out_shell7 = 5e-06 [1/A^(2)] |
---|
60 | * sld_out_shell8 = 5.5e-06 [1/A^(2)] |
---|
61 | * sld_out_shell9 = 6e-06 [1/A^(2)] |
---|
62 | * sld_out_shell10 = 6.2e-06 [1/A^(2)] |
---|
63 | * sld_in_shell1 = 1.7e-06 [1/A^(2)] |
---|
64 | * sld_in_shell2 = 2.2e-06 [1/A^(2)] |
---|
65 | * sld_in_shell3 = 2.7e-06 [1/A^(2)] |
---|
66 | * sld_in_shell4 = 3.2e-06 [1/A^(2)] |
---|
67 | * sld_in_shell5 = 3.7e-06 [1/A^(2)] |
---|
68 | * sld_in_shell6 = 4.2e-06 [1/A^(2)] |
---|
69 | * sld_in_shell7 = 4.7e-06 [1/A^(2)] |
---|
70 | * sld_in_shell8 = 5.2e-06 [1/A^(2)] |
---|
71 | * sld_in_shell9 = 5.7e-06 [1/A^(2)] |
---|
72 | * sld_in_shell10 = 6e-06 [1/A^(2)] |
---|
73 | * A_shell1 = 1.0 |
---|
74 | * A_shell2 = 1.0 |
---|
75 | * A_shell3 = 1.0 |
---|
76 | * A_shell4 = 1.0 |
---|
77 | * A_shell5 = 1.0 |
---|
78 | * A_shell6 = 1.0 |
---|
79 | * A_shell7 = 1.0 |
---|
80 | * A_shell8 = 1.0 |
---|
81 | * A_shell9 = 1.0 |
---|
82 | * A_shell10 = 1.0 |
---|
83 | * thick_shell1 = 50.0 [A] |
---|
84 | * thick_shell2 = 50.0 [A] |
---|
85 | * thick_shell3 = 50.0 [A] |
---|
86 | * thick_shell4 = 50.0 [A] |
---|
87 | * thick_shell5 = 50.0 [A] |
---|
88 | * thick_shell6 = 50.0 [A] |
---|
89 | * thick_shell7 = 50.0 [A] |
---|
90 | * thick_shell8 = 50.0 [A] |
---|
91 | * thick_shell9 = 50.0 [A] |
---|
92 | * thick_shell10 = 50.0 [A] |
---|
93 | * func_shell1 = 2.0 |
---|
94 | * func_shell2 = 2.0 |
---|
95 | * func_shell3 = 2.0 |
---|
96 | * func_shell4 = 2.0 |
---|
97 | * func_shell5 = 2.0 |
---|
98 | * func_shell6 = 2.0 |
---|
99 | * func_shell7 = 2.0 |
---|
100 | * func_shell8 = 2.0 |
---|
101 | * func_shell9 = 2.0 |
---|
102 | * func_shell10 = 2.0 |
---|
103 | |
---|
104 | """ |
---|
105 | |
---|
106 | def __init__(self, multfactor=1): |
---|
107 | """ Initialization """ |
---|
108 | self.__dict__ = {} |
---|
109 | |
---|
110 | # Initialize BaseComponent first, then sphere |
---|
111 | BaseComponent.__init__(self) |
---|
112 | #apply(COnionModel.__init__, (self,)) |
---|
113 | |
---|
114 | COnionModel.__init__(self) |
---|
115 | self.is_multifunc = False |
---|
116 | |
---|
117 | ## Name of the model |
---|
118 | self.name = "OnionModel" |
---|
119 | ## Model description |
---|
120 | self.description = """ |
---|
121 | Form factor of mutishells normalized by the volume. Here each shell is described |
---|
122 | by an exponential function; |
---|
123 | I) |
---|
124 | For A_shell != 0, |
---|
125 | f(r) = B*exp(A_shell*(r-r_in)/thick_shell)+C |
---|
126 | where |
---|
127 | B=(sld_out-sld_in)/(exp(A_shell)-1) |
---|
128 | C=sld_in-B. |
---|
129 | Note that in the above case, |
---|
130 | the function becomes a linear function |
---|
131 | as A_shell --> 0+ or 0-. |
---|
132 | II) |
---|
133 | For the exact point of A_shell == 0, |
---|
134 | f(r) = sld_in ,i.e., it crosses over flat function |
---|
135 | Note that the 'sld_out' becaomes NULL in this case. |
---|
136 | |
---|
137 | background:background, |
---|
138 | rad_core0: radius of sphere(core) |
---|
139 | thick_shell#:the thickness of the shell# |
---|
140 | sld_core0: the SLD of the sphere |
---|
141 | sld_solv: the SLD of the solvent |
---|
142 | sld_shell: the SLD of the shell# |
---|
143 | A_shell#: the coefficient in the exponential function |
---|
144 | """ |
---|
145 | |
---|
146 | ## Parameter details [units, min, max] |
---|
147 | self.details = {} |
---|
148 | self.details['n_shells'] = ['', None, None] |
---|
149 | self.details['scale'] = ['', None, None] |
---|
150 | self.details['rad_core0'] = ['[A]', None, None] |
---|
151 | self.details['sld_core0'] = ['[1/A^(2)]', None, None] |
---|
152 | self.details['sld_solv'] = ['[1/A^(2)]', None, None] |
---|
153 | self.details['background'] = ['[1/cm]', None, None] |
---|
154 | self.details['sld_out_shell1'] = ['[1/A^(2)]', None, None] |
---|
155 | self.details['sld_out_shell2'] = ['[1/A^(2)]', None, None] |
---|
156 | self.details['sld_out_shell3'] = ['[1/A^(2)]', None, None] |
---|
157 | self.details['sld_out_shell4'] = ['[1/A^(2)]', None, None] |
---|
158 | self.details['sld_out_shell5'] = ['[1/A^(2)]', None, None] |
---|
159 | self.details['sld_out_shell6'] = ['[1/A^(2)]', None, None] |
---|
160 | self.details['sld_out_shell7'] = ['[1/A^(2)]', None, None] |
---|
161 | self.details['sld_out_shell8'] = ['[1/A^(2)]', None, None] |
---|
162 | self.details['sld_out_shell9'] = ['[1/A^(2)]', None, None] |
---|
163 | self.details['sld_out_shell10'] = ['[1/A^(2)]', None, None] |
---|
164 | self.details['sld_in_shell1'] = ['[1/A^(2)]', None, None] |
---|
165 | self.details['sld_in_shell2'] = ['[1/A^(2)]', None, None] |
---|
166 | self.details['sld_in_shell3'] = ['[1/A^(2)]', None, None] |
---|
167 | self.details['sld_in_shell4'] = ['[1/A^(2)]', None, None] |
---|
168 | self.details['sld_in_shell5'] = ['[1/A^(2)]', None, None] |
---|
169 | self.details['sld_in_shell6'] = ['[1/A^(2)]', None, None] |
---|
170 | self.details['sld_in_shell7'] = ['[1/A^(2)]', None, None] |
---|
171 | self.details['sld_in_shell8'] = ['[1/A^(2)]', None, None] |
---|
172 | self.details['sld_in_shell9'] = ['[1/A^(2)]', None, None] |
---|
173 | self.details['sld_in_shell10'] = ['[1/A^(2)]', None, None] |
---|
174 | self.details['A_shell1'] = ['', None, None] |
---|
175 | self.details['A_shell2'] = ['', None, None] |
---|
176 | self.details['A_shell3'] = ['', None, None] |
---|
177 | self.details['A_shell4'] = ['', None, None] |
---|
178 | self.details['A_shell5'] = ['', None, None] |
---|
179 | self.details['A_shell6'] = ['', None, None] |
---|
180 | self.details['A_shell7'] = ['', None, None] |
---|
181 | self.details['A_shell8'] = ['', None, None] |
---|
182 | self.details['A_shell9'] = ['', None, None] |
---|
183 | self.details['A_shell10'] = ['', None, None] |
---|
184 | self.details['thick_shell1'] = ['[A]', None, None] |
---|
185 | self.details['thick_shell2'] = ['[A]', None, None] |
---|
186 | self.details['thick_shell3'] = ['[A]', None, None] |
---|
187 | self.details['thick_shell4'] = ['[A]', None, None] |
---|
188 | self.details['thick_shell5'] = ['[A]', None, None] |
---|
189 | self.details['thick_shell6'] = ['[A]', None, None] |
---|
190 | self.details['thick_shell7'] = ['[A]', None, None] |
---|
191 | self.details['thick_shell8'] = ['[A]', None, None] |
---|
192 | self.details['thick_shell9'] = ['[A]', None, None] |
---|
193 | self.details['thick_shell10'] = ['[A]', None, None] |
---|
194 | self.details['func_shell1'] = ['', None, None] |
---|
195 | self.details['func_shell2'] = ['', None, None] |
---|
196 | self.details['func_shell3'] = ['', None, None] |
---|
197 | self.details['func_shell4'] = ['', None, None] |
---|
198 | self.details['func_shell5'] = ['', None, None] |
---|
199 | self.details['func_shell6'] = ['', None, None] |
---|
200 | self.details['func_shell7'] = ['', None, None] |
---|
201 | self.details['func_shell8'] = ['', None, None] |
---|
202 | self.details['func_shell9'] = ['', None, None] |
---|
203 | self.details['func_shell10'] = ['', None, None] |
---|
204 | |
---|
205 | ## fittable parameters |
---|
206 | self.fixed = ['rad_core0.width', |
---|
207 | 'thick_shell1.width', |
---|
208 | 'thick_shell2.width', |
---|
209 | 'thick_shell3.width', |
---|
210 | 'thick_shell4.width', |
---|
211 | 'thick_shell5.width', |
---|
212 | 'thick_shell6.width', |
---|
213 | 'thick_shell7.width', |
---|
214 | 'thick_shell8.width', |
---|
215 | 'thick_shell9.width', |
---|
216 | 'thick_shell10.width'] |
---|
217 | |
---|
218 | ## non-fittable parameters |
---|
219 | self.non_fittable = [] |
---|
220 | |
---|
221 | ## parameters with orientation |
---|
222 | self.orientation_params = [] |
---|
223 | |
---|
224 | ## parameters with magnetism |
---|
225 | self.magnetic_params = [] |
---|
226 | |
---|
227 | self.category = None |
---|
228 | self.multiplicity_info = None |
---|
229 | |
---|
230 | def __setstate__(self, state): |
---|
231 | """ |
---|
232 | restore the state of a model from pickle |
---|
233 | """ |
---|
234 | self.__dict__, self.params, self.dispersion = state |
---|
235 | |
---|
236 | def __reduce_ex__(self, proto): |
---|
237 | """ |
---|
238 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
239 | c model. |
---|
240 | """ |
---|
241 | state = (self.__dict__, self.params, self.dispersion) |
---|
242 | return (create_OnionModel, tuple(), state, None, None) |
---|
243 | |
---|
244 | def clone(self): |
---|
245 | """ Return a identical copy of self """ |
---|
246 | return self._clone(OnionModel()) |
---|
247 | |
---|
248 | def run(self, x=0.0): |
---|
249 | """ |
---|
250 | Evaluate the model |
---|
251 | |
---|
252 | :param x: input q, or [q,phi] |
---|
253 | |
---|
254 | :return: scattering function P(q) |
---|
255 | |
---|
256 | """ |
---|
257 | return COnionModel.run(self, x) |
---|
258 | |
---|
259 | def runXY(self, x=0.0): |
---|
260 | """ |
---|
261 | Evaluate the model in cartesian coordinates |
---|
262 | |
---|
263 | :param x: input q, or [qx, qy] |
---|
264 | |
---|
265 | :return: scattering function P(q) |
---|
266 | |
---|
267 | """ |
---|
268 | return COnionModel.runXY(self, x) |
---|
269 | |
---|
270 | def evalDistribution(self, x): |
---|
271 | """ |
---|
272 | Evaluate the model in cartesian coordinates |
---|
273 | |
---|
274 | :param x: input q[], or [qx[], qy[]] |
---|
275 | |
---|
276 | :return: scattering function P(q[]) |
---|
277 | |
---|
278 | """ |
---|
279 | return COnionModel.evalDistribution(self, x) |
---|
280 | |
---|
281 | def calculate_ER(self): |
---|
282 | """ |
---|
283 | Calculate the effective radius for P(q)*S(q) |
---|
284 | |
---|
285 | :return: the value of the effective radius |
---|
286 | |
---|
287 | """ |
---|
288 | return COnionModel.calculate_ER(self) |
---|
289 | |
---|
290 | def calculate_VR(self): |
---|
291 | """ |
---|
292 | Calculate the volf ratio for P(q)*S(q) |
---|
293 | |
---|
294 | :return: the value of the volf ratio |
---|
295 | |
---|
296 | """ |
---|
297 | return COnionModel.calculate_VR(self) |
---|
298 | |
---|
299 | def set_dispersion(self, parameter, dispersion): |
---|
300 | """ |
---|
301 | Set the dispersion object for a model parameter |
---|
302 | |
---|
303 | :param parameter: name of the parameter [string] |
---|
304 | :param dispersion: dispersion object of type DispersionModel |
---|
305 | |
---|
306 | """ |
---|
307 | return COnionModel.set_dispersion(self, |
---|
308 | parameter, dispersion.cdisp) |
---|
309 | |
---|
310 | |
---|
311 | # End of file |
---|
312 | |
---|