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