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/refl.h |
---|
23 | AND RE-RUN THE GENERATOR SCRIPT |
---|
24 | |
---|
25 | """ |
---|
26 | |
---|
27 | from sans.models.BaseComponent import BaseComponent |
---|
28 | from sans.models.sans_extension.c_models import CReflModel |
---|
29 | import copy |
---|
30 | |
---|
31 | def create_ReflModel(): |
---|
32 | obj = ReflModel() |
---|
33 | #CReflModel.__init__(obj) is called by ReflModel constructor |
---|
34 | return obj |
---|
35 | |
---|
36 | class ReflModel(CReflModel, BaseComponent): |
---|
37 | """ |
---|
38 | Class that evaluates a ReflModel model. |
---|
39 | This file was auto-generated from ../c_extensions/refl.h. |
---|
40 | Refer to that file and the structure it contains |
---|
41 | for details of the model. |
---|
42 | List of default parameters: |
---|
43 | n_layers = 1.0 |
---|
44 | scale = 1.0 |
---|
45 | thick_inter0 = 1.0 [A] |
---|
46 | func_inter0 = 0.0 |
---|
47 | sld_bottom0 = 2.07e-06 [1/A^(2)] |
---|
48 | sld_medium = 1e-06 [1/A^(2)] |
---|
49 | background = 0.0 |
---|
50 | sld_flat1 = 4e-06 [1/A^(2)] |
---|
51 | sld_flat2 = 3.5e-06 [1/A^(2)] |
---|
52 | sld_flat3 = 4e-06 [1/A^(2)] |
---|
53 | sld_flat4 = 3.5e-06 [1/A^(2)] |
---|
54 | sld_flat5 = 4e-06 [1/A^(2)] |
---|
55 | sld_flat6 = 3.5e-06 [1/A^(2)] |
---|
56 | sld_flat7 = 4e-06 [1/A^(2)] |
---|
57 | sld_flat8 = 3.5e-06 [1/A^(2)] |
---|
58 | sld_flat9 = 4e-06 [1/A^(2)] |
---|
59 | sld_flat10 = 3.5e-06 [1/A^(2)] |
---|
60 | thick_inter1 = 1.0 [A] |
---|
61 | thick_inter2 = 1.0 [A] |
---|
62 | thick_inter3 = 1.0 [A] |
---|
63 | thick_inter4 = 1.0 [A] |
---|
64 | thick_inter5 = 1.0 [A] |
---|
65 | thick_inter6 = 1.0 [A] |
---|
66 | thick_inter7 = 1.0 [A] |
---|
67 | thick_inter8 = 1.0 [A] |
---|
68 | thick_inter9 = 1.0 [A] |
---|
69 | thick_inter10 = 1.0 [A] |
---|
70 | thick_flat1 = 10.0 [A] |
---|
71 | thick_flat2 = 100.0 [A] |
---|
72 | thick_flat3 = 100.0 [A] |
---|
73 | thick_flat4 = 100.0 [A] |
---|
74 | thick_flat5 = 100.0 [A] |
---|
75 | thick_flat6 = 100.0 [A] |
---|
76 | thick_flat7 = 100.0 [A] |
---|
77 | thick_flat8 = 100.0 [A] |
---|
78 | thick_flat9 = 100.0 [A] |
---|
79 | thick_flat10 = 100.0 [A] |
---|
80 | func_inter1 = 0.0 |
---|
81 | func_inter2 = 0.0 |
---|
82 | func_inter3 = 0.0 |
---|
83 | func_inter4 = 0.0 |
---|
84 | func_inter5 = 0.0 |
---|
85 | func_inter6 = 0.0 |
---|
86 | func_inter7 = 0.0 |
---|
87 | func_inter8 = 0.0 |
---|
88 | func_inter9 = 0.0 |
---|
89 | func_inter10 = 0.0 |
---|
90 | |
---|
91 | """ |
---|
92 | |
---|
93 | def __init__(self): |
---|
94 | """ Initialization """ |
---|
95 | |
---|
96 | # Initialize BaseComponent first, then sphere |
---|
97 | BaseComponent.__init__(self) |
---|
98 | #apply(CReflModel.__init__, (self,)) |
---|
99 | CReflModel.__init__(self) |
---|
100 | |
---|
101 | ## Name of the model |
---|
102 | self.name = "ReflModel" |
---|
103 | ## Model description |
---|
104 | self.description ="""Calculate neutron reflectivity using the Parratt iterative formula |
---|
105 | Parameters: |
---|
106 | background:background |
---|
107 | scale: scale factor |
---|
108 | sld_bottom0: the SLD of the substrate |
---|
109 | sld_medium: the SLD of the incident medium |
---|
110 | or superstrate |
---|
111 | sld_flatN: the SLD of the flat region of |
---|
112 | the N'th layer |
---|
113 | thick_flatN: the thickness of the flat |
---|
114 | region of the N'th layer |
---|
115 | func_interN: the function used to describe |
---|
116 | the interface of the N'th layer |
---|
117 | thick_interN: the thickness of the interface |
---|
118 | of the N'th layer |
---|
119 | Note: the layer number starts to increase |
---|
120 | from the bottom (substrate) to the top.""" |
---|
121 | |
---|
122 | ## Parameter details [units, min, max] |
---|
123 | self.details = {} |
---|
124 | self.details['n_layers'] = ['', None, None] |
---|
125 | self.details['scale'] = ['', None, None] |
---|
126 | self.details['thick_inter0'] = ['[A]', None, None] |
---|
127 | self.details['func_inter0'] = ['', None, None] |
---|
128 | self.details['sld_bottom0'] = ['[1/A^(2)]', None, None] |
---|
129 | self.details['sld_medium'] = ['[1/A^(2)]', None, None] |
---|
130 | self.details['background'] = ['', None, None] |
---|
131 | self.details['sld_flat1'] = ['[1/A^(2)]', None, None] |
---|
132 | self.details['sld_flat2'] = ['[1/A^(2)]', None, None] |
---|
133 | self.details['sld_flat3'] = ['[1/A^(2)]', None, None] |
---|
134 | self.details['sld_flat4'] = ['[1/A^(2)]', None, None] |
---|
135 | self.details['sld_flat5'] = ['[1/A^(2)]', None, None] |
---|
136 | self.details['sld_flat6'] = ['[1/A^(2)]', None, None] |
---|
137 | self.details['sld_flat7'] = ['[1/A^(2)]', None, None] |
---|
138 | self.details['sld_flat8'] = ['[1/A^(2)]', None, None] |
---|
139 | self.details['sld_flat9'] = ['[1/A^(2)]', None, None] |
---|
140 | self.details['sld_flat10'] = ['[1/A^(2)]', None, None] |
---|
141 | self.details['thick_inter1'] = ['[A]', None, None] |
---|
142 | self.details['thick_inter2'] = ['[A]', None, None] |
---|
143 | self.details['thick_inter3'] = ['[A]', None, None] |
---|
144 | self.details['thick_inter4'] = ['[A]', None, None] |
---|
145 | self.details['thick_inter5'] = ['[A]', None, None] |
---|
146 | self.details['thick_inter6'] = ['[A]', None, None] |
---|
147 | self.details['thick_inter7'] = ['[A]', None, None] |
---|
148 | self.details['thick_inter8'] = ['[A]', None, None] |
---|
149 | self.details['thick_inter9'] = ['[A]', None, None] |
---|
150 | self.details['thick_inter10'] = ['[A]', None, None] |
---|
151 | self.details['thick_flat1'] = ['[A]', None, None] |
---|
152 | self.details['thick_flat2'] = ['[A]', None, None] |
---|
153 | self.details['thick_flat3'] = ['[A]', None, None] |
---|
154 | self.details['thick_flat4'] = ['[A]', None, None] |
---|
155 | self.details['thick_flat5'] = ['[A]', None, None] |
---|
156 | self.details['thick_flat6'] = ['[A]', None, None] |
---|
157 | self.details['thick_flat7'] = ['[A]', None, None] |
---|
158 | self.details['thick_flat8'] = ['[A]', None, None] |
---|
159 | self.details['thick_flat9'] = ['[A]', None, None] |
---|
160 | self.details['thick_flat10'] = ['[A]', None, None] |
---|
161 | self.details['func_inter1'] = ['', None, None] |
---|
162 | self.details['func_inter2'] = ['', None, None] |
---|
163 | self.details['func_inter3'] = ['', None, None] |
---|
164 | self.details['func_inter4'] = ['', None, None] |
---|
165 | self.details['func_inter5'] = ['', None, None] |
---|
166 | self.details['func_inter6'] = ['', None, None] |
---|
167 | self.details['func_inter7'] = ['', None, None] |
---|
168 | self.details['func_inter8'] = ['', None, None] |
---|
169 | self.details['func_inter9'] = ['', None, None] |
---|
170 | self.details['func_inter10'] = ['', None, None] |
---|
171 | |
---|
172 | ## fittable parameters |
---|
173 | self.fixed=[] |
---|
174 | |
---|
175 | ## non-fittable parameters |
---|
176 | self.non_fittable = ['n_layers', 'func_inter0', 'func_inter1', 'func_inter2', 'func_inter3', 'func_inter4', 'func_inter5', 'func_inter5', 'func_inter7', 'func_inter8', 'func_inter9', 'func_inter10'] |
---|
177 | |
---|
178 | ## parameters with orientation |
---|
179 | self.orientation_params = [] |
---|
180 | |
---|
181 | def __setstate__(self, state): |
---|
182 | """ |
---|
183 | restore the state of a model from pickle |
---|
184 | """ |
---|
185 | self.__dict__, self.params, self.dispersion = state |
---|
186 | |
---|
187 | def __reduce_ex__(self, proto): |
---|
188 | """ |
---|
189 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
190 | c model. |
---|
191 | """ |
---|
192 | state = (self.__dict__, self.params, self.dispersion) |
---|
193 | return (create_ReflModel,tuple(), state, None, None) |
---|
194 | |
---|
195 | def clone(self): |
---|
196 | """ Return a identical copy of self """ |
---|
197 | return self._clone(ReflModel()) |
---|
198 | |
---|
199 | |
---|
200 | def run(self, x=0.0): |
---|
201 | """ |
---|
202 | Evaluate the model |
---|
203 | |
---|
204 | :param x: input q, or [q,phi] |
---|
205 | |
---|
206 | :return: scattering function P(q) |
---|
207 | |
---|
208 | """ |
---|
209 | |
---|
210 | return CReflModel.run(self, x) |
---|
211 | |
---|
212 | def runXY(self, x=0.0): |
---|
213 | """ |
---|
214 | Evaluate the model in cartesian coordinates |
---|
215 | |
---|
216 | :param x: input q, or [qx, qy] |
---|
217 | |
---|
218 | :return: scattering function P(q) |
---|
219 | |
---|
220 | """ |
---|
221 | |
---|
222 | return CReflModel.runXY(self, x) |
---|
223 | |
---|
224 | def evalDistribution(self, x=[]): |
---|
225 | """ |
---|
226 | Evaluate the model in cartesian coordinates |
---|
227 | |
---|
228 | :param x: input q[], or [qx[], qy[]] |
---|
229 | |
---|
230 | :return: scattering function P(q[]) |
---|
231 | |
---|
232 | """ |
---|
233 | return CReflModel.evalDistribution(self, x) |
---|
234 | |
---|
235 | def calculate_ER(self): |
---|
236 | """ |
---|
237 | Calculate the effective radius for P(q)*S(q) |
---|
238 | |
---|
239 | :return: the value of the effective radius |
---|
240 | |
---|
241 | """ |
---|
242 | return CReflModel.calculate_ER(self) |
---|
243 | |
---|
244 | def set_dispersion(self, parameter, dispersion): |
---|
245 | """ |
---|
246 | Set the dispersion object for a model parameter |
---|
247 | |
---|
248 | :param parameter: name of the parameter [string] |
---|
249 | :param dispersion: dispersion object of type DispersionModel |
---|
250 | |
---|
251 | """ |
---|
252 | return CReflModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
253 | |
---|
254 | |
---|
255 | # End of file |
---|