source: sasview/src/sans/models/BarBellModel.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: 6.3 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\barbell.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CBarBellModel
28
29def create_BarBellModel():
30    """
31       Create a model instance
32    """
33    obj = BarBellModel()
34    # CBarBellModel.__init__(obj) is called by
35    # the BarBellModel constructor
36    return obj
37
38class BarBellModel(CBarBellModel, BaseComponent):
39    """
40    Class that evaluates a BarBellModel model.
41    This file was auto-generated from src\sans\models\include\barbell.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    * rad_bar         = 20.0 [A]
49    * len_bar         = 400.0 [A]
50    * rad_bell        = 40.0 [A]
51    * sld_barbell     = 1e-06 [1/A^(2)]
52    * sld_solv        = 6.3e-06 [1/A^(2)]
53    * background      = 0.0 [1/cm]
54    * theta           = 0.0 [deg]
55    * phi             = 0.0 [deg]
56
57    """
58       
59    def __init__(self, multfactor=1):
60        """ Initialization """
61        self.__dict__ = {}
62       
63        # Initialize BaseComponent first, then sphere
64        BaseComponent.__init__(self)
65        #apply(CBarBellModel.__init__, (self,))
66
67        CBarBellModel.__init__(self)
68        self.is_multifunc = False
69                       
70        ## Name of the model
71        self.name = "BarBellModel"
72        ## Model description
73        self.description = """
74        Calculates the scattering from a barbell-shaped cylinder. That is
75                a sphereocylinder with spherical end caps
76                that have a radius larger than that of
77                the cylinder and the center of the end cap
78                radius lies outside of the cylinder.
79                Note: As the length of cylinder(bar) -->0,
80                it becomes a dumbbell.
81                And when rad_bar = rad_bell,
82                it is a spherocylinder.
83                It must be that rad_bar <(=) rad_bell.
84                [Parameters];
85                scale: volume fraction of spheres,
86                background:incoherent background,
87                rad_bar: radius of the cylindrical bar,
88                len_bar: length of the cylindrical bar,
89                rad_bell: radius of the spherical bell,
90                sld_barbell: SLD of the barbell,
91                sld_solv: SLD of the solvent.
92        """
93       
94        ## Parameter details [units, min, max]
95        self.details = {}
96        self.details['scale'] = ['', None, None]
97        self.details['rad_bar'] = ['[A]', None, None]
98        self.details['len_bar'] = ['[A]', None, None]
99        self.details['rad_bell'] = ['[A]', None, None]
100        self.details['sld_barbell'] = ['[1/A^(2)]', None, None]
101        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
102        self.details['background'] = ['[1/cm]', None, None]
103        self.details['theta'] = ['[deg]', None, None]
104        self.details['phi'] = ['[deg]', None, None]
105
106        ## fittable parameters
107        self.fixed = ['rad_bar.width',
108                      'len_bar',
109                      'rad_bell',
110                      'phi.width',
111                      'theta.width']
112       
113        ## non-fittable parameters
114        self.non_fittable = []
115       
116        ## parameters with orientation
117        self.orientation_params = ['phi',
118                                   'theta',
119                                   'phi.width',
120                                   'theta.width']
121
122        ## parameters with magnetism
123        self.magnetic_params = []
124
125        self.category = None
126        self.multiplicity_info = None
127       
128    def __setstate__(self, state):
129        """
130        restore the state of a model from pickle
131        """
132        self.__dict__, self.params, self.dispersion = state
133       
134    def __reduce_ex__(self, proto):
135        """
136        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
137        c model.
138        """
139        state = (self.__dict__, self.params, self.dispersion)
140        return (create_BarBellModel, tuple(), state, None, None)
141       
142    def clone(self):
143        """ Return a identical copy of self """
144        return self._clone(BarBellModel())   
145       
146    def run(self, x=0.0):
147        """
148        Evaluate the model
149       
150        :param x: input q, or [q,phi]
151       
152        :return: scattering function P(q)
153       
154        """
155        return CBarBellModel.run(self, x)
156   
157    def runXY(self, x=0.0):
158        """
159        Evaluate the model in cartesian coordinates
160       
161        :param x: input q, or [qx, qy]
162       
163        :return: scattering function P(q)
164       
165        """
166        return CBarBellModel.runXY(self, x)
167       
168    def evalDistribution(self, x):
169        """
170        Evaluate the model in cartesian coordinates
171       
172        :param x: input q[], or [qx[], qy[]]
173       
174        :return: scattering function P(q[])
175       
176        """
177        return CBarBellModel.evalDistribution(self, x)
178       
179    def calculate_ER(self):
180        """
181        Calculate the effective radius for P(q)*S(q)
182       
183        :return: the value of the effective radius
184       
185        """       
186        return CBarBellModel.calculate_ER(self)
187       
188    def calculate_VR(self):
189        """
190        Calculate the volf ratio for P(q)*S(q)
191       
192        :return: the value of the volf ratio
193       
194        """       
195        return CBarBellModel.calculate_VR(self)
196             
197    def set_dispersion(self, parameter, dispersion):
198        """
199        Set the dispersion object for a model parameter
200       
201        :param parameter: name of the parameter [string]
202        :param dispersion: dispersion object of type DispersionModel
203       
204        """
205        return CBarBellModel.set_dispersion(self,
206               parameter, dispersion.cdisp)
207       
208   
209# End of file
210
Note: See TracBrowser for help on using the repository browser.