source: sasview/src/sans/models/RaspBerryModel.py @ d09f0ae1

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 d09f0ae1 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: 6.0 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\raspberry.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CRaspBerryModel
28
29def create_RaspBerryModel():
30    """
31       Create a model instance
32    """
33    obj = RaspBerryModel()
34    # CRaspBerryModel.__init__(obj) is called by
35    # the RaspBerryModel constructor
36    return obj
37
38class RaspBerryModel(CRaspBerryModel, BaseComponent):
39    """
40    Class that evaluates a RaspBerryModel model.
41    This file was auto-generated from src\sans\models\include\raspberry.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    * volf_Lsph       = 0.05
48    * radius_Lsph     = 5000.0 [A]
49    * sld_Lsph        = -4e-07 [1/A^(2)]
50    * volf_Ssph       = 0.005
51    * radius_Ssph     = 100.0 [A]
52    * surfrac_Ssph    = 0.4
53    * sld_Ssph        = 3.5e-06 [1/A^(2)]
54    * delta_Ssph      = 0.0
55    * sld_solv        = 6.3e-06 [1/A^(2)]
56    * background      = 0.0 [1/cm]
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(CRaspBerryModel.__init__, (self,))
67
68        CRaspBerryModel.__init__(self)
69        self.is_multifunc = False
70                       
71        ## Name of the model
72        self.name = "RaspBerryModel"
73        ## Model description
74        self.description = """
75         RaspBerryModel:
76                volf_Lsph = volume fraction large spheres
77                radius_Lsph = radius large sphere (A)
78                sld_Lsph = sld large sphere (A-2)
79                volf_Ssph = volume fraction small spheres
80                radius_Ssph = radius small sphere (A)
81                surfrac_Ssph = fraction of small spheres at surface
82                sld_Ssph = sld small sphere
83                delta_Ssph = small sphere penetration (A)
84                sld_solv   = sld solvent
85                background = background (cm-1)
86                Ref: J. coll. inter. sci. (2010) vol. 343 (1) pp. 36-41.
87        """
88       
89        ## Parameter details [units, min, max]
90        self.details = {}
91        self.details['volf_Lsph'] = ['', None, None]
92        self.details['radius_Lsph'] = ['[A]', None, None]
93        self.details['sld_Lsph'] = ['[1/A^(2)]', None, None]
94        self.details['volf_Ssph'] = ['', None, None]
95        self.details['radius_Ssph'] = ['[A]', None, None]
96        self.details['surfrac_Ssph'] = ['', None, None]
97        self.details['sld_Ssph'] = ['[1/A^(2)]', None, None]
98        self.details['delta_Ssph'] = ['', None, None]
99        self.details['sld_solv'] = ['[1/A^(2)]', None, None]
100        self.details['background'] = ['[1/cm]', None, None]
101
102        ## fittable parameters
103        self.fixed = ['radius_Lsph.width']
104       
105        ## non-fittable parameters
106        self.non_fittable = []
107       
108        ## parameters with orientation
109        self.orientation_params = []
110
111        ## parameters with magnetism
112        self.magnetic_params = []
113
114        self.category = None
115        self.multiplicity_info = None
116       
117    def __setstate__(self, state):
118        """
119        restore the state of a model from pickle
120        """
121        self.__dict__, self.params, self.dispersion = state
122       
123    def __reduce_ex__(self, proto):
124        """
125        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
126        c model.
127        """
128        state = (self.__dict__, self.params, self.dispersion)
129        return (create_RaspBerryModel, tuple(), state, None, None)
130       
131    def clone(self):
132        """ Return a identical copy of self """
133        return self._clone(RaspBerryModel())   
134       
135    def run(self, x=0.0):
136        """
137        Evaluate the model
138       
139        :param x: input q, or [q,phi]
140       
141        :return: scattering function P(q)
142       
143        """
144        return CRaspBerryModel.run(self, x)
145   
146    def runXY(self, x=0.0):
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 CRaspBerryModel.runXY(self, x)
156       
157    def evalDistribution(self, x):
158        """
159        Evaluate the model in cartesian coordinates
160       
161        :param x: input q[], or [qx[], qy[]]
162       
163        :return: scattering function P(q[])
164       
165        """
166        return CRaspBerryModel.evalDistribution(self, x)
167       
168    def calculate_ER(self):
169        """
170        Calculate the effective radius for P(q)*S(q)
171       
172        :return: the value of the effective radius
173       
174        """       
175        return CRaspBerryModel.calculate_ER(self)
176       
177    def calculate_VR(self):
178        """
179        Calculate the volf ratio for P(q)*S(q)
180       
181        :return: the value of the volf ratio
182       
183        """       
184        return CRaspBerryModel.calculate_VR(self)
185             
186    def set_dispersion(self, parameter, dispersion):
187        """
188        Set the dispersion object for a model parameter
189       
190        :param parameter: name of the parameter [string]
191        :param dispersion: dispersion object of type DispersionModel
192       
193        """
194        return CRaspBerryModel.set_dispersion(self,
195               parameter, dispersion.cdisp)
196       
197   
198# End of file
199
Note: See TracBrowser for help on using the repository browser.