source: sasview/src/sans/models/FuzzySphereModel.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: 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\fuzzysphere.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CFuzzySphereModel
28
29def create_FuzzySphereModel():
30    """
31       Create a model instance
32    """
33    obj = FuzzySphereModel()
34    # CFuzzySphereModel.__init__(obj) is called by
35    # the FuzzySphereModel constructor
36    return obj
37
38class FuzzySphereModel(CFuzzySphereModel, BaseComponent):
39    """
40    Class that evaluates a FuzzySphereModel model.
41    This file was auto-generated from src\sans\models\include\fuzzysphere.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    * radius          = 60.0 [A]
48    * scale           = 0.01
49    * fuzziness       = 10.0 [A]
50    * sldSph          = 1e-06 [1/A^(2)]
51    * sldSolv         = 3e-06 [1/A^(2)]
52    * background      = 0.001 [1/cm]
53
54    """
55       
56    def __init__(self, multfactor=1):
57        """ Initialization """
58        self.__dict__ = {}
59       
60        # Initialize BaseComponent first, then sphere
61        BaseComponent.__init__(self)
62        #apply(CFuzzySphereModel.__init__, (self,))
63
64        CFuzzySphereModel.__init__(self)
65        self.is_multifunc = False
66                       
67        ## Name of the model
68        self.name = "FuzzySphereModel"
69        ## Model description
70        self.description = """
71       
72                scale: scale factor times volume fraction,
73                or just volume fraction for absolute scale data
74                radius: radius of the solid sphere
75                fuzziness = the STD of the height of fuzzy interfacial
76                thickness (ie., so-called interfacial roughness)
77                sldSph: the SLD of the sphere
78                sldSolv: the SLD of the solvent
79                background: incoherent background
80                Note: By definition, this function works only when fuzziness << radius.
81        """
82       
83        ## Parameter details [units, min, max]
84        self.details = {}
85        self.details['radius'] = ['[A]', None, None]
86        self.details['scale'] = ['', None, None]
87        self.details['fuzziness'] = ['[A]', None, None]
88        self.details['sldSph'] = ['[1/A^(2)]', None, None]
89        self.details['sldSolv'] = ['[1/A^(2)]', None, None]
90        self.details['background'] = ['[1/cm]', None, None]
91
92        ## fittable parameters
93        self.fixed = ['radius.width',
94                      'fuzziness.width']
95       
96        ## non-fittable parameters
97        self.non_fittable = []
98       
99        ## parameters with orientation
100        self.orientation_params = []
101
102        ## parameters with magnetism
103        self.magnetic_params = []
104
105        self.category = None
106        self.multiplicity_info = None
107       
108    def __setstate__(self, state):
109        """
110        restore the state of a model from pickle
111        """
112        self.__dict__, self.params, self.dispersion = state
113       
114    def __reduce_ex__(self, proto):
115        """
116        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
117        c model.
118        """
119        state = (self.__dict__, self.params, self.dispersion)
120        return (create_FuzzySphereModel, tuple(), state, None, None)
121       
122    def clone(self):
123        """ Return a identical copy of self """
124        return self._clone(FuzzySphereModel())   
125       
126    def run(self, x=0.0):
127        """
128        Evaluate the model
129       
130        :param x: input q, or [q,phi]
131       
132        :return: scattering function P(q)
133       
134        """
135        return CFuzzySphereModel.run(self, x)
136   
137    def runXY(self, x=0.0):
138        """
139        Evaluate the model in cartesian coordinates
140       
141        :param x: input q, or [qx, qy]
142       
143        :return: scattering function P(q)
144       
145        """
146        return CFuzzySphereModel.runXY(self, x)
147       
148    def evalDistribution(self, x):
149        """
150        Evaluate the model in cartesian coordinates
151       
152        :param x: input q[], or [qx[], qy[]]
153       
154        :return: scattering function P(q[])
155       
156        """
157        return CFuzzySphereModel.evalDistribution(self, x)
158       
159    def calculate_ER(self):
160        """
161        Calculate the effective radius for P(q)*S(q)
162       
163        :return: the value of the effective radius
164       
165        """       
166        return CFuzzySphereModel.calculate_ER(self)
167       
168    def calculate_VR(self):
169        """
170        Calculate the volf ratio for P(q)*S(q)
171       
172        :return: the value of the volf ratio
173       
174        """       
175        return CFuzzySphereModel.calculate_VR(self)
176             
177    def set_dispersion(self, parameter, dispersion):
178        """
179        Set the dispersion object for a model parameter
180       
181        :param parameter: name of the parameter [string]
182        :param dispersion: dispersion object of type DispersionModel
183       
184        """
185        return CFuzzySphereModel.set_dispersion(self,
186               parameter, dispersion.cdisp)
187       
188   
189# End of file
190
Note: See TracBrowser for help on using the repository browser.