source: sasview/src/sans/models/ReflAdvModel.py @ d09f0ae1

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since d09f0ae1 was 400155b, checked in by gonzalezm, 10 years ago

Implementing request from ticket 261 - default number of bins in Annulus [Phi View] is now 36 and the first bin is now centered at 0 degrees

  • Property mode set to 100644
File size: 12.1 KB
Line 
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"""
16Provide 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\refl_adv.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CReflAdvModel
28
29def create_ReflAdvModel():
30    """
31       Create a model instance
32    """
33    obj = ReflAdvModel()
34    # CReflAdvModel.__init__(obj) is called by
35    # the ReflAdvModel constructor
36    return obj
37
38class ReflAdvModel(CReflAdvModel, BaseComponent):
39    """
40    Class that evaluates a ReflAdvModel model.
41    This file was auto-generated from src\sans\models\include\refl_adv.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_layers        = 1.0
48    * scale           = 1.0
49    * thick_inter0    = 50.0 [A]
50    * func_inter0     = 0.0
51    * sld_bottom0     = 2.07e-06 [1/A^(2)]
52    * sld_medium      = 1e-06 [1/A^(2)]
53    * background      = 0.0
54    * sld_flat1       = 4e-06 [1/A^(2)]
55    * sld_flat2       = 3.5e-06 [1/A^(2)]
56    * sld_flat3       = 4e-06 [1/A^(2)]
57    * sld_flat4       = 3.5e-06 [1/A^(2)]
58    * sld_flat5       = 4e-06 [1/A^(2)]
59    * sld_flat6       = 3.5e-06 [1/A^(2)]
60    * sld_flat7       = 4e-06 [1/A^(2)]
61    * sld_flat8       = 3.5e-06 [1/A^(2)]
62    * sld_flat9       = 4e-06 [1/A^(2)]
63    * sld_flat10      = 3.5e-06 [1/A^(2)]
64    * thick_inter1    = 50.0 [A]
65    * thick_inter2    = 50.0 [A]
66    * thick_inter3    = 50.0 [A]
67    * thick_inter4    = 50.0 [A]
68    * thick_inter5    = 50.0 [A]
69    * thick_inter6    = 50.0 [A]
70    * thick_inter7    = 50.0 [A]
71    * thick_inter8    = 50.0 [A]
72    * thick_inter9    = 50.0 [A]
73    * thick_inter10   = 50.0 [A]
74    * thick_flat1     = 100.0 [A]
75    * thick_flat2     = 100.0 [A]
76    * thick_flat3     = 100.0 [A]
77    * thick_flat4     = 100.0 [A]
78    * thick_flat5     = 100.0 [A]
79    * thick_flat6     = 100.0 [A]
80    * thick_flat7     = 100.0 [A]
81    * thick_flat8     = 100.0 [A]
82    * thick_flat9     = 100.0 [A]
83    * thick_flat10    = 100.0 [A]
84    * func_inter1     = 0.0
85    * func_inter2     = 0.0
86    * func_inter3     = 0.0
87    * func_inter4     = 0.0
88    * func_inter5     = 0.0
89    * func_inter6     = 0.0
90    * func_inter7     = 0.0
91    * func_inter8     = 0.0
92    * func_inter9     = 0.0
93    * func_inter10    = 0.0
94    * sldIM_flat1     = 0.0 [1/A^(2)]
95    * sldIM_flat2     = 0.0 [1/A^(2)]
96    * sldIM_flat3     = 0.0 [1/A^(2)]
97    * sldIM_flat4     = 0.0 [1/A^(2)]
98    * sldIM_flat5     = 0.0 [1/A^(2)]
99    * sldIM_flat6     = 0.0 [1/A^(2)]
100    * sldIM_flat7     = 0.0 [1/A^(2)]
101    * sldIM_flat8     = 0.0 [1/A^(2)]
102    * sldIM_flat9     = 0.0 [1/A^(2)]
103    * sldIM_flat10    = 0.0 [1/A^(2)]
104    * nu_inter1       = 2.5
105    * nu_inter2       = 2.5
106    * nu_inter3       = 2.5
107    * nu_inter4       = 2.5
108    * nu_inter5       = 2.5
109    * nu_inter6       = 2.5
110    * nu_inter7       = 2.5
111    * nu_inter8       = 2.5
112    * nu_inter9       = 2.5
113    * nu_inter10      = 2.5
114    * sldIM_sub0      = 0.0
115    * sldIM_medium    = 0.0
116    * npts_inter      = 21.0
117    * nu_inter0       = 2.5
118
119    """
120       
121    def __init__(self, multfactor=1):
122        """ Initialization """
123        self.__dict__ = {}
124       
125        # Initialize BaseComponent first, then sphere
126        BaseComponent.__init__(self)
127        #apply(CReflAdvModel.__init__, (self,))
128
129        CReflAdvModel.__init__(self)
130        self.is_multifunc = False
131                       
132        ## Name of the model
133        self.name = "ReflAdvModel"
134        ## Model description
135        self.description = """
136        Calculate neutron reflectivity using the Parratt iterative formula
137                Parameters:
138                background:background
139                scale: scale factor
140                sld_bottom0: the SLD of the substrate
141                sld_medium: the SLD of the incident medium
142                or superstrate
143                sld_flatN: the SLD of the flat region of
144                the N'th layer
145                thick_flatN: the thickness of the flat
146                region of the N'th layer
147                func_interN: the function used to describe
148                the interface of the N'th layer
149                nu_interN: the coefficient for the func_interN
150                thick_interN: the thickness of the interface
151                of the N'th layer
152                Note: the layer number starts to increase
153                from the bottom (substrate) to the top.
154        """
155       
156        ## Parameter details [units, min, max]
157        self.details = {}
158        self.details['n_layers'] = ['', None, None]
159        self.details['scale'] = ['', None, None]
160        self.details['thick_inter0'] = ['[A]', None, None]
161        self.details['func_inter0'] = ['', None, None]
162        self.details['sld_bottom0'] = ['[1/A^(2)]', None, None]
163        self.details['sld_medium'] = ['[1/A^(2)]', None, None]
164        self.details['background'] = ['', None, None]
165        self.details['sld_flat1'] = ['[1/A^(2)]', None, None]
166        self.details['sld_flat2'] = ['[1/A^(2)]', None, None]
167        self.details['sld_flat3'] = ['[1/A^(2)]', None, None]
168        self.details['sld_flat4'] = ['[1/A^(2)]', None, None]
169        self.details['sld_flat5'] = ['[1/A^(2)]', None, None]
170        self.details['sld_flat6'] = ['[1/A^(2)]', None, None]
171        self.details['sld_flat7'] = ['[1/A^(2)]', None, None]
172        self.details['sld_flat8'] = ['[1/A^(2)]', None, None]
173        self.details['sld_flat9'] = ['[1/A^(2)]', None, None]
174        self.details['sld_flat10'] = ['[1/A^(2)]', None, None]
175        self.details['thick_inter1'] = ['[A]', None, None]
176        self.details['thick_inter2'] = ['[A]', None, None]
177        self.details['thick_inter3'] = ['[A]', None, None]
178        self.details['thick_inter4'] = ['[A]', None, None]
179        self.details['thick_inter5'] = ['[A]', None, None]
180        self.details['thick_inter6'] = ['[A]', None, None]
181        self.details['thick_inter7'] = ['[A]', None, None]
182        self.details['thick_inter8'] = ['[A]', None, None]
183        self.details['thick_inter9'] = ['[A]', None, None]
184        self.details['thick_inter10'] = ['[A]', None, None]
185        self.details['thick_flat1'] = ['[A]', None, None]
186        self.details['thick_flat2'] = ['[A]', None, None]
187        self.details['thick_flat3'] = ['[A]', None, None]
188        self.details['thick_flat4'] = ['[A]', None, None]
189        self.details['thick_flat5'] = ['[A]', None, None]
190        self.details['thick_flat6'] = ['[A]', None, None]
191        self.details['thick_flat7'] = ['[A]', None, None]
192        self.details['thick_flat8'] = ['[A]', None, None]
193        self.details['thick_flat9'] = ['[A]', None, None]
194        self.details['thick_flat10'] = ['[A]', None, None]
195        self.details['func_inter1'] = ['', None, None]
196        self.details['func_inter2'] = ['', None, None]
197        self.details['func_inter3'] = ['', None, None]
198        self.details['func_inter4'] = ['', None, None]
199        self.details['func_inter5'] = ['', None, None]
200        self.details['func_inter6'] = ['', None, None]
201        self.details['func_inter7'] = ['', None, None]
202        self.details['func_inter8'] = ['', None, None]
203        self.details['func_inter9'] = ['', None, None]
204        self.details['func_inter10'] = ['', None, None]
205        self.details['sldIM_flat1'] = ['[1/A^(2)]', None, None]
206        self.details['sldIM_flat2'] = ['[1/A^(2)]', None, None]
207        self.details['sldIM_flat3'] = ['[1/A^(2)]', None, None]
208        self.details['sldIM_flat4'] = ['[1/A^(2)]', None, None]
209        self.details['sldIM_flat5'] = ['[1/A^(2)]', None, None]
210        self.details['sldIM_flat6'] = ['[1/A^(2)]', None, None]
211        self.details['sldIM_flat7'] = ['[1/A^(2)]', None, None]
212        self.details['sldIM_flat8'] = ['[1/A^(2)]', None, None]
213        self.details['sldIM_flat9'] = ['[1/A^(2)]', None, None]
214        self.details['sldIM_flat10'] = ['[1/A^(2)]', None, None]
215        self.details['nu_inter1'] = ['', None, None]
216        self.details['nu_inter2'] = ['', None, None]
217        self.details['nu_inter3'] = ['', None, None]
218        self.details['nu_inter4'] = ['', None, None]
219        self.details['nu_inter5'] = ['', None, None]
220        self.details['nu_inter6'] = ['', None, None]
221        self.details['nu_inter7'] = ['', None, None]
222        self.details['nu_inter8'] = ['', None, None]
223        self.details['nu_inter9'] = ['', None, None]
224        self.details['nu_inter10'] = ['', None, None]
225        self.details['sldIM_sub0'] = ['', None, None]
226        self.details['sldIM_medium'] = ['', None, None]
227        self.details['npts_inter'] = ['', None, None]
228        self.details['nu_inter0'] = ['', None, None]
229
230        ## fittable parameters
231        self.fixed = []
232       
233        ## non-fittable parameters
234        self.non_fittable = ['n_layers',
235                             'func_inter0',
236                             'func_inter1',
237                             'func_inter2',
238                             'func_inter3',
239                             'func_inter4',
240                             'func_inter5',
241                             'func_inter5',
242                             'func_inter7',
243                             'func_inter8',
244                             'func_inter9',
245                             'func_inter10']
246       
247        ## parameters with orientation
248        self.orientation_params = []
249
250        ## parameters with magnetism
251        self.magnetic_params = []
252
253        self.category = None
254        self.multiplicity_info = None
255       
256    def __setstate__(self, state):
257        """
258        restore the state of a model from pickle
259        """
260        self.__dict__, self.params, self.dispersion = state
261       
262    def __reduce_ex__(self, proto):
263        """
264        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
265        c model.
266        """
267        state = (self.__dict__, self.params, self.dispersion)
268        return (create_ReflAdvModel, tuple(), state, None, None)
269       
270    def clone(self):
271        """ Return a identical copy of self """
272        return self._clone(ReflAdvModel())   
273       
274    def run(self, x=0.0):
275        """
276        Evaluate the model
277       
278        :param x: input q, or [q,phi]
279       
280        :return: scattering function P(q)
281       
282        """
283        return CReflAdvModel.run(self, x)
284   
285    def runXY(self, x=0.0):
286        """
287        Evaluate the model in cartesian coordinates
288       
289        :param x: input q, or [qx, qy]
290       
291        :return: scattering function P(q)
292       
293        """
294        return CReflAdvModel.runXY(self, x)
295       
296    def evalDistribution(self, x):
297        """
298        Evaluate the model in cartesian coordinates
299       
300        :param x: input q[], or [qx[], qy[]]
301       
302        :return: scattering function P(q[])
303       
304        """
305        return CReflAdvModel.evalDistribution(self, x)
306       
307    def calculate_ER(self):
308        """
309        Calculate the effective radius for P(q)*S(q)
310       
311        :return: the value of the effective radius
312       
313        """       
314        return CReflAdvModel.calculate_ER(self)
315       
316    def calculate_VR(self):
317        """
318        Calculate the volf ratio for P(q)*S(q)
319       
320        :return: the value of the volf ratio
321       
322        """       
323        return CReflAdvModel.calculate_VR(self)
324             
325    def set_dispersion(self, parameter, dispersion):
326        """
327        Set the dispersion object for a model parameter
328       
329        :param parameter: name of the parameter [string]
330        :param dispersion: dispersion object of type DispersionModel
331       
332        """
333        return CReflAdvModel.set_dispersion(self,
334               parameter, dispersion.cdisp)
335       
336   
337# End of file
338
Note: See TracBrowser for help on using the repository browser.