source: sasview/src/sans/models/ParallelepipedModel.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@…>, 11 years ago

This branch is now merged with the latest trunk release. I will merge them next.

  • Property mode set to 100644
File size: 8.1 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\parallelepiped.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CParallelepipedModel
26
27def create_ParallelepipedModel():
28    """
29       Create a model instance
30    """
31    obj = ParallelepipedModel()
32    # CParallelepipedModel.__init__(obj) is called by
33    # the ParallelepipedModel constructor
34    return obj
35
36class ParallelepipedModel(CParallelepipedModel, BaseComponent):
37    """
38    Class that evaluates a ParallelepipedModel model.
39    This file was auto-generated from src\sans\models\include\parallelepiped.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         short_a         = 35.0 [A]
45         short_b         = 75.0 [A]
46         long_c          = 400.0 [A]
47         sldPipe         = 6.3e-06 [1/A^(2)]
48         sldSolv         = 1e-06 [1/A^(2)]
49         background      = 0.0 [1/cm]
50         parallel_theta  = 0.0 [deg]
51         parallel_phi    = 0.0 [deg]
52         parallel_psi    = 0.0 [deg]
53         M0_sld_pipe     = 0.0 [1/A^(2)]
54         M_theta_pipe    = 0.0 [deg]
55         M_phi_pipe      = 0.0 [deg]
56         M0_sld_solv     = 0.0 [1/A^(2)]
57         M_theta_solv    = 0.0 [deg]
58         M_phi_solv      = 0.0 [deg]
59         Up_frac_i       = 0.5 [u/(u+d)]
60         Up_frac_f       = 0.5 [u/(u+d)]
61         Up_theta        = 0.0 [deg]
62
63    """
64       
65    def __init__(self, multfactor=1):
66        """ Initialization """
67        self.__dict__ = {}
68       
69        # Initialize BaseComponent first, then sphere
70        BaseComponent.__init__(self)
71        #apply(CParallelepipedModel.__init__, (self,))
72
73        CParallelepipedModel.__init__(self)
74        self.is_multifunc = False
75                       
76        ## Name of the model
77        self.name = "ParallelepipedModel"
78        ## Model description
79        self.description = """
80         Form factor for a rectangular solid with uniform scattering length density.
81               
82                scale:Scale factor
83                short_a: length of short edge  [A]
84                short_b: length of another short edge [A]
85                long_c: length of long edge  of the parallelepiped [A]
86                sldPipe: Pipe_sld
87                sldSolv: solvent_sld
88                background:Incoherent Background [1/cm]
89        """
90       
91        ## Parameter details [units, min, max]
92        self.details = {}
93        self.details['scale'] = ['', None, None]
94        self.details['short_a'] = ['[A]', None, None]
95        self.details['short_b'] = ['[A]', None, None]
96        self.details['long_c'] = ['[A]', None, None]
97        self.details['sldPipe'] = ['[1/A^(2)]', None, None]
98        self.details['sldSolv'] = ['[1/A^(2)]', None, None]
99        self.details['background'] = ['[1/cm]', None, None]
100        self.details['parallel_theta'] = ['[deg]', None, None]
101        self.details['parallel_phi'] = ['[deg]', None, None]
102        self.details['parallel_psi'] = ['[deg]', None, None]
103        self.details['M0_sld_pipe'] = ['[1/A^(2)]', None, None]
104        self.details['M_theta_pipe'] = ['[deg]', None, None]
105        self.details['M_phi_pipe'] = ['[deg]', None, None]
106        self.details['M0_sld_solv'] = ['[1/A^(2)]', None, None]
107        self.details['M_theta_solv'] = ['[deg]', None, None]
108        self.details['M_phi_solv'] = ['[deg]', None, None]
109        self.details['Up_frac_i'] = ['[u/(u+d)]', None, None]
110        self.details['Up_frac_f'] = ['[u/(u+d)]', None, None]
111        self.details['Up_theta'] = ['[deg]', None, None]
112
113        ## fittable parameters
114        self.fixed = ['short_a.width',
115                      'short_b.width',
116                      'long_c.width',
117                      'parallel_phi.width',
118                      'parallel_psi.width',
119                      'parallel_theta.width']
120       
121        ## non-fittable parameters
122        self.non_fittable = []
123       
124        ## parameters with orientation
125        self.orientation_params = ['parallel_phi',
126                                   'parallel_psi',
127                                   'parallel_theta',
128                                   'parallel_phi.width',
129                                   'parallel_psi.width',
130                                   'parallel_theta.width',
131                                   'M0_sld_pipe',
132                                   'M_theta_pipe',
133                                   'M_phi_pipe',
134                                   'M0_sld_solv',
135                                   'M_theta_solv',
136                                   'M_phi_solv',
137                                   'Up_frac_i',
138                                   'Up_frac_f',
139                                   'Up_theta']
140
141        ## parameters with magnetism
142        self.magnetic_params = ['M0_sld_pipe', 'M_theta_pipe', 'M_phi_pipe', 'M0_sld_solv', 'M_theta_solv', 'M_phi_solv', 'Up_frac_i', 'Up_frac_f', 'Up_theta']
143
144        self.category = None
145        self.multiplicity_info = None
146       
147    def __setstate__(self, state):
148        """
149        restore the state of a model from pickle
150        """
151        self.__dict__, self.params, self.dispersion = state
152       
153    def __reduce_ex__(self, proto):
154        """
155        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
156        c model.
157        """
158        state = (self.__dict__, self.params, self.dispersion)
159        return (create_ParallelepipedModel, tuple(), state, None, None)
160       
161    def clone(self):
162        """ Return a identical copy of self """
163        return self._clone(ParallelepipedModel())   
164       
165    def run(self, x=0.0):
166        """
167        Evaluate the model
168       
169        :param x: input q, or [q,phi]
170       
171        :return: scattering function P(q)
172       
173        """
174        return CParallelepipedModel.run(self, x)
175   
176    def runXY(self, x=0.0):
177        """
178        Evaluate the model in cartesian coordinates
179       
180        :param x: input q, or [qx, qy]
181       
182        :return: scattering function P(q)
183       
184        """
185        return CParallelepipedModel.runXY(self, x)
186       
187    def evalDistribution(self, x):
188        """
189        Evaluate the model in cartesian coordinates
190       
191        :param x: input q[], or [qx[], qy[]]
192       
193        :return: scattering function P(q[])
194       
195        """
196        return CParallelepipedModel.evalDistribution(self, x)
197       
198    def calculate_ER(self):
199        """
200        Calculate the effective radius for P(q)*S(q)
201       
202        :return: the value of the effective radius
203       
204        """       
205        return CParallelepipedModel.calculate_ER(self)
206       
207    def calculate_VR(self):
208        """
209        Calculate the volf ratio for P(q)*S(q)
210       
211        :return: the value of the volf ratio
212       
213        """       
214        return CParallelepipedModel.calculate_VR(self)
215             
216    def set_dispersion(self, parameter, dispersion):
217        """
218        Set the dispersion object for a model parameter
219       
220        :param parameter: name of the parameter [string]
221        :param dispersion: dispersion object of type DispersionModel
222       
223        """
224        return CParallelepipedModel.set_dispersion(self,
225               parameter, dispersion.cdisp)
226       
227   
228# End of file
229
Note: See TracBrowser for help on using the repository browser.