1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | ############################################################################## |
---|
4 | # This software was developed by the University of Tennessee as part of the |
---|
5 | # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) |
---|
6 | # project funded by the US National Science Foundation. |
---|
7 | # |
---|
8 | # If you use DANSE applications to do scientific research that leads to |
---|
9 | # publication, we ask that you acknowledge the use of the software with the |
---|
10 | # following sentence: |
---|
11 | # |
---|
12 | # "This work benefited from DANSE software developed under NSF award DMR-0520547." |
---|
13 | # |
---|
14 | # copyright 2008, University of Tennessee |
---|
15 | ############################################################################## |
---|
16 | |
---|
17 | |
---|
18 | """ |
---|
19 | Provide functionality for a C extension model |
---|
20 | |
---|
21 | :WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY |
---|
22 | DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\onion.h |
---|
23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
24 | |
---|
25 | """ |
---|
26 | |
---|
27 | from sans.models.BaseComponent import BaseComponent |
---|
28 | from sans_extension.c_models import COnionModel |
---|
29 | import copy |
---|
30 | |
---|
31 | def create_OnionModel(): |
---|
32 | obj = OnionModel() |
---|
33 | #COnionModel.__init__(obj) is called by OnionModel constructor |
---|
34 | return obj |
---|
35 | |
---|
36 | class OnionModel(COnionModel, BaseComponent): |
---|
37 | """ |
---|
38 | Class that evaluates a OnionModel model. |
---|
39 | This file was auto-generated from ..\c_extensions\onion.h. |
---|
40 | Refer to that file and the structure it contains |
---|
41 | for details of the model. |
---|
42 | List of default parameters: |
---|
43 | n_shells = 1.0 |
---|
44 | scale = 1.0 |
---|
45 | rad_core0 = 200.0 [A] |
---|
46 | sld_core0 = 1e-006 [1/A^(2)] |
---|
47 | sld_solv = 6.4e-006 [1/A^(2)] |
---|
48 | background = 0.0 [1/cm] |
---|
49 | sld_out_shell1 = 2e-006 [1/A^(2)] |
---|
50 | sld_out_shell2 = 2.5e-006 [1/A^(2)] |
---|
51 | sld_out_shell3 = 3e-006 [1/A^(2)] |
---|
52 | sld_out_shell4 = 3.5e-006 [1/A^(2)] |
---|
53 | sld_out_shell5 = 4e-006 [1/A^(2)] |
---|
54 | sld_out_shell6 = 4.5e-006 [1/A^(2)] |
---|
55 | sld_out_shell7 = 5e-006 [1/A^(2)] |
---|
56 | sld_out_shell8 = 5.5e-006 [1/A^(2)] |
---|
57 | sld_out_shell9 = 6e-006 [1/A^(2)] |
---|
58 | sld_out_shell10 = 6.2e-006 [1/A^(2)] |
---|
59 | sld_in_shell1 = 1.7e-006 [1/A^(2)] |
---|
60 | sld_in_shell2 = 2.2e-006 [1/A^(2)] |
---|
61 | sld_in_shell3 = 2.7e-006 [1/A^(2)] |
---|
62 | sld_in_shell4 = 3.2e-006 [1/A^(2)] |
---|
63 | sld_in_shell5 = 3.7e-006 [1/A^(2)] |
---|
64 | sld_in_shell6 = 4.2e-006 [1/A^(2)] |
---|
65 | sld_in_shell7 = 4.7e-006 [1/A^(2)] |
---|
66 | sld_in_shell8 = 5.2e-006 [1/A^(2)] |
---|
67 | sld_in_shell9 = 5.7e-006 [1/A^(2)] |
---|
68 | sld_in_shell10 = 6e-006 [1/A^(2)] |
---|
69 | A_shell1 = 1.0 |
---|
70 | A_shell2 = 1.0 |
---|
71 | A_shell3 = 1.0 |
---|
72 | A_shell4 = 1.0 |
---|
73 | A_shell5 = 1.0 |
---|
74 | A_shell6 = 1.0 |
---|
75 | A_shell7 = 1.0 |
---|
76 | A_shell8 = 1.0 |
---|
77 | A_shell9 = 1.0 |
---|
78 | A_shell10 = 1.0 |
---|
79 | thick_shell1 = 50.0 [A] |
---|
80 | thick_shell2 = 50.0 [A] |
---|
81 | thick_shell3 = 50.0 [A] |
---|
82 | thick_shell4 = 50.0 [A] |
---|
83 | thick_shell5 = 50.0 [A] |
---|
84 | thick_shell6 = 50.0 [A] |
---|
85 | thick_shell7 = 50.0 [A] |
---|
86 | thick_shell8 = 50.0 [A] |
---|
87 | thick_shell9 = 50.0 [A] |
---|
88 | thick_shell10 = 50.0 [A] |
---|
89 | func_shell1 = 2.0 |
---|
90 | func_shell2 = 2.0 |
---|
91 | func_shell3 = 2.0 |
---|
92 | func_shell4 = 2.0 |
---|
93 | func_shell5 = 2.0 |
---|
94 | func_shell6 = 2.0 |
---|
95 | func_shell7 = 2.0 |
---|
96 | func_shell8 = 2.0 |
---|
97 | func_shell9 = 2.0 |
---|
98 | func_shell10 = 2.0 |
---|
99 | |
---|
100 | """ |
---|
101 | |
---|
102 | def __init__(self): |
---|
103 | """ Initialization """ |
---|
104 | |
---|
105 | # Initialize BaseComponent first, then sphere |
---|
106 | BaseComponent.__init__(self) |
---|
107 | #apply(COnionModel.__init__, (self,)) |
---|
108 | COnionModel.__init__(self) |
---|
109 | |
---|
110 | ## Name of the model |
---|
111 | self.name = "OnionModel" |
---|
112 | ## Model description |
---|
113 | self.description ="""Form factor of mutishells normalized by the volume. Here each shell is described |
---|
114 | by an exponential function; |
---|
115 | I) |
---|
116 | For A_shell != 0, |
---|
117 | f(r) = B*exp(A_shell*(r-r_in)/thick_shell)+C |
---|
118 | where |
---|
119 | B=(sld_out-sld_in)/(exp(A_shell)-1) |
---|
120 | C=sld_in-B. |
---|
121 | Note that in the above case, |
---|
122 | the function becomes a linear function |
---|
123 | as A_shell --> 0+ or 0-. |
---|
124 | II) |
---|
125 | For the exact point of A_shell == 0, |
---|
126 | f(r) = sld_in ,i.e., it crosses over flat function |
---|
127 | Note that the 'sld_out' becaomes NULL in this case. |
---|
128 | |
---|
129 | background:background, |
---|
130 | rad_core0: radius of sphere(core) |
---|
131 | thick_shell#:the thickness of the shell# |
---|
132 | sld_core0: the SLD of the sphere |
---|
133 | sld_solv: the SLD of the solvent |
---|
134 | sld_shell: the SLD of the shell# |
---|
135 | A_shell#: the coefficient in the exponential function""" |
---|
136 | |
---|
137 | ## Parameter details [units, min, max] |
---|
138 | self.details = {} |
---|
139 | self.details['n_shells'] = ['', None, None] |
---|
140 | self.details['scale'] = ['', None, None] |
---|
141 | self.details['rad_core0'] = ['[A]', None, None] |
---|
142 | self.details['sld_core0'] = ['[1/A^(2)]', None, None] |
---|
143 | self.details['sld_solv'] = ['[1/A^(2)]', None, None] |
---|
144 | self.details['background'] = ['[1/cm]', None, None] |
---|
145 | self.details['sld_out_shell1'] = ['[1/A^(2)]', None, None] |
---|
146 | self.details['sld_out_shell2'] = ['[1/A^(2)]', None, None] |
---|
147 | self.details['sld_out_shell3'] = ['[1/A^(2)]', None, None] |
---|
148 | self.details['sld_out_shell4'] = ['[1/A^(2)]', None, None] |
---|
149 | self.details['sld_out_shell5'] = ['[1/A^(2)]', None, None] |
---|
150 | self.details['sld_out_shell6'] = ['[1/A^(2)]', None, None] |
---|
151 | self.details['sld_out_shell7'] = ['[1/A^(2)]', None, None] |
---|
152 | self.details['sld_out_shell8'] = ['[1/A^(2)]', None, None] |
---|
153 | self.details['sld_out_shell9'] = ['[1/A^(2)]', None, None] |
---|
154 | self.details['sld_out_shell10'] = ['[1/A^(2)]', None, None] |
---|
155 | self.details['sld_in_shell1'] = ['[1/A^(2)]', None, None] |
---|
156 | self.details['sld_in_shell2'] = ['[1/A^(2)]', None, None] |
---|
157 | self.details['sld_in_shell3'] = ['[1/A^(2)]', None, None] |
---|
158 | self.details['sld_in_shell4'] = ['[1/A^(2)]', None, None] |
---|
159 | self.details['sld_in_shell5'] = ['[1/A^(2)]', None, None] |
---|
160 | self.details['sld_in_shell6'] = ['[1/A^(2)]', None, None] |
---|
161 | self.details['sld_in_shell7'] = ['[1/A^(2)]', None, None] |
---|
162 | self.details['sld_in_shell8'] = ['[1/A^(2)]', None, None] |
---|
163 | self.details['sld_in_shell9'] = ['[1/A^(2)]', None, None] |
---|
164 | self.details['sld_in_shell10'] = ['[1/A^(2)]', None, None] |
---|
165 | self.details['A_shell1'] = ['', None, None] |
---|
166 | self.details['A_shell2'] = ['', None, None] |
---|
167 | self.details['A_shell3'] = ['', None, None] |
---|
168 | self.details['A_shell4'] = ['', None, None] |
---|
169 | self.details['A_shell5'] = ['', None, None] |
---|
170 | self.details['A_shell6'] = ['', None, None] |
---|
171 | self.details['A_shell7'] = ['', None, None] |
---|
172 | self.details['A_shell8'] = ['', None, None] |
---|
173 | self.details['A_shell9'] = ['', None, None] |
---|
174 | self.details['A_shell10'] = ['', None, None] |
---|
175 | self.details['thick_shell1'] = ['[A]', None, None] |
---|
176 | self.details['thick_shell2'] = ['[A]', None, None] |
---|
177 | self.details['thick_shell3'] = ['[A]', None, None] |
---|
178 | self.details['thick_shell4'] = ['[A]', None, None] |
---|
179 | self.details['thick_shell5'] = ['[A]', None, None] |
---|
180 | self.details['thick_shell6'] = ['[A]', None, None] |
---|
181 | self.details['thick_shell7'] = ['[A]', None, None] |
---|
182 | self.details['thick_shell8'] = ['[A]', None, None] |
---|
183 | self.details['thick_shell9'] = ['[A]', None, None] |
---|
184 | self.details['thick_shell10'] = ['[A]', None, None] |
---|
185 | self.details['func_shell1'] = ['', None, None] |
---|
186 | self.details['func_shell2'] = ['', None, None] |
---|
187 | self.details['func_shell3'] = ['', None, None] |
---|
188 | self.details['func_shell4'] = ['', None, None] |
---|
189 | self.details['func_shell5'] = ['', None, None] |
---|
190 | self.details['func_shell6'] = ['', None, None] |
---|
191 | self.details['func_shell7'] = ['', None, None] |
---|
192 | self.details['func_shell8'] = ['', None, None] |
---|
193 | self.details['func_shell9'] = ['', None, None] |
---|
194 | self.details['func_shell10'] = ['', None, None] |
---|
195 | |
---|
196 | ## fittable parameters |
---|
197 | self.fixed=['rad_core0.width', 'thick_shell1.width', 'thick_shell2.width', 'thick_shell3.width', 'thick_shell4.width', 'thick_shell5.width', 'thick_shell6.width', 'thick_shell7.width', 'thick_shell8.width', 'thick_shell9.width', 'thick_shell10.width'] |
---|
198 | |
---|
199 | ## non-fittable parameters |
---|
200 | self.non_fittable = [] |
---|
201 | |
---|
202 | ## parameters with orientation |
---|
203 | self.orientation_params = [] |
---|
204 | |
---|
205 | def __setstate__(self, state): |
---|
206 | """ |
---|
207 | restore the state of a model from pickle |
---|
208 | """ |
---|
209 | self.__dict__, self.params, self.dispersion = state |
---|
210 | |
---|
211 | def __reduce_ex__(self, proto): |
---|
212 | """ |
---|
213 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
214 | c model. |
---|
215 | """ |
---|
216 | state = (self.__dict__, self.params, self.dispersion) |
---|
217 | return (create_OnionModel,tuple(), state, None, None) |
---|
218 | |
---|
219 | def clone(self): |
---|
220 | """ Return a identical copy of self """ |
---|
221 | return self._clone(OnionModel()) |
---|
222 | |
---|
223 | |
---|
224 | def run(self, x=0.0): |
---|
225 | """ |
---|
226 | Evaluate the model |
---|
227 | |
---|
228 | :param x: input q, or [q,phi] |
---|
229 | |
---|
230 | :return: scattering function P(q) |
---|
231 | |
---|
232 | """ |
---|
233 | |
---|
234 | return COnionModel.run(self, x) |
---|
235 | |
---|
236 | def runXY(self, x=0.0): |
---|
237 | """ |
---|
238 | Evaluate the model in cartesian coordinates |
---|
239 | |
---|
240 | :param x: input q, or [qx, qy] |
---|
241 | |
---|
242 | :return: scattering function P(q) |
---|
243 | |
---|
244 | """ |
---|
245 | |
---|
246 | return COnionModel.runXY(self, x) |
---|
247 | |
---|
248 | def evalDistribution(self, x=[]): |
---|
249 | """ |
---|
250 | Evaluate the model in cartesian coordinates |
---|
251 | |
---|
252 | :param x: input q[], or [qx[], qy[]] |
---|
253 | |
---|
254 | :return: scattering function P(q[]) |
---|
255 | |
---|
256 | """ |
---|
257 | return COnionModel.evalDistribution(self, x) |
---|
258 | |
---|
259 | def calculate_ER(self): |
---|
260 | """ |
---|
261 | Calculate the effective radius for P(q)*S(q) |
---|
262 | |
---|
263 | :return: the value of the effective radius |
---|
264 | |
---|
265 | """ |
---|
266 | return COnionModel.calculate_ER(self) |
---|
267 | |
---|
268 | def set_dispersion(self, parameter, dispersion): |
---|
269 | """ |
---|
270 | Set the dispersion object for a model parameter |
---|
271 | |
---|
272 | :param parameter: name of the parameter [string] |
---|
273 | :param dispersion: dispersion object of type DispersionModel |
---|
274 | |
---|
275 | """ |
---|
276 | return COnionModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
277 | |
---|
278 | |
---|
279 | # End of file |
---|