source: sasview/sansmodels/src/sans/models/OnionModel.py @ 02879ea

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