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