source: sasview/src/sans/models/CoreShellBicelleModel.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: 7.3 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\core_shell_bicelle.h
21         AND RE-RUN THE GENERATOR SCRIPT
22"""
23
24from sans.models.BaseComponent import BaseComponent
25from sans.models.sans_extension.c_models import CCoreShellBicelleModel
26
27def create_CoreShellBicelleModel():
28    """
29       Create a model instance
30    """
31    obj = CoreShellBicelleModel()
32    # CCoreShellBicelleModel.__init__(obj) is called by
33    # the CoreShellBicelleModel constructor
34    return obj
35
36class CoreShellBicelleModel(CCoreShellBicelleModel, BaseComponent):
37    """
38    Class that evaluates a CoreShellBicelleModel model.
39    This file was auto-generated from src\sans\models\include\core_shell_bicelle.h.
40    Refer to that file and the structure it contains
41    for details of the model.
42    List of default parameters:
43         radius          = 20.0 [A]
44         scale           = 1.0
45         rim_thick       = 10.0 [A]
46         face_thick      = 10.0 [A]
47         length          = 400.0 [A]
48         core_sld        = 1e-06 [1/A^(2)]
49         face_sld        = 4e-06 [1/A^(2)]
50         rim_sld         = 4e-06 [1/A^(2)]
51         solvent_sld     = 1e-06 [1/A^(2)]
52         background      = 0.0 [1/cm]
53         axis_theta      = 90.0 [deg]
54         axis_phi        = 0.0 [deg]
55
56    """
57       
58    def __init__(self, multfactor=1):
59        """ Initialization """
60        self.__dict__ = {}
61       
62        # Initialize BaseComponent first, then sphere
63        BaseComponent.__init__(self)
64        #apply(CCoreShellBicelleModel.__init__, (self,))
65
66        CCoreShellBicelleModel.__init__(self)
67        self.is_multifunc = False
68                       
69        ## Name of the model
70        self.name = "CoreShellBicelleModel"
71        ## Model description
72        self.description = """
73        P(q,alpha)= scale/Vs*f(q)^(2) + bkg,  where: f(q)= 2(core_sld
74                - solvant_sld)* Vc*sin[qLcos(alpha/2)]
75                /[qLcos(alpha/2)]*J1(qRsin(alpha))
76                /[qRsin(alpha)]+2(shell_sld-solvent_sld)
77                *Vs*sin[q(L+T)cos(alpha/2)][[q(L+T)
78                *cos(alpha/2)]*J1(q(R+T)sin(alpha))
79                /q(R+T)sin(alpha)]
80               
81                alpha:is the angle between the axis of
82                the cylinder and the q-vector
83                Vs: the volume of the outer shell
84                Vc: the volume of the core
85                L: the length of the core
86                shell_sld: the scattering length density
87                of the shell
88                solvent_sld: the scattering length density
89                of the solvent
90                bkg: the background
91                T: the thickness
92                R+T: is the outer radius
93                L+2T: The total length of the outershell
94                J1: the first order Bessel function
95                theta: axis_theta of the cylinder
96                phi: the axis_phi of the cylinder...
97        """
98       
99        ## Parameter details [units, min, max]
100        self.details = {}
101        self.details['radius'] = ['[A]', None, None]
102        self.details['scale'] = ['', None, None]
103        self.details['rim_thick'] = ['[A]', None, None]
104        self.details['face_thick'] = ['[A]', None, None]
105        self.details['length'] = ['[A]', None, None]
106        self.details['core_sld'] = ['[1/A^(2)]', None, None]
107        self.details['face_sld'] = ['[1/A^(2)]', None, None]
108        self.details['rim_sld'] = ['[1/A^(2)]', None, None]
109        self.details['solvent_sld'] = ['[1/A^(2)]', None, None]
110        self.details['background'] = ['[1/cm]', None, None]
111        self.details['axis_theta'] = ['[deg]', None, None]
112        self.details['axis_phi'] = ['[deg]', None, None]
113
114        ## fittable parameters
115        self.fixed = ['axis_phi.width',
116                      'axis_theta.width',
117                      'length.width',
118                      'radius.width',
119                      'rim_thick.width',
120                      'face_thick.width']
121       
122        ## non-fittable parameters
123        self.non_fittable = []
124       
125        ## parameters with orientation
126        self.orientation_params = ['axis_phi',
127                                   'axis_theta',
128                                   'axis_phi.width',
129                                   'axis_theta.width']
130
131        ## parameters with magnetism
132        self.magnetic_params = []
133
134        self.category = None
135        self.multiplicity_info = None
136       
137    def __setstate__(self, state):
138        """
139        restore the state of a model from pickle
140        """
141        self.__dict__, self.params, self.dispersion = state
142       
143    def __reduce_ex__(self, proto):
144        """
145        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
146        c model.
147        """
148        state = (self.__dict__, self.params, self.dispersion)
149        return (create_CoreShellBicelleModel, tuple(), state, None, None)
150       
151    def clone(self):
152        """ Return a identical copy of self """
153        return self._clone(CoreShellBicelleModel())   
154       
155    def run(self, x=0.0):
156        """
157        Evaluate the model
158       
159        :param x: input q, or [q,phi]
160       
161        :return: scattering function P(q)
162       
163        """
164        return CCoreShellBicelleModel.run(self, x)
165   
166    def runXY(self, x=0.0):
167        """
168        Evaluate the model in cartesian coordinates
169       
170        :param x: input q, or [qx, qy]
171       
172        :return: scattering function P(q)
173       
174        """
175        return CCoreShellBicelleModel.runXY(self, x)
176       
177    def evalDistribution(self, x):
178        """
179        Evaluate the model in cartesian coordinates
180       
181        :param x: input q[], or [qx[], qy[]]
182       
183        :return: scattering function P(q[])
184       
185        """
186        return CCoreShellBicelleModel.evalDistribution(self, x)
187       
188    def calculate_ER(self):
189        """
190        Calculate the effective radius for P(q)*S(q)
191       
192        :return: the value of the effective radius
193       
194        """       
195        return CCoreShellBicelleModel.calculate_ER(self)
196       
197    def calculate_VR(self):
198        """
199        Calculate the volf ratio for P(q)*S(q)
200       
201        :return: the value of the volf ratio
202       
203        """       
204        return CCoreShellBicelleModel.calculate_VR(self)
205             
206    def set_dispersion(self, parameter, dispersion):
207        """
208        Set the dispersion object for a model parameter
209       
210        :param parameter: name of the parameter [string]
211        :param dispersion: dispersion object of type DispersionModel
212       
213        """
214        return CCoreShellBicelleModel.set_dispersion(self,
215               parameter, dispersion.cdisp)
216       
217   
218# End of file
219
Note: See TracBrowser for help on using the repository browser.