source: sasview/src/sans/models/LinearPearlsModel.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.6 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\linearpearls.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CLinearPearlsModel
26
27def create_LinearPearlsModel():
28    """
29       Create a model instance
30    """
31    obj = LinearPearlsModel()
32    # CLinearPearlsModel.__init__(obj) is called by
33    # the LinearPearlsModel constructor
34    return obj
35
36class LinearPearlsModel(CLinearPearlsModel, BaseComponent):
37    """
38    Class that evaluates a LinearPearlsModel model.
39    This file was auto-generated from src\sans\models\include\linearpearls.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         radius          = 80.0 [A]
45         edge_separation = 350.0 [A]
46         num_pearls      = 3.0
47         sld_pearl       = 1e-06 [1/A^(2)]
48         sld_solv        = 6.3e-06 [1/A^(2)]
49         background      = 0.0
50         scale           = 1.0
51         radius          = 80.0 [A]
52         edge_separation = 350.0 [A]
53         num_pearls      = 3.0
54         sld_pearl       = 1e-06 [1/A^(2)]
55         sld_solv        = 6.3e-06 [1/A^(2)]
56         background      = 0.0
57
58    """
59       
60    def __init__(self, multfactor=1):
61        """ Initialization """
62        self.__dict__ = {}
63       
64        # Initialize BaseComponent first, then sphere
65        BaseComponent.__init__(self)
66        #apply(CLinearPearlsModel.__init__, (self,))
67
68        CLinearPearlsModel.__init__(self)
69        self.is_multifunc = False
70                       
71        ## Name of the model
72        self.name = "LinearPearlsModel"
73        ## Model description
74        self.description = """
75        Calculate form factor for Pearl Necklace Model
76                [Macromol. 1996, 29, 2974-2979]
77                Parameters:
78                background:background
79                scale: scale factor
80                sld_pearl: the SLD of the pearl spheres
81                sld_solv: the SLD of the solvent
82                num_pearls: number of the pearls
83                radius: the radius of a pearl
84                edge_separation: the length of string segment; surface to surface
85        """
86       
87        ## Parameter details [units, min, max]
88        self.details = {}
89        self.details['scale'] = ['', None, None]
90        self.details['radius'] = ['[A]', None, None]
91        self.details['edge_separation'] = ['[A]', None, None]
92        self.details['num_pearls'] = ['', None, None]
93        self.details['sld_pearl'] = ['[1/A^(2)]', None, None]
94        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
95        self.details['background'] = ['', None, None]
96        self.details['scale'] = ['', None, None]
97        self.details['radius'] = ['[A]', None, None]
98        self.details['edge_separation'] = ['[A]', None, None]
99        self.details['num_pearls'] = ['', None, None]
100        self.details['sld_pearl'] = ['[1/A^(2)]', None, None]
101        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
102        self.details['background'] = ['', None, None]
103
104        ## fittable parameters
105        self.fixed = ['radius.width',
106                      'edge_separation.width']
107       
108        ## non-fittable parameters
109        self.non_fittable = []
110       
111        ## parameters with orientation
112        self.orientation_params = []
113
114        ## parameters with magnetism
115        self.magnetic_params = []
116
117        self.category = None
118        self.multiplicity_info = None
119       
120    def __setstate__(self, state):
121        """
122        restore the state of a model from pickle
123        """
124        self.__dict__, self.params, self.dispersion = state
125       
126    def __reduce_ex__(self, proto):
127        """
128        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
129        c model.
130        """
131        state = (self.__dict__, self.params, self.dispersion)
132        return (create_LinearPearlsModel, tuple(), state, None, None)
133       
134    def clone(self):
135        """ Return a identical copy of self """
136        return self._clone(LinearPearlsModel())   
137       
138    def run(self, x=0.0):
139        """
140        Evaluate the model
141       
142        :param x: input q, or [q,phi]
143       
144        :return: scattering function P(q)
145       
146        """
147        return CLinearPearlsModel.run(self, x)
148   
149    def runXY(self, x=0.0):
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 CLinearPearlsModel.runXY(self, x)
159       
160    def evalDistribution(self, x):
161        """
162        Evaluate the model in cartesian coordinates
163       
164        :param x: input q[], or [qx[], qy[]]
165       
166        :return: scattering function P(q[])
167       
168        """
169        return CLinearPearlsModel.evalDistribution(self, x)
170       
171    def calculate_ER(self):
172        """
173        Calculate the effective radius for P(q)*S(q)
174       
175        :return: the value of the effective radius
176       
177        """       
178        return CLinearPearlsModel.calculate_ER(self)
179       
180    def calculate_VR(self):
181        """
182        Calculate the volf ratio for P(q)*S(q)
183       
184        :return: the value of the volf ratio
185       
186        """       
187        return CLinearPearlsModel.calculate_VR(self)
188             
189    def set_dispersion(self, parameter, dispersion):
190        """
191        Set the dispersion object for a model parameter
192       
193        :param parameter: name of the parameter [string]
194        :param dispersion: dispersion object of type DispersionModel
195       
196        """
197        return CLinearPearlsModel.set_dispersion(self,
198               parameter, dispersion.cdisp)
199       
200   
201# End of file
202
Note: See TracBrowser for help on using the repository browser.