source: sasview/src/sans/models/SurfaceFractalModel.py @ 54b9ad2

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 54b9ad2 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.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\surfacefractal.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CSurfaceFractalModel
28
29def create_SurfaceFractalModel():
30    """
31       Create a model instance
32    """
33    obj = SurfaceFractalModel()
34    # CSurfaceFractalModel.__init__(obj) is called by
35    # the SurfaceFractalModel constructor
36    return obj
37
38class SurfaceFractalModel(CSurfaceFractalModel, BaseComponent):
39    """
40    Class that evaluates a SurfaceFractalModel model.
41    This file was auto-generated from src\sans\models\include\surfacefractal.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    * radius          = 10.0 [A]
49    * surface_dim     = 2.0
50    * co_length       = 500.0 [A]
51    * background      = 0.0
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(CSurfaceFractalModel.__init__, (self,))
62
63        CSurfaceFractalModel.__init__(self)
64        self.is_multifunc = False
65                       
66        ## Name of the model
67        self.name = "SurfaceFractalModel"
68        ## Model description
69        self.description = """
70         The scattering intensity  I(x) = scale*P(x)*S(x) + background, where
71                scale = scale_factor  * V * delta^(2)
72                p(x)=  F(x*radius)^(2)
73                F(x) = 3*[sin(x)-x cos(x)]/x**3
74                S(x) = [(gamma(5-Ds)*colength^(5-Ds)*[1+(x^2*colength^2)]^((Ds-5)/2)
75                * sin[(Ds-5)*arctan(x*colength)])/x]
76                where delta = sldParticle -sldSolv.
77                radius       =  Particle radius
78                surface_dim  =  Surface fractal dimension (Ds)
79                co_length  =  Cut-off length
80                background   =  background
81                Ref.:Mildner, Hall,J Phys D Appl Phys(1986), 19, 1535-1545
82                Note I: This model is valid for 1<surface_dim<3 with limited q range.
83                Note II: This model is not in absolute scale.
84        """
85       
86        ## Parameter details [units, min, max]
87        self.details = {}
88        self.details['scale'] = ['', None, None]
89        self.details['radius'] = ['[A]', None, None]
90        self.details['surface_dim'] = ['', None, None]
91        self.details['co_length'] = ['[A]', None, None]
92        self.details['background'] = ['', None, None]
93
94        ## fittable parameters
95        self.fixed = []
96       
97        ## non-fittable parameters
98        self.non_fittable = []
99       
100        ## parameters with orientation
101        self.orientation_params = []
102
103        ## parameters with magnetism
104        self.magnetic_params = []
105
106        self.category = None
107        self.multiplicity_info = None
108       
109    def __setstate__(self, state):
110        """
111        restore the state of a model from pickle
112        """
113        self.__dict__, self.params, self.dispersion = state
114       
115    def __reduce_ex__(self, proto):
116        """
117        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
118        c model.
119        """
120        state = (self.__dict__, self.params, self.dispersion)
121        return (create_SurfaceFractalModel, tuple(), state, None, None)
122       
123    def clone(self):
124        """ Return a identical copy of self """
125        return self._clone(SurfaceFractalModel())   
126       
127    def run(self, x=0.0):
128        """
129        Evaluate the model
130       
131        :param x: input q, or [q,phi]
132       
133        :return: scattering function P(q)
134       
135        """
136        return CSurfaceFractalModel.run(self, x)
137   
138    def runXY(self, x=0.0):
139        """
140        Evaluate the model in cartesian coordinates
141       
142        :param x: input q, or [qx, qy]
143       
144        :return: scattering function P(q)
145       
146        """
147        return CSurfaceFractalModel.runXY(self, x)
148       
149    def evalDistribution(self, x):
150        """
151        Evaluate the model in cartesian coordinates
152       
153        :param x: input q[], or [qx[], qy[]]
154       
155        :return: scattering function P(q[])
156       
157        """
158        return CSurfaceFractalModel.evalDistribution(self, x)
159       
160    def calculate_ER(self):
161        """
162        Calculate the effective radius for P(q)*S(q)
163       
164        :return: the value of the effective radius
165       
166        """       
167        return CSurfaceFractalModel.calculate_ER(self)
168       
169    def calculate_VR(self):
170        """
171        Calculate the volf ratio for P(q)*S(q)
172       
173        :return: the value of the volf ratio
174       
175        """       
176        return CSurfaceFractalModel.calculate_VR(self)
177             
178    def set_dispersion(self, parameter, dispersion):
179        """
180        Set the dispersion object for a model parameter
181       
182        :param parameter: name of the parameter [string]
183        :param dispersion: dispersion object of type DispersionModel
184       
185        """
186        return CSurfaceFractalModel.set_dispersion(self,
187               parameter, dispersion.cdisp)
188       
189   
190# End of file
191
Note: See TracBrowser for help on using the repository browser.