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

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

  • 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: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
19         DO NOT MODIFY THIS FILE, MODIFY
20            src\sans\models\include\multishell.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CMultiShellModel
26
27def create_MultiShellModel():
28    """
29       Create a model instance
30    """
31    obj = MultiShellModel()
32    # CMultiShellModel.__init__(obj) is called by
33    # the MultiShellModel constructor
34    return obj
35
36class MultiShellModel(CMultiShellModel, BaseComponent):
37    """
38    Class that evaluates a MultiShellModel model.
39    This file was auto-generated from src\sans\models\include\multishell.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         core_radius     = 60.0 [A]
45         s_thickness     = 10.0 [A]
46         w_thickness     = 10.0 [A]
47         core_sld        = 6.4e-06 [1/A^(2)]
48         shell_sld       = 4e-07 [1/A^(2)]
49         n_pairs         = 2.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(CMultiShellModel.__init__, (self,))
61
62        CMultiShellModel.__init__(self)
63        self.is_multifunc = False
64                       
65        ## Name of the model
66        self.name = "MultiShellModel"
67        ## Model description
68        self.description = """
69         MultiShell (Sphere) Model (or Multilamellar Vesicles): Model parameters;
70                scale : scale factor
71                core_radius : Core radius of the multishell
72                s_thickness: shell thickness
73                w_thickness: water thickness
74                core_sld: core scattering length density
75                shell_sld: shell scattering length density
76                n_pairs:number of pairs of water/shell
77                background: incoherent background
78        """
79       
80        ## Parameter details [units, min, max]
81        self.details = {}
82        self.details['scale'] = ['', None, None]
83        self.details['core_radius'] = ['[A]', None, None]
84        self.details['s_thickness'] = ['[A]', None, None]
85        self.details['w_thickness'] = ['[A]', None, None]
86        self.details['core_sld'] = ['[1/A^(2)]', None, None]
87        self.details['shell_sld'] = ['[1/A^(2)]', None, None]
88        self.details['n_pairs'] = ['', None, None]
89        self.details['background'] = ['[1/cm]', None, None]
90
91        ## fittable parameters
92        self.fixed = ['core_radius.width',
93                      's_thickness.width',
94                      'w_thickness.width']
95       
96        ## non-fittable parameters
97        self.non_fittable = []
98       
99        ## parameters with orientation
100        self.orientation_params = []
101
102        ## parameters with magnetism
103        self.magnetic_params = []
104
105        self.category = None
106        self.multiplicity_info = None
107       
108    def __setstate__(self, state):
109        """
110        restore the state of a model from pickle
111        """
112        self.__dict__, self.params, self.dispersion = state
113       
114    def __reduce_ex__(self, proto):
115        """
116        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
117        c model.
118        """
119        state = (self.__dict__, self.params, self.dispersion)
120        return (create_MultiShellModel, tuple(), state, None, None)
121       
122    def clone(self):
123        """ Return a identical copy of self """
124        return self._clone(MultiShellModel())   
125       
126    def run(self, x=0.0):
127        """
128        Evaluate the model
129       
130        :param x: input q, or [q,phi]
131       
132        :return: scattering function P(q)
133       
134        """
135        return CMultiShellModel.run(self, x)
136   
137    def runXY(self, x=0.0):
138        """
139        Evaluate the model in cartesian coordinates
140       
141        :param x: input q, or [qx, qy]
142       
143        :return: scattering function P(q)
144       
145        """
146        return CMultiShellModel.runXY(self, x)
147       
148    def evalDistribution(self, x):
149        """
150        Evaluate the model in cartesian coordinates
151       
152        :param x: input q[], or [qx[], qy[]]
153       
154        :return: scattering function P(q[])
155       
156        """
157        return CMultiShellModel.evalDistribution(self, x)
158       
159    def calculate_ER(self):
160        """
161        Calculate the effective radius for P(q)*S(q)
162       
163        :return: the value of the effective radius
164       
165        """       
166        return CMultiShellModel.calculate_ER(self)
167       
168    def calculate_VR(self):
169        """
170        Calculate the volf ratio for P(q)*S(q)
171       
172        :return: the value of the volf ratio
173       
174        """       
175        return CMultiShellModel.calculate_VR(self)
176             
177    def set_dispersion(self, parameter, dispersion):
178        """
179        Set the dispersion object for a model parameter
180       
181        :param parameter: name of the parameter [string]
182        :param dispersion: dispersion object of type DispersionModel
183       
184        """
185        return CMultiShellModel.set_dispersion(self,
186               parameter, dispersion.cdisp)
187       
188   
189# End of file
190
Note: See TracBrowser for help on using the repository browser.