source: sasview/src/sans/models/SphereModel.py @ d09f0ae1

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