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