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