source: sasview/sansmodels/src/sans/models/OnionModel.py @ 20905a0

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 20905a0 was e096270, checked in by Jae Cho <jhjcho@…>, 14 years ago

added a new model

  • Property mode set to 100644
File size: 10.1 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_core        = 200.0 [A]
41         sld_core        = 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
45         sld_out_shell2  = 2.5e-006
46         sld_out_shell3  = 3e-006
47         sld_out_shell4  = 3.5e-006
48         sld_out_shell5  = 4e-006
49         sld_out_shell6  = 4.5e-006
50         sld_out_shell7  = 5e-006
51         sld_out_shell8  = 5.5e-006
52         sld_out_shell9  = 6e-006
53         sld_out_shell10 = 6.2e-006
54         sld_in_shell1   = 1.7e-006
55         sld_in_shell2   = 2.2e-006
56         sld_in_shell3   = 2.7e-006
57         sld_in_shell4   = 3.2e-006
58         sld_in_shell5   = 3.7e-006
59         sld_in_shell6   = 4.2e-006
60         sld_in_shell7   = 4.7e-006
61         sld_in_shell8   = 5.2e-006
62         sld_in_shell9   = 5.7e-006
63         sld_in_shell10  = 6e-006
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
75         thick_shell2    = 50.0
76         thick_shell3    = 50.0
77         thick_shell4    = 50.0
78         thick_shell5    = 50.0
79         thick_shell6    = 50.0
80         thick_shell7    = 50.0
81         thick_shell8    = 50.0
82         thick_shell9    = 50.0
83         thick_shell10   = 50.0
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_core: radius of sphere(core)
125                thick_shell#:the thickness of the shell#
126                sld_core: 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_core'] = ['[A]', None, None]
136        self.details['sld_core'] = ['[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'] = ['', None, None]
140        self.details['sld_out_shell2'] = ['', None, None]
141        self.details['sld_out_shell3'] = ['', None, None]
142        self.details['sld_out_shell4'] = ['', None, None]
143        self.details['sld_out_shell5'] = ['', None, None]
144        self.details['sld_out_shell6'] = ['', None, None]
145        self.details['sld_out_shell7'] = ['', None, None]
146        self.details['sld_out_shell8'] = ['', None, None]
147        self.details['sld_out_shell9'] = ['', None, None]
148        self.details['sld_out_shell10'] = ['', None, None]
149        self.details['sld_in_shell1'] = ['', None, None]
150        self.details['sld_in_shell2'] = ['', None, None]
151        self.details['sld_in_shell3'] = ['', None, None]
152        self.details['sld_in_shell4'] = ['', None, None]
153        self.details['sld_in_shell5'] = ['', None, None]
154        self.details['sld_in_shell6'] = ['', None, None]
155        self.details['sld_in_shell7'] = ['', None, None]
156        self.details['sld_in_shell8'] = ['', None, None]
157        self.details['sld_in_shell9'] = ['', None, None]
158        self.details['sld_in_shell10'] = ['', 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'] = ['', None, None]
170        self.details['thick_shell2'] = ['', None, None]
171        self.details['thick_shell3'] = ['', None, None]
172        self.details['thick_shell4'] = ['', None, None]
173        self.details['thick_shell5'] = ['', None, None]
174        self.details['thick_shell6'] = ['', None, None]
175        self.details['thick_shell7'] = ['', None, None]
176        self.details['thick_shell8'] = ['', None, None]
177        self.details['thick_shell9'] = ['', None, None]
178        self.details['thick_shell10'] = ['', 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_core.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        ## parameters with orientation
194        self.orientation_params =[]
195   
196    def clone(self):
197        """ Return a identical copy of self """
198        return self._clone(OnionModel())   
199       
200    def __getstate__(self):
201        """
202        return object state for pickling and copying
203        """
204        model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log}
205       
206        return self.__dict__, model_state
207       
208    def __setstate__(self, state):
209        """
210        create object from pickled state
211       
212        :param state: the state of the current model
213       
214        """
215       
216        self.__dict__, model_state = state
217        self.params = model_state['params']
218        self.dispersion = model_state['dispersion']
219        self.log = model_state['log']
220       
221   
222    def run(self, x=0.0):
223        """
224        Evaluate the model
225       
226        :param x: input q, or [q,phi]
227       
228        :return: scattering function P(q)
229       
230        """
231       
232        return COnionModel.run(self, x)
233   
234    def runXY(self, x=0.0):
235        """
236        Evaluate the model in cartesian coordinates
237       
238        :param x: input q, or [qx, qy]
239       
240        :return: scattering function P(q)
241       
242        """
243       
244        return COnionModel.runXY(self, x)
245       
246    def evalDistribution(self, x=[]):
247        """
248        Evaluate the model in cartesian coordinates
249       
250        :param x: input q[], or [qx[], qy[]]
251       
252        :return: scattering function P(q[])
253       
254        """
255        return COnionModel.evalDistribution(self, x)
256       
257    def calculate_ER(self):
258        """
259        Calculate the effective radius for P(q)*S(q)
260       
261        :return: the value of the effective radius
262       
263        """       
264        return COnionModel.calculate_ER(self)
265       
266    def set_dispersion(self, parameter, dispersion):
267        """
268        Set the dispersion object for a model parameter
269       
270        :param parameter: name of the parameter [string]
271        :param dispersion: dispersion object of type DispersionModel
272       
273        """
274        return COnionModel.set_dispersion(self, parameter, dispersion.cdisp)
275       
276   
277# End of file
Note: See TracBrowser for help on using the repository browser.