source: sasview/sansmodels/src/sans/models/PearlNecklaceModel.py @ 8bac371

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 8bac371 was 92df66f8, checked in by Gervaise Alina <gervyh@…>, 13 years ago

commit wrap model

  • Property mode set to 100644
File size: 5.7 KB
Line 
1#!/usr/bin/env python
2
3##############################################################################
4#       This software was developed by the University of Tennessee as part of the
5#       Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
6#       project funded by the US National Science Foundation.
7#
8#       If you use DANSE applications to do scientific research that leads to
9#       publication, we ask that you acknowledge the use of the software with the
10#       following sentence:
11#
12#       "This work benefited from DANSE software developed under NSF award DMR-0520547."
13#
14#       copyright 2008, University of Tennessee
15##############################################################################
16
17
18"""
19Provide functionality for a C extension model
20
21:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
22         DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\pearlnecklace.h
23         AND RE-RUN THE GENERATOR SCRIPT
24
25"""
26
27from sans.models.BaseComponent import BaseComponent
28from sans.models.sans_extension.c_models import CPearlNecklaceModel
29import copy   
30
31def create_PearlNecklaceModel():
32    obj = PearlNecklaceModel()
33    #CPearlNecklaceModel.__init__(obj) is called by PearlNecklaceModel constructor
34    return obj
35
36class PearlNecklaceModel(CPearlNecklaceModel, BaseComponent):
37    """
38    Class that evaluates a PearlNecklaceModel model.
39    This file was auto-generated from ..\c_extensions\pearlnecklace.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         thick_string    = 2.5 [A]
47         num_pearls      = 3.0
48         sld_pearl       = 1e-06 [1/A^(2)]
49         sld_string      = 1e-06 [1/A^(2)]
50         sld_solv        = 6.3e-06 [1/A^(2)]
51         background      = 0.0
52
53    """
54       
55    def __init__(self):
56        """ Initialization """
57       
58        # Initialize BaseComponent first, then sphere
59        BaseComponent.__init__(self)
60        #apply(CPearlNecklaceModel.__init__, (self,))
61        CPearlNecklaceModel.__init__(self)
62       
63        ## Name of the model
64        self.name = "PearlNecklaceModel"
65        ## Model description
66        self.description ="""Calculate form factor for Pearl Necklace Model
67                [Macromol. Symp. 2004, 211, 25-42]
68                Parameters:
69                background:background
70                scale: scale factor
71                sld_pearl: the SLD of the pearl spheres
72                sld_string: the SLD of the strings
73                sld_solv: the SLD of the solvent
74                num_pearls: number of the pearls
75                radius: the radius of a pearl
76                edge_separation: the length of string segment; surface to surface
77                thick_string: thickness (ie, diameter) of the string"""
78       
79        ## Parameter details [units, min, max]
80        self.details = {}
81        self.details['scale'] = ['', None, None]
82        self.details['radius'] = ['[A]', None, None]
83        self.details['edge_separation'] = ['[A]', None, None]
84        self.details['thick_string'] = ['[A]', None, None]
85        self.details['num_pearls'] = ['', None, None]
86        self.details['sld_pearl'] = ['[1/A^(2)]', None, None]
87        self.details['sld_string'] = ['[1/A^(2)]', None, None]
88        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
89        self.details['background'] = ['', None, None]
90
91        ## fittable parameters
92        self.fixed=['radius.width', 'edge_separation.width']
93       
94        ## non-fittable parameters
95        self.non_fittable = []
96       
97        ## parameters with orientation
98        self.orientation_params = []
99
100    def __setstate__(self, state):
101        """
102        restore the state of a model from pickle
103        """
104        self.__dict__, self.params, self.dispersion = state
105       
106    def __reduce_ex__(self, proto):
107        """
108        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
109        c model.
110        """
111        state = (self.__dict__, self.params, self.dispersion)
112        return (create_PearlNecklaceModel,tuple(), state, None, None)
113       
114    def clone(self):
115        """ Return a identical copy of self """
116        return self._clone(PearlNecklaceModel())   
117       
118   
119    def run(self, x=0.0):
120        """
121        Evaluate the model
122       
123        :param x: input q, or [q,phi]
124       
125        :return: scattering function P(q)
126       
127        """
128       
129        return CPearlNecklaceModel.run(self, x)
130   
131    def runXY(self, x=0.0):
132        """
133        Evaluate the model in cartesian coordinates
134       
135        :param x: input q, or [qx, qy]
136       
137        :return: scattering function P(q)
138       
139        """
140       
141        return CPearlNecklaceModel.runXY(self, x)
142       
143    def evalDistribution(self, x=[]):
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 CPearlNecklaceModel.evalDistribution(self, x)
153       
154    def calculate_ER(self):
155        """
156        Calculate the effective radius for P(q)*S(q)
157       
158        :return: the value of the effective radius
159       
160        """       
161        return CPearlNecklaceModel.calculate_ER(self)
162       
163    def set_dispersion(self, parameter, dispersion):
164        """
165        Set the dispersion object for a model parameter
166       
167        :param parameter: name of the parameter [string]
168        :param dispersion: dispersion object of type DispersionModel
169       
170        """
171        return CPearlNecklaceModel.set_dispersion(self, parameter, dispersion.cdisp)
172       
173   
174# End of file
Note: See TracBrowser for help on using the repository browser.