source: sasview/src/sans/models/Core2ndMomentModel.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@…>, 10 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.1 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\coresecondmoment.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CCore2ndMomentModel
26
27def create_Core2ndMomentModel():
28    """
29       Create a model instance
30    """
31    obj = Core2ndMomentModel()
32    # CCore2ndMomentModel.__init__(obj) is called by
33    # the Core2ndMomentModel constructor
34    return obj
35
36class Core2ndMomentModel(CCore2ndMomentModel, BaseComponent):
37    """
38    Class that evaluates a Core2ndMomentModel model.
39    This file was auto-generated from src\sans\models\include\coresecondmoment.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         density_poly    = 0.7 [g/cm^(3)]
45         sld_poly        = 1.5e-06 [1/A^(2)]
46         radius_core     = 500.0 [A]
47         volf_cores      = 0.14
48         ads_amount      = 1.9 [mg/m^(2)]
49         sld_solv        = 6.3e-06 [1/A^(2)]
50         second_moment   = 23.0 [A]
51         background      = 0.0 [1/cm]
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(CCore2ndMomentModel.__init__, (self,))
62
63        CCore2ndMomentModel.__init__(self)
64        self.is_multifunc = False
65                       
66        ## Name of the model
67        self.name = "Core2ndMomentModel"
68        ## Model description
69        self.description = """
70        Calculate CoreSecondMoment Model
71               
72                scale:calibration factor,
73                density_poly: density of the layer
74                sld_poly: the SLD of the layer
75                volf_cores: volume fraction of cores
76                ads_amount: adsorbed amount
77                second_moment: second moment of the layer
78                sld_solv: the SLD of the solvent
79                background
80               
81        """
82       
83        ## Parameter details [units, min, max]
84        self.details = {}
85        self.details['scale'] = ['', None, None]
86        self.details['density_poly'] = ['[g/cm^(3)]', None, None]
87        self.details['sld_poly'] = ['[1/A^(2)]', None, None]
88        self.details['radius_core'] = ['[A]', None, None]
89        self.details['volf_cores'] = ['', None, None]
90        self.details['ads_amount'] = ['[mg/m^(2)]', None, None]
91        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
92        self.details['second_moment'] = ['[A]', None, None]
93        self.details['background'] = ['[1/cm]', None, None]
94
95        ## fittable parameters
96        self.fixed = ['radius_core.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_Core2ndMomentModel, tuple(), state, None, None)
123       
124    def clone(self):
125        """ Return a identical copy of self """
126        return self._clone(Core2ndMomentModel())   
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 CCore2ndMomentModel.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 CCore2ndMomentModel.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 CCore2ndMomentModel.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 CCore2ndMomentModel.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 CCore2ndMomentModel.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 CCore2ndMomentModel.set_dispersion(self,
188               parameter, dispersion.cdisp)
189       
190   
191# End of file
192
Note: See TracBrowser for help on using the repository browser.