source: sasview/src/sans/models/CoreShellModel.py @ 400155b

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 400155b was 400155b, checked in by gonzalezm, 9 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: 7.5 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\core_shell.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CCoreShellModel
28
29def create_CoreShellModel():
30    """
31       Create a model instance
32    """
33    obj = CoreShellModel()
34    # CCoreShellModel.__init__(obj) is called by
35    # the CoreShellModel constructor
36    return obj
37
38class CoreShellModel(CCoreShellModel, BaseComponent):
39    """
40    Class that evaluates a CoreShellModel model.
41    This file was auto-generated from src\sans\models\include\core_shell.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    * radius          = 60.0 [A]
48    * scale           = 1.0
49    * thickness       = 10.0 [A]
50    * core_sld        = 1e-06 [1/A^(2)]
51    * shell_sld       = 2e-06 [1/A^(2)]
52    * solvent_sld     = 3e-06 [1/A^(2)]
53    * background      = 0.0 [1/cm]
54    * M0_sld_shell    = 0.0 [1/A^(2)]
55    * M_theta_shell   = 0.0 [deg]
56    * M_phi_shell     = 0.0 [deg]
57    * M0_sld_core     = 0.0 [1/A^(2)]
58    * M_theta_core    = 0.0 [deg]
59    * M_phi_core      = 0.0 [deg]
60    * M0_sld_solv     = 0.0 [1/A^(2)]
61    * M_theta_solv    = 0.0 [deg]
62    * M_phi_solv      = 0.0 [deg]
63    * Up_frac_i       = 0.5 [u/(u+d)]
64    * Up_frac_f       = 0.5 [u/(u+d)]
65    * Up_theta        = 0.0 [deg]
66
67    """
68       
69    def __init__(self, multfactor=1):
70        """ Initialization """
71        self.__dict__ = {}
72       
73        # Initialize BaseComponent first, then sphere
74        BaseComponent.__init__(self)
75        #apply(CCoreShellModel.__init__, (self,))
76
77        CCoreShellModel.__init__(self)
78        self.is_multifunc = False
79                       
80        ## Name of the model
81        self.name = "CoreShellModel"
82        ## Model description
83        self.description = """
84        Form factor for a monodisperse spherical particle with particle
85                with a core-shell structure:
86               
87                The form factor is normalized by the
88                total particle volume.
89               
90                radius: core radius, thickness: shell thickness
91               
92                Ref: Guinier, A. and G. Fournet,
93                John Wiley and Sons, New York, 1955.
94        """
95       
96        ## Parameter details [units, min, max]
97        self.details = {}
98        self.details['radius'] = ['[A]', None, None]
99        self.details['scale'] = ['', None, None]
100        self.details['thickness'] = ['[A]', None, None]
101        self.details['core_sld'] = ['[1/A^(2)]', None, None]
102        self.details['shell_sld'] = ['[1/A^(2)]', None, None]
103        self.details['solvent_sld'] = ['[1/A^(2)]', None, None]
104        self.details['background'] = ['[1/cm]', None, None]
105        self.details['M0_sld_shell'] = ['[1/A^(2)]', None, None]
106        self.details['M_theta_shell'] = ['[deg]', None, None]
107        self.details['M_phi_shell'] = ['[deg]', None, None]
108        self.details['M0_sld_core'] = ['[1/A^(2)]', None, None]
109        self.details['M_theta_core'] = ['[deg]', None, None]
110        self.details['M_phi_core'] = ['[deg]', None, None]
111        self.details['M0_sld_solv'] = ['[1/A^(2)]', None, None]
112        self.details['M_theta_solv'] = ['[deg]', None, None]
113        self.details['M_phi_solv'] = ['[deg]', None, None]
114        self.details['Up_frac_i'] = ['[u/(u+d)]', None, None]
115        self.details['Up_frac_f'] = ['[u/(u+d)]', None, None]
116        self.details['Up_theta'] = ['[deg]', None, None]
117
118        ## fittable parameters
119        self.fixed = ['thickness.width',
120                      'radius.width']
121       
122        ## non-fittable parameters
123        self.non_fittable = []
124       
125        ## parameters with orientation
126        self.orientation_params = ['M0_sld_shell',
127                                   'M_theta_shell',
128                                   'M_phi_shell',
129                                   'M0_sld_core',
130                                   'M_theta_core',
131                                   'M_phi_core',
132                                   'M0_sld_solv',
133                                   'M_theta_solv',
134                                   'M_phi_solv',
135                                   'Up_frac_i',
136                                   'Up_frac_f',
137                                   'Up_theta']
138
139        ## parameters with magnetism
140        self.magnetic_params = ['M0_sld_shell', 'M_theta_shell', 'M_phi_shell', 'M0_sld_core', 'M_theta_core', 'M_phi_core', 'M0_sld_solv', 'M_theta_solv', 'M_phi_solv', 'Up_frac_i', 'Up_frac_f', 'Up_theta']
141
142        self.category = None
143        self.multiplicity_info = None
144       
145    def __setstate__(self, state):
146        """
147        restore the state of a model from pickle
148        """
149        self.__dict__, self.params, self.dispersion = state
150       
151    def __reduce_ex__(self, proto):
152        """
153        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
154        c model.
155        """
156        state = (self.__dict__, self.params, self.dispersion)
157        return (create_CoreShellModel, tuple(), state, None, None)
158       
159    def clone(self):
160        """ Return a identical copy of self """
161        return self._clone(CoreShellModel())   
162       
163    def run(self, x=0.0):
164        """
165        Evaluate the model
166       
167        :param x: input q, or [q,phi]
168       
169        :return: scattering function P(q)
170       
171        """
172        return CCoreShellModel.run(self, x)
173   
174    def runXY(self, x=0.0):
175        """
176        Evaluate the model in cartesian coordinates
177       
178        :param x: input q, or [qx, qy]
179       
180        :return: scattering function P(q)
181       
182        """
183        return CCoreShellModel.runXY(self, x)
184       
185    def evalDistribution(self, x):
186        """
187        Evaluate the model in cartesian coordinates
188       
189        :param x: input q[], or [qx[], qy[]]
190       
191        :return: scattering function P(q[])
192       
193        """
194        return CCoreShellModel.evalDistribution(self, x)
195       
196    def calculate_ER(self):
197        """
198        Calculate the effective radius for P(q)*S(q)
199       
200        :return: the value of the effective radius
201       
202        """       
203        return CCoreShellModel.calculate_ER(self)
204       
205    def calculate_VR(self):
206        """
207        Calculate the volf ratio for P(q)*S(q)
208       
209        :return: the value of the volf ratio
210       
211        """       
212        return CCoreShellModel.calculate_VR(self)
213             
214    def set_dispersion(self, parameter, dispersion):
215        """
216        Set the dispersion object for a model parameter
217       
218        :param parameter: name of the parameter [string]
219        :param dispersion: dispersion object of type DispersionModel
220       
221        """
222        return CCoreShellModel.set_dispersion(self,
223               parameter, dispersion.cdisp)
224       
225   
226# End of file
227
Note: See TracBrowser for help on using the repository browser.