source: sasview/src/sans/models/StarPolymer.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.2 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\starpolymer.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CStarPolymer
28
29def create_StarPolymer():
30    """
31       Create a model instance
32    """
33    obj = StarPolymer()
34    # CStarPolymer.__init__(obj) is called by
35    # the StarPolymer constructor
36    return obj
37
38class StarPolymer(CStarPolymer, BaseComponent):
39    """
40    Class that evaluates a StarPolymer model.
41    This file was auto-generated from src\sans\models\include\starpolymer.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    * arms            = 3.0
48    * R2              = 100.0 [A]
49    * scale           = 1.0
50    * background      = 0.0 [1/cm]
51
52    """
53       
54    def __init__(self, multfactor=1):
55        """ Initialization """
56        self.__dict__ = {}
57       
58        # Initialize BaseComponent first, then sphere
59        BaseComponent.__init__(self)
60        #apply(CStarPolymer.__init__, (self,))
61
62        CStarPolymer.__init__(self)
63        self.is_multifunc = False
64                       
65        ## Name of the model
66        self.name = "StarPolymer"
67        ## Model description
68        self.description = """
69          Scattering model class for 'Star polymer with Gaussian statistics'
70                with
71                P(q) = 2/{fv^2} * (v - (1-exp(-v)) + {f-1}/2 * (1-exp(-v))^2)
72                where
73                - v = u^2f/(3f-2)
74                - u = <R_g^2>q^2, where <R_g^2> is the ensemble average radius of
75                giration squared of an arm
76                - f is the number of arms on the star
77        """
78       
79        ## Parameter details [units, min, max]
80        self.details = {}
81        self.details['arms'] = ['', None, None]
82        self.details['R2'] = ['[A]', None, None]
83        self.details['scale'] = ['', None, None]
84        self.details['background'] = ['[1/cm]', None, None]
85
86        ## fittable parameters
87        self.fixed = []
88       
89        ## non-fittable parameters
90        self.non_fittable = []
91       
92        ## parameters with orientation
93        self.orientation_params = []
94
95        ## parameters with magnetism
96        self.magnetic_params = []
97
98        self.category = None
99        self.multiplicity_info = None
100       
101    def __setstate__(self, state):
102        """
103        restore the state of a model from pickle
104        """
105        self.__dict__, self.params, self.dispersion = state
106       
107    def __reduce_ex__(self, proto):
108        """
109        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
110        c model.
111        """
112        state = (self.__dict__, self.params, self.dispersion)
113        return (create_StarPolymer, tuple(), state, None, None)
114       
115    def clone(self):
116        """ Return a identical copy of self """
117        return self._clone(StarPolymer())   
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        return CStarPolymer.run(self, x)
129   
130    def runXY(self, x=0.0):
131        """
132        Evaluate the model in cartesian coordinates
133       
134        :param x: input q, or [qx, qy]
135       
136        :return: scattering function P(q)
137       
138        """
139        return CStarPolymer.runXY(self, x)
140       
141    def evalDistribution(self, x):
142        """
143        Evaluate the model in cartesian coordinates
144       
145        :param x: input q[], or [qx[], qy[]]
146       
147        :return: scattering function P(q[])
148       
149        """
150        return CStarPolymer.evalDistribution(self, x)
151       
152    def calculate_ER(self):
153        """
154        Calculate the effective radius for P(q)*S(q)
155       
156        :return: the value of the effective radius
157       
158        """       
159        return CStarPolymer.calculate_ER(self)
160       
161    def calculate_VR(self):
162        """
163        Calculate the volf ratio for P(q)*S(q)
164       
165        :return: the value of the volf ratio
166       
167        """       
168        return CStarPolymer.calculate_VR(self)
169             
170    def set_dispersion(self, parameter, dispersion):
171        """
172        Set the dispersion object for a model parameter
173       
174        :param parameter: name of the parameter [string]
175        :param dispersion: dispersion object of type DispersionModel
176       
177        """
178        return CStarPolymer.set_dispersion(self,
179               parameter, dispersion.cdisp)
180       
181   
182# End of file
183
Note: See TracBrowser for help on using the repository browser.