source: sasview/src/sans/models/Core2ndMomentModel.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.9 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\coresecondmoment.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CCore2ndMomentModel
28
29def create_Core2ndMomentModel():
30    """
31       Create a model instance
32    """
33    obj = Core2ndMomentModel()
34    # CCore2ndMomentModel.__init__(obj) is called by
35    # the Core2ndMomentModel constructor
36    return obj
37
38class Core2ndMomentModel(CCore2ndMomentModel, BaseComponent):
39    """
40    Class that evaluates a Core2ndMomentModel model.
41    This file was auto-generated from src\sans\models\include\coresecondmoment.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    * density_poly    = 0.7 [g/cm^(3)]
49    * sld_poly        = 1.5e-06 [1/A^(2)]
50    * radius_core     = 500.0 [A]
51    * volf_cores      = 0.14
52    * ads_amount      = 1.9 [mg/m^(2)]
53    * sld_solv        = 6.3e-06 [1/A^(2)]
54    * second_moment   = 23.0 [A]
55    * background      = 0.0 [1/cm]
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(CCore2ndMomentModel.__init__, (self,))
66
67        CCore2ndMomentModel.__init__(self)
68        self.is_multifunc = False
69                       
70        ## Name of the model
71        self.name = "Core2ndMomentModel"
72        ## Model description
73        self.description = """
74        Calculate CoreSecondMoment Model
75               
76                scale:calibration factor,
77                density_poly: density of the layer
78                sld_poly: the SLD of the layer
79                volf_cores: volume fraction of cores
80                ads_amount: adsorbed amount
81                second_moment: second moment of the layer
82                sld_solv: the SLD of the solvent
83                background
84               
85        """
86       
87        ## Parameter details [units, min, max]
88        self.details = {}
89        self.details['scale'] = ['', None, None]
90        self.details['density_poly'] = ['[g/cm^(3)]', None, None]
91        self.details['sld_poly'] = ['[1/A^(2)]', None, None]
92        self.details['radius_core'] = ['[A]', None, None]
93        self.details['volf_cores'] = ['', None, None]
94        self.details['ads_amount'] = ['[mg/m^(2)]', None, None]
95        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
96        self.details['second_moment'] = ['[A]', None, None]
97        self.details['background'] = ['[1/cm]', None, None]
98
99        ## fittable parameters
100        self.fixed = ['radius_core.width']
101       
102        ## non-fittable parameters
103        self.non_fittable = []
104       
105        ## parameters with orientation
106        self.orientation_params = []
107
108        ## parameters with magnetism
109        self.magnetic_params = []
110
111        self.category = None
112        self.multiplicity_info = None
113       
114    def __setstate__(self, state):
115        """
116        restore the state of a model from pickle
117        """
118        self.__dict__, self.params, self.dispersion = state
119       
120    def __reduce_ex__(self, proto):
121        """
122        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
123        c model.
124        """
125        state = (self.__dict__, self.params, self.dispersion)
126        return (create_Core2ndMomentModel, tuple(), state, None, None)
127       
128    def clone(self):
129        """ Return a identical copy of self """
130        return self._clone(Core2ndMomentModel())   
131       
132    def run(self, x=0.0):
133        """
134        Evaluate the model
135       
136        :param x: input q, or [q,phi]
137       
138        :return: scattering function P(q)
139       
140        """
141        return CCore2ndMomentModel.run(self, x)
142   
143    def runXY(self, x=0.0):
144        """
145        Evaluate the model in cartesian coordinates
146       
147        :param x: input q, or [qx, qy]
148       
149        :return: scattering function P(q)
150       
151        """
152        return CCore2ndMomentModel.runXY(self, x)
153       
154    def evalDistribution(self, x):
155        """
156        Evaluate the model in cartesian coordinates
157       
158        :param x: input q[], or [qx[], qy[]]
159       
160        :return: scattering function P(q[])
161       
162        """
163        return CCore2ndMomentModel.evalDistribution(self, x)
164       
165    def calculate_ER(self):
166        """
167        Calculate the effective radius for P(q)*S(q)
168       
169        :return: the value of the effective radius
170       
171        """       
172        return CCore2ndMomentModel.calculate_ER(self)
173       
174    def calculate_VR(self):
175        """
176        Calculate the volf ratio for P(q)*S(q)
177       
178        :return: the value of the volf ratio
179       
180        """       
181        return CCore2ndMomentModel.calculate_VR(self)
182             
183    def set_dispersion(self, parameter, dispersion):
184        """
185        Set the dispersion object for a model parameter
186       
187        :param parameter: name of the parameter [string]
188        :param dispersion: dispersion object of type DispersionModel
189       
190        """
191        return CCore2ndMomentModel.set_dispersion(self,
192               parameter, dispersion.cdisp)
193       
194   
195# End of file
196
Note: See TracBrowser for help on using the repository browser.