source: sasview/src/sans/models/FractalModel.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: 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: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
19         DO NOT MODIFY THIS FILE, MODIFY
20            src\sans\models\include\fractal.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CFractalModel
26
27def create_FractalModel():
28    """
29       Create a model instance
30    """
31    obj = FractalModel()
32    # CFractalModel.__init__(obj) is called by
33    # the FractalModel constructor
34    return obj
35
36class FractalModel(CFractalModel, BaseComponent):
37    """
38    Class that evaluates a FractalModel model.
39    This file was auto-generated from src\sans\models\include\fractal.h.
40    Refer to that file and the structure it contains
41    for details of the model.
42    List of default parameters:
43         radius          = 5.0 [A]
44         scale           = 0.05
45         fractal_dim     = 2.0
46         cor_length      = 100.0 [A]
47         sldBlock        = 2e-06 [1/A^(2)]
48         sldSolv         = 6.35e-06 [1/A^(2)]
49         background      = 0.0 [1/cm]
50
51    """
52       
53    def __init__(self, multfactor=1):
54        """ Initialization """
55        self.__dict__ = {}
56       
57        # Initialize BaseComponent first, then sphere
58        BaseComponent.__init__(self)
59        #apply(CFractalModel.__init__, (self,))
60
61        CFractalModel.__init__(self)
62        self.is_multifunc = False
63                       
64        ## Name of the model
65        self.name = "FractalModel"
66        ## Model description
67        self.description = """
68         The scattering intensity  I(x) = P(|x|)*S(|x|) + background, where
69                p(x)= scale * V * delta^(2)* F(x*radius)^(2)
70                F(x) = 3*[sin(x)-x cos(x)]/x**3
71                where delta = sldBlock -sldSolv.
72                scale        =  scale factor * Volume fraction
73                radius       =  Block radius
74                fractal_dim  =  Fractal dimension
75                cor_length  =  Correlation Length
76                sldBlock    =  SDL block
77                sldSolv  =  SDL solvent
78                background   =  background
79        """
80       
81        ## Parameter details [units, min, max]
82        self.details = {}
83        self.details['radius'] = ['[A]', None, None]
84        self.details['scale'] = ['', None, None]
85        self.details['fractal_dim'] = ['', None, None]
86        self.details['cor_length'] = ['[A]', None, None]
87        self.details['sldBlock'] = ['[1/A^(2)]', None, None]
88        self.details['sldSolv'] = ['[1/A^(2)]', None, None]
89        self.details['background'] = ['[1/cm]', None, None]
90
91        ## fittable parameters
92        self.fixed = []
93       
94        ## non-fittable parameters
95        self.non_fittable = []
96       
97        ## parameters with orientation
98        self.orientation_params = []
99
100        ## parameters with magnetism
101        self.magnetic_params = []
102
103        self.category = None
104        self.multiplicity_info = None
105       
106    def __setstate__(self, state):
107        """
108        restore the state of a model from pickle
109        """
110        self.__dict__, self.params, self.dispersion = state
111       
112    def __reduce_ex__(self, proto):
113        """
114        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
115        c model.
116        """
117        state = (self.__dict__, self.params, self.dispersion)
118        return (create_FractalModel, tuple(), state, None, None)
119       
120    def clone(self):
121        """ Return a identical copy of self """
122        return self._clone(FractalModel())   
123       
124    def run(self, x=0.0):
125        """
126        Evaluate the model
127       
128        :param x: input q, or [q,phi]
129       
130        :return: scattering function P(q)
131       
132        """
133        return CFractalModel.run(self, x)
134   
135    def runXY(self, x=0.0):
136        """
137        Evaluate the model in cartesian coordinates
138       
139        :param x: input q, or [qx, qy]
140       
141        :return: scattering function P(q)
142       
143        """
144        return CFractalModel.runXY(self, x)
145       
146    def evalDistribution(self, x):
147        """
148        Evaluate the model in cartesian coordinates
149       
150        :param x: input q[], or [qx[], qy[]]
151       
152        :return: scattering function P(q[])
153       
154        """
155        return CFractalModel.evalDistribution(self, x)
156       
157    def calculate_ER(self):
158        """
159        Calculate the effective radius for P(q)*S(q)
160       
161        :return: the value of the effective radius
162       
163        """       
164        return CFractalModel.calculate_ER(self)
165       
166    def calculate_VR(self):
167        """
168        Calculate the volf ratio for P(q)*S(q)
169       
170        :return: the value of the volf ratio
171       
172        """       
173        return CFractalModel.calculate_VR(self)
174             
175    def set_dispersion(self, parameter, dispersion):
176        """
177        Set the dispersion object for a model parameter
178       
179        :param parameter: name of the parameter [string]
180        :param dispersion: dispersion object of type DispersionModel
181       
182        """
183        return CFractalModel.set_dispersion(self,
184               parameter, dispersion.cdisp)
185       
186   
187# End of file
188
Note: See TracBrowser for help on using the repository browser.