source: sasview/src/sans/models/FlexibleCylinderModel.py @ 54b9ad2

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