source: sasview/sansmodels/src/sans/models/ReflModel.py @ 74b1770

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 74b1770 was 339ce67, checked in by Jae Cho <jhjcho@…>, 14 years ago

added some models and tests

  • Property mode set to 100644
File size: 10.6 KB
Line 
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"""
19Provide 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
27from sans.models.BaseComponent import BaseComponent
28from sans_extension.c_models import CReflModel
29import copy   
30   
31class ReflModel(CReflModel, BaseComponent):
32    """
33    Class that evaluates a ReflModel model.
34    This file was auto-generated from ..\c_extensions\refl.h.
35    Refer to that file and the structure it contains
36    for details of the model.
37    List of default parameters:
38         n_layers        = 1.0
39         scale           = 1.0
40         thick_inter0    = 1.0 [A]
41         func_inter0     = 0.0
42         sld_sub0        = 2.07e-006 [1/A^(2)]
43         sld_medium      = 1e-006 [1/A^(2)]
44         background      = 0.0
45         sld_flat1       = 4e-006 [1/A^(2)]
46         sld_flat2       = 3.5e-006 [1/A^(2)]
47         sld_flat3       = 4e-006 [1/A^(2)]
48         sld_flat4       = 3.5e-006 [1/A^(2)]
49         sld_flat5       = 4e-006 [1/A^(2)]
50         sld_flat6       = 3.5e-006 [1/A^(2)]
51         sld_flat7       = 4e-006 [1/A^(2)]
52         sld_flat8       = 3.5e-006 [1/A^(2)]
53         sld_flat9       = 4e-006 [1/A^(2)]
54         sld_flat10      = 3.5e-006 [1/A^(2)]
55         thick_inter1    = 1.0 [A]
56         thick_inter2    = 1.0 [A]
57         thick_inter3    = 1.0 [A]
58         thick_inter4    = 1.0 [A]
59         thick_inter5    = 1.0 [A]
60         thick_inter6    = 1.0 [A]
61         thick_inter7    = 1.0 [A]
62         thick_inter8    = 1.0 [A]
63         thick_inter9    = 1.0 [A]
64         thick_inter10   = 1.0 [A]
65         thick_flat1     = 10.0 [A]
66         thick_flat2     = 100.0 [A]
67         thick_flat3     = 100.0 [A]
68         thick_flat4     = 100.0 [A]
69         thick_flat5     = 100.0 [A]
70         thick_flat6     = 100.0 [A]
71         thick_flat7     = 100.0 [A]
72         thick_flat8     = 100.0 [A]
73         thick_flat9     = 100.0 [A]
74         thick_flat10    = 100.0 [A]
75         func_inter1     = 0.0
76         func_inter2     = 0.0
77         func_inter3     = 0.0
78         func_inter4     = 0.0
79         func_inter5     = 0.0
80         func_inter6     = 0.0
81         func_inter7     = 0.0
82         func_inter8     = 0.0
83         func_inter9     = 0.0
84         func_inter10    = 0.0
85         sldIM_flat1     = 0.0
86         sldIM_flat2     = 0.0
87         sldIM_flat3     = 0.0
88         sldIM_flat4     = 0.0
89         sldIM_flat5     = 0.0
90         sldIM_flat6     = 0.0
91         sldIM_flat7     = 0.0
92         sldIM_flat8     = 0.0
93         sldIM_flat9     = 0.0
94         sldIM_flat10    = 0.0
95         sldIM_sub0      = 0.0
96         sldIM_medium    = 0.0
97
98    """
99       
100    def __init__(self):
101        """ Initialization """
102       
103        # Initialize BaseComponent first, then sphere
104        BaseComponent.__init__(self)
105        CReflModel.__init__(self)
106       
107        ## Name of the model
108        self.name = "ReflModel"
109        ## Model description
110        self.description ="""Form factor of mutishells normalized by the volume. Here each shell is described
111                by an exponential function;
112                I)
113                For A_shell != 0,
114                f(r) = B*exp(A_shell*(r-r_in)/thick_shell)+C
115                where
116                B=(sld_out-sld_in)/(exp(A_shell)-1)
117                C=sld_in-B.
118                Note that in the above case,
119                the function becomes a linear function
120                as A_shell --> 0+ or 0-.
121                II)
122                For the exact point of A_shell == 0,
123                f(r) = sld_in ,i.e., it crosses over flat function
124                Note that the 'sld_out' becaomes NULL in this case.
125               
126                background:background,
127                rad_core: radius of sphere(core)
128                thick_shell#:the thickness of the shell#
129                sld_core: the SLD of the sphere
130                sld_solv: the SLD of the solvent
131                sld_shell: the SLD of the shell#
132                A_shell#: the coefficient in the exponential function"""
133       
134        ## Parameter details [units, min, max]
135        self.details = {}
136        self.details['n_layers'] = ['', None, None]
137        self.details['scale'] = ['', None, None]
138        self.details['thick_inter0'] = ['[A]', None, None]
139        self.details['func_inter0'] = ['', None, None]
140        self.details['sld_sub0'] = ['[1/A^(2)]', None, None]
141        self.details['sld_medium'] = ['[1/A^(2)]', None, None]
142        self.details['background'] = ['', None, None]
143        self.details['sld_flat1'] = ['[1/A^(2)]', None, None]
144        self.details['sld_flat2'] = ['[1/A^(2)]', None, None]
145        self.details['sld_flat3'] = ['[1/A^(2)]', None, None]
146        self.details['sld_flat4'] = ['[1/A^(2)]', None, None]
147        self.details['sld_flat5'] = ['[1/A^(2)]', None, None]
148        self.details['sld_flat6'] = ['[1/A^(2)]', None, None]
149        self.details['sld_flat7'] = ['[1/A^(2)]', None, None]
150        self.details['sld_flat8'] = ['[1/A^(2)]', None, None]
151        self.details['sld_flat9'] = ['[1/A^(2)]', None, None]
152        self.details['sld_flat10'] = ['[1/A^(2)]', None, None]
153        self.details['thick_inter1'] = ['[A]', None, None]
154        self.details['thick_inter2'] = ['[A]', None, None]
155        self.details['thick_inter3'] = ['[A]', None, None]
156        self.details['thick_inter4'] = ['[A]', None, None]
157        self.details['thick_inter5'] = ['[A]', None, None]
158        self.details['thick_inter6'] = ['[A]', None, None]
159        self.details['thick_inter7'] = ['[A]', None, None]
160        self.details['thick_inter8'] = ['[A]', None, None]
161        self.details['thick_inter9'] = ['[A]', None, None]
162        self.details['thick_inter10'] = ['[A]', None, None]
163        self.details['thick_flat1'] = ['[A]', None, None]
164        self.details['thick_flat2'] = ['[A]', None, None]
165        self.details['thick_flat3'] = ['[A]', None, None]
166        self.details['thick_flat4'] = ['[A]', None, None]
167        self.details['thick_flat5'] = ['[A]', None, None]
168        self.details['thick_flat6'] = ['[A]', None, None]
169        self.details['thick_flat7'] = ['[A]', None, None]
170        self.details['thick_flat8'] = ['[A]', None, None]
171        self.details['thick_flat9'] = ['[A]', None, None]
172        self.details['thick_flat10'] = ['[A]', None, None]
173        self.details['func_inter1'] = ['', None, None]
174        self.details['func_inter2'] = ['', None, None]
175        self.details['func_inter3'] = ['', None, None]
176        self.details['func_inter4'] = ['', None, None]
177        self.details['func_inter5'] = ['', None, None]
178        self.details['func_inter6'] = ['', None, None]
179        self.details['func_inter7'] = ['', None, None]
180        self.details['func_inter8'] = ['', None, None]
181        self.details['func_inter9'] = ['', None, None]
182        self.details['func_inter10'] = ['', None, None]
183        self.details['sldIM_flat1'] = ['', None, None]
184        self.details['sldIM_flat2'] = ['', None, None]
185        self.details['sldIM_flat3'] = ['', None, None]
186        self.details['sldIM_flat4'] = ['', None, None]
187        self.details['sldIM_flat5'] = ['', None, None]
188        self.details['sldIM_flat6'] = ['', None, None]
189        self.details['sldIM_flat7'] = ['', None, None]
190        self.details['sldIM_flat8'] = ['', None, None]
191        self.details['sldIM_flat9'] = ['', None, None]
192        self.details['sldIM_flat10'] = ['', None, None]
193        self.details['sldIM_sub0'] = ['', None, None]
194        self.details['sldIM_medium'] = ['', None, None]
195
196        ## fittable parameters
197        self.fixed=[]
198       
199        ## non-fittable parameters
200        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']
201       
202        ## parameters with orientation
203        self.orientation_params =[]
204   
205    def clone(self):
206        """ Return a identical copy of self """
207        return self._clone(ReflModel())   
208       
209    def __getstate__(self):
210        """
211        return object state for pickling and copying
212        """
213        model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log}
214       
215        return self.__dict__, model_state
216       
217    def __setstate__(self, state):
218        """
219        create object from pickled state
220       
221        :param state: the state of the current model
222       
223        """
224       
225        self.__dict__, model_state = state
226        self.params = model_state['params']
227        self.dispersion = model_state['dispersion']
228        self.log = model_state['log']
229       
230   
231    def run(self, x=0.0):
232        """
233        Evaluate the model
234       
235        :param x: input q, or [q,phi]
236       
237        :return: scattering function P(q)
238       
239        """
240       
241        return CReflModel.run(self, x)
242   
243    def runXY(self, x=0.0):
244        """
245        Evaluate the model in cartesian coordinates
246       
247        :param x: input q, or [qx, qy]
248       
249        :return: scattering function P(q)
250       
251        """
252       
253        return CReflModel.runXY(self, x)
254       
255    def evalDistribution(self, x=[]):
256        """
257        Evaluate the model in cartesian coordinates
258       
259        :param x: input q[], or [qx[], qy[]]
260       
261        :return: scattering function P(q[])
262       
263        """
264        return CReflModel.evalDistribution(self, x)
265       
266    def calculate_ER(self):
267        """
268        Calculate the effective radius for P(q)*S(q)
269       
270        :return: the value of the effective radius
271       
272        """       
273        return CReflModel.calculate_ER(self)
274       
275    def set_dispersion(self, parameter, dispersion):
276        """
277        Set the dispersion object for a model parameter
278       
279        :param parameter: name of the parameter [string]
280        :param dispersion: dispersion object of type DispersionModel
281       
282        """
283        return CReflModel.set_dispersion(self, parameter, dispersion.cdisp)
284       
285   
286# End of file
Note: See TracBrowser for help on using the repository browser.