source: sasview/src/sans/models/CoreFourShellModel.py @ 81b524f

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 81b524f was 81b524f, checked in by Jeff Krzywon <jeffery.krzywon@…>, 11 years ago

This branch is now merged with the latest trunk release. I will merge them next.

  • Property mode set to 100644
File size: 10.2 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: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
19         DO NOT MODIFY THIS FILE, MODIFY
20            src\sans\models\include\corefourshell.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CCoreFourShellModel
26
27def create_CoreFourShellModel():
28    """
29       Create a model instance
30    """
31    obj = CoreFourShellModel()
32    # CCoreFourShellModel.__init__(obj) is called by
33    # the CoreFourShellModel constructor
34    return obj
35
36class CoreFourShellModel(CCoreFourShellModel, BaseComponent):
37    """
38    Class that evaluates a CoreFourShellModel model.
39    This file was auto-generated from src\sans\models\include\corefourshell.h.
40    Refer to that file and the structure it contains
41    for details of the model.
42    List of default parameters:
43         scale           = 1.0
44         rad_core0       = 60.0 [A]
45         sld_core0       = 6.4e-06 [1/A^(2)]
46         thick_shell1    = 10.0 [A]
47         sld_shell1      = 1e-06 [1/A^(2)]
48         thick_shell2    = 10.0 [A]
49         sld_shell2      = 2e-06 [1/A^(2)]
50         thick_shell3    = 10.0 [A]
51         sld_shell3      = 3e-06 [1/A^(2)]
52         thick_shell4    = 10.0 [A]
53         sld_shell4      = 4e-06 [1/A^(2)]
54         sld_solv        = 6.4e-06 [1/A^(2)]
55         background      = 0.001 [1/cm]
56         M0_sld_shell1   = 0.0 [1/A^(2)]
57         M_theta_shell1  = 0.0 [deg]
58         M_phi_shell1    = 0.0 [deg]
59         M0_sld_shell2   = 0.0 [1/A^(2)]
60         M_theta_shell2  = 0.0 [deg]
61         M_phi_shell2    = 0.0 [deg]
62         M0_sld_shell3   = 0.0 [1/A^(2)]
63         M_theta_shell3  = 0.0 [deg]
64         M_phi_shell3    = 0.0 [deg]
65         M0_sld_shell4   = 0.0 [1/A^(2)]
66         M_theta_shell4  = 0.0 [deg]
67         M_phi_shell4    = 0.0 [deg]
68         M0_sld_core0    = 0.0 [1/A^(2)]
69         M_theta_core0   = 0.0 [deg]
70         M_phi_core0     = 0.0 [deg]
71         M0_sld_solv     = 0.0 [1/A^(2)]
72         M_theta_solv    = 0.0 [deg]
73         M_phi_solv      = 0.0 [deg]
74         Up_frac_i       = 0.5 [u/(u+d)]
75         Up_frac_f       = 0.5 [u/(u+d)]
76         Up_theta        = 0.0 [deg]
77
78    """
79       
80    def __init__(self, multfactor=1):
81        """ Initialization """
82        self.__dict__ = {}
83       
84        # Initialize BaseComponent first, then sphere
85        BaseComponent.__init__(self)
86        #apply(CCoreFourShellModel.__init__, (self,))
87
88        CCoreFourShellModel.__init__(self)
89        self.is_multifunc = False
90                       
91        ## Name of the model
92        self.name = "CoreFourShellModel"
93        ## Model description
94        self.description = """
95         Calculates the scattering intensity from a core-4 shell structure.
96                scale = scale factor * volume fraction
97                rad_core0: the radius of the core
98                sld_core0: the SLD of the core
99                thick_shelli: the thickness of the i'th shell from the core
100                sld_shelli: the SLD of the i'th shell from the core
101                sld_solv: the SLD of the solvent
102                background: incoherent background
103        """
104       
105        ## Parameter details [units, min, max]
106        self.details = {}
107        self.details['scale'] = ['', None, None]
108        self.details['rad_core0'] = ['[A]', None, None]
109        self.details['sld_core0'] = ['[1/A^(2)]', None, None]
110        self.details['thick_shell1'] = ['[A]', None, None]
111        self.details['sld_shell1'] = ['[1/A^(2)]', None, None]
112        self.details['thick_shell2'] = ['[A]', None, None]
113        self.details['sld_shell2'] = ['[1/A^(2)]', None, None]
114        self.details['thick_shell3'] = ['[A]', None, None]
115        self.details['sld_shell3'] = ['[1/A^(2)]', None, None]
116        self.details['thick_shell4'] = ['[A]', None, None]
117        self.details['sld_shell4'] = ['[1/A^(2)]', None, None]
118        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
119        self.details['background'] = ['[1/cm]', None, None]
120        self.details['M0_sld_shell1'] = ['[1/A^(2)]', None, None]
121        self.details['M_theta_shell1'] = ['[deg]', None, None]
122        self.details['M_phi_shell1'] = ['[deg]', None, None]
123        self.details['M0_sld_shell2'] = ['[1/A^(2)]', None, None]
124        self.details['M_theta_shell2'] = ['[deg]', None, None]
125        self.details['M_phi_shell2'] = ['[deg]', None, None]
126        self.details['M0_sld_shell3'] = ['[1/A^(2)]', None, None]
127        self.details['M_theta_shell3'] = ['[deg]', None, None]
128        self.details['M_phi_shell3'] = ['[deg]', None, None]
129        self.details['M0_sld_shell4'] = ['[1/A^(2)]', None, None]
130        self.details['M_theta_shell4'] = ['[deg]', None, None]
131        self.details['M_phi_shell4'] = ['[deg]', None, None]
132        self.details['M0_sld_core0'] = ['[1/A^(2)]', None, None]
133        self.details['M_theta_core0'] = ['[deg]', None, None]
134        self.details['M_phi_core0'] = ['[deg]', None, None]
135        self.details['M0_sld_solv'] = ['[1/A^(2)]', None, None]
136        self.details['M_theta_solv'] = ['[deg]', None, None]
137        self.details['M_phi_solv'] = ['[deg]', None, None]
138        self.details['Up_frac_i'] = ['[u/(u+d)]', None, None]
139        self.details['Up_frac_f'] = ['[u/(u+d)]', None, None]
140        self.details['Up_theta'] = ['[deg]', None, None]
141
142        ## fittable parameters
143        self.fixed = ['thick_shell4.width',
144                      'thick_shell1.width',
145                      'thick_shell2.width',
146                      'thick_shell3.width',
147                      'rad_core0.width']
148       
149        ## non-fittable parameters
150        self.non_fittable = []
151       
152        ## parameters with orientation
153        self.orientation_params = ['M0_sld_shell4',
154                                   'M_theta_shell4',
155                                   'M_phi_shell4',
156                                   'M0_sld_shell3',
157                                   'M_theta_shell3',
158                                   'M_phi_shell3',
159                                   'M0_sld_shell2',
160                                   'M_theta_shell2',
161                                   'M_phi_shell2',
162                                   'M0_sld_shell1',
163                                   'M_theta_shell1',
164                                   'M_phi_shell1',
165                                   'M0_sld_core0',
166                                   'M_theta_core0',
167                                   'M_phi_core0',
168                                   'M0_sld_solv',
169                                   'M_theta_solv',
170                                   'M_phi_solv',
171                                   'Up_frac_i',
172                                   'Up_frac_f',
173                                   'Up_theta']
174
175        ## parameters with magnetism
176        self.magnetic_params = ['M0_sld_shell4', 'M_theta_shell4', 'M_phi_shell4', 'M0_sld_shell3', 'M_theta_shell3', 'M_phi_shell3', 'M0_sld_shell2', 'M_theta_shell2', 'M_phi_shell2', 'M0_sld_shell1', 'M_theta_shell1', 'M_phi_shell1', 'M0_sld_core0', 'M_theta_core0', 'M_phi_core0', 'M0_sld_solv', 'M_theta_solv', 'M_phi_solv', 'Up_frac_i', 'Up_frac_f', 'Up_theta']
177
178        self.category = None
179        self.multiplicity_info = None
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_CoreFourShellModel, tuple(), state, None, None)
194       
195    def clone(self):
196        """ Return a identical copy of self """
197        return self._clone(CoreFourShellModel())   
198       
199    def run(self, x=0.0):
200        """
201        Evaluate the model
202       
203        :param x: input q, or [q,phi]
204       
205        :return: scattering function P(q)
206       
207        """
208        return CCoreFourShellModel.run(self, x)
209   
210    def runXY(self, x=0.0):
211        """
212        Evaluate the model in cartesian coordinates
213       
214        :param x: input q, or [qx, qy]
215       
216        :return: scattering function P(q)
217       
218        """
219        return CCoreFourShellModel.runXY(self, x)
220       
221    def evalDistribution(self, x):
222        """
223        Evaluate the model in cartesian coordinates
224       
225        :param x: input q[], or [qx[], qy[]]
226       
227        :return: scattering function P(q[])
228       
229        """
230        return CCoreFourShellModel.evalDistribution(self, x)
231       
232    def calculate_ER(self):
233        """
234        Calculate the effective radius for P(q)*S(q)
235       
236        :return: the value of the effective radius
237       
238        """       
239        return CCoreFourShellModel.calculate_ER(self)
240       
241    def calculate_VR(self):
242        """
243        Calculate the volf ratio for P(q)*S(q)
244       
245        :return: the value of the volf ratio
246       
247        """       
248        return CCoreFourShellModel.calculate_VR(self)
249             
250    def set_dispersion(self, parameter, dispersion):
251        """
252        Set the dispersion object for a model parameter
253       
254        :param parameter: name of the parameter [string]
255        :param dispersion: dispersion object of type DispersionModel
256       
257        """
258        return CCoreFourShellModel.set_dispersion(self,
259               parameter, dispersion.cdisp)
260       
261   
262# End of file
263
Note: See TracBrowser for help on using the repository browser.