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