source: sasview/src/sans/models/CylinderModel.py @ 81b524f

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 81b524f was 81b524f, checked in by Jeff Krzywon <jeffery.krzywon@…>, 10 years ago

This branch is now merged with the latest trunk release. I will merge them next.

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