source: sasview/src/sans/models/BCCrystalModel.py @ 400155b

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 400155b was 400155b, checked in by gonzalezm, 9 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.4 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\bcc.h
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sans.models.BaseComponent import BaseComponent
27from sans.models.sans_extension.c_models import CBCCrystalModel
28
29def create_BCCrystalModel():
30    """
31       Create a model instance
32    """
33    obj = BCCrystalModel()
34    # CBCCrystalModel.__init__(obj) is called by
35    # the BCCrystalModel constructor
36    return obj
37
38class BCCrystalModel(CBCCrystalModel, BaseComponent):
39    """
40    Class that evaluates a BCCrystalModel model.
41    This file was auto-generated from src\sans\models\include\bcc.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    * scale           = 1.0
48    * dnn             = 220.0 [A]
49    * d_factor        = 0.06
50    * radius          = 40.0 [A]
51    * sldSph          = 3e-06 [1/A^(2)]
52    * sldSolv         = 6.3e-06 [1/A^(2)]
53    * background      = 0.0 [1/cm]
54    * theta           = 0.0 [deg]
55    * phi             = 0.0 [deg]
56    * psi             = 0.0 [deg]
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(CBCCrystalModel.__init__, (self,))
67
68        CBCCrystalModel.__init__(self)
69        self.is_multifunc = False
70                       
71        ## Name of the model
72        self.name = "BCCrystalModel"
73        ## Model description
74        self.description = """
75        P(q)=(scale/Vp)*V_lattice*P(q)*Z(q)+bkg where scale is the volume
76                fraction of sphere,
77                Vp = volume of the primary particle,
78                V_lattice = volume correction for
79                for the crystal structure,
80                P(q)= form factor of the sphere (normalized),
81                Z(q)= paracrystalline structure factor
82                for a face centered cubic structure.
83                [Body Centered Cubic ParaCrystal Model]
84                Parameters;
85                scale: volume fraction of spheres
86                bkg:background, R: radius of sphere
87                dnn: Nearest neighbor distance
88                d_factor: Paracrystal distortion factor
89                radius: radius of the spheres
90                sldSph: SLD of the sphere
91                sldSolv: SLD of the solvent
92               
93        """
94       
95        ## Parameter details [units, min, max]
96        self.details = {}
97        self.details['scale'] = ['', None, None]
98        self.details['dnn'] = ['[A]', None, None]
99        self.details['d_factor'] = ['', None, None]
100        self.details['radius'] = ['[A]', None, None]
101        self.details['sldSph'] = ['[1/A^(2)]', None, None]
102        self.details['sldSolv'] = ['[1/A^(2)]', None, None]
103        self.details['background'] = ['[1/cm]', None, None]
104        self.details['theta'] = ['[deg]', None, None]
105        self.details['phi'] = ['[deg]', None, None]
106        self.details['psi'] = ['[deg]', None, None]
107
108        ## fittable parameters
109        self.fixed = ['radius.width',
110                      'phi.width',
111                      'psi.width',
112                      'theta.width']
113       
114        ## non-fittable parameters
115        self.non_fittable = []
116       
117        ## parameters with orientation
118        self.orientation_params = ['phi',
119                                   'psi',
120                                   'theta',
121                                   'phi.width',
122                                   'psi.width',
123                                   'theta.width']
124
125        ## parameters with magnetism
126        self.magnetic_params = []
127
128        self.category = None
129        self.multiplicity_info = None
130       
131    def __setstate__(self, state):
132        """
133        restore the state of a model from pickle
134        """
135        self.__dict__, self.params, self.dispersion = state
136       
137    def __reduce_ex__(self, proto):
138        """
139        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
140        c model.
141        """
142        state = (self.__dict__, self.params, self.dispersion)
143        return (create_BCCrystalModel, tuple(), state, None, None)
144       
145    def clone(self):
146        """ Return a identical copy of self """
147        return self._clone(BCCrystalModel())   
148       
149    def run(self, x=0.0):
150        """
151        Evaluate the model
152       
153        :param x: input q, or [q,phi]
154       
155        :return: scattering function P(q)
156       
157        """
158        return CBCCrystalModel.run(self, x)
159   
160    def runXY(self, x=0.0):
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 CBCCrystalModel.runXY(self, x)
170       
171    def evalDistribution(self, x):
172        """
173        Evaluate the model in cartesian coordinates
174       
175        :param x: input q[], or [qx[], qy[]]
176       
177        :return: scattering function P(q[])
178       
179        """
180        return CBCCrystalModel.evalDistribution(self, x)
181       
182    def calculate_ER(self):
183        """
184        Calculate the effective radius for P(q)*S(q)
185       
186        :return: the value of the effective radius
187       
188        """       
189        return CBCCrystalModel.calculate_ER(self)
190       
191    def calculate_VR(self):
192        """
193        Calculate the volf ratio for P(q)*S(q)
194       
195        :return: the value of the volf ratio
196       
197        """       
198        return CBCCrystalModel.calculate_VR(self)
199             
200    def set_dispersion(self, parameter, dispersion):
201        """
202        Set the dispersion object for a model parameter
203       
204        :param parameter: name of the parameter [string]
205        :param dispersion: dispersion object of type DispersionModel
206       
207        """
208        return CBCCrystalModel.set_dispersion(self,
209               parameter, dispersion.cdisp)
210       
211   
212# End of file
213
Note: See TracBrowser for help on using the repository browser.