source: sasview/src/sans/models/CappedCylinderModel.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.4 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\capcyl.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CCappedCylinderModel
28
29def create_CappedCylinderModel():
30    """
31       Create a model instance
32    """
33    obj = CappedCylinderModel()
34    # CCappedCylinderModel.__init__(obj) is called by
35    # the CappedCylinderModel constructor
36    return obj
37
38class CappedCylinderModel(CCappedCylinderModel, BaseComponent):
39    """
40    Class that evaluates a CappedCylinderModel model.
41    This file was auto-generated from src\sans\models\include\capcyl.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    * rad_cyl         = 20.0 [A]
49    * len_cyl         = 400.0 [A]
50    * rad_cap         = 40.0 [A]
51    * sld_capcyl      = 1e-06 [1/A^(2)]
52    * sld_solv        = 6.3e-06 [1/A^(2)]
53    * background      = 0.0 [1/cm]
54    * theta           = 0.0 [deg]
55    * phi             = 0.0 [deg]
56
57    """
58       
59    def __init__(self, multfactor=1):
60        """ Initialization """
61        self.__dict__ = {}
62       
63        # Initialize BaseComponent first, then sphere
64        BaseComponent.__init__(self)
65        #apply(CCappedCylinderModel.__init__, (self,))
66
67        CCappedCylinderModel.__init__(self)
68        self.is_multifunc = False
69                       
70        ## Name of the model
71        self.name = "CappedCylinderModel"
72        ## Model description
73        self.description = """
74        Calculates the scattering from a cylinder with spherical section end-caps.
75                That is, a sphereocylinder
76                with end caps that have a radius larger than
77                that of the cylinder and the center of the
78                end cap radius lies within the cylinder.
79                Note: As the length of cylinder -->0,
80                it becomes a ConvexLens.
81                It must be that rad_cyl <(=) rad_cap.
82                [Parameters];
83                scale: volume fraction of spheres,
84                background:incoherent background,
85                rad_cyl: radius of the cylinder,
86                len_cyl: length of the cylinder,
87                rad_cap: radius of the semi-spherical cap,
88                sld_capcyl: SLD of the capped cylinder,
89                sld_solv: SLD of the solvent.
90        """
91       
92        ## Parameter details [units, min, max]
93        self.details = {}
94        self.details['scale'] = ['', None, None]
95        self.details['rad_cyl'] = ['[A]', None, None]
96        self.details['len_cyl'] = ['[A]', None, None]
97        self.details['rad_cap'] = ['[A]', None, None]
98        self.details['sld_capcyl'] = ['[1/A^(2)]', None, None]
99        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
100        self.details['background'] = ['[1/cm]', None, None]
101        self.details['theta'] = ['[deg]', None, None]
102        self.details['phi'] = ['[deg]', None, None]
103
104        ## fittable parameters
105        self.fixed = ['rad_cyl.width',
106                      'len_cyl',
107                      'rad_cap',
108                      'phi.width',
109                      'theta.width']
110       
111        ## non-fittable parameters
112        self.non_fittable = []
113       
114        ## parameters with orientation
115        self.orientation_params = ['phi',
116                                   'theta',
117                                   'phi.width',
118                                   'theta.width']
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_CappedCylinderModel, tuple(), state, None, None)
139       
140    def clone(self):
141        """ Return a identical copy of self """
142        return self._clone(CappedCylinderModel())   
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 CCappedCylinderModel.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 CCappedCylinderModel.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 CCappedCylinderModel.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 CCappedCylinderModel.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 CCappedCylinderModel.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 CCappedCylinderModel.set_dispersion(self,
204               parameter, dispersion.cdisp)
205       
206   
207# End of file
208
Note: See TracBrowser for help on using the repository browser.