source: sasview/sansmodels/src/sans/models/CoreShellCylinderModel.py @ 18695bf

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 18695bf was 96656e3, checked in by Jae Cho <jhjcho@…>, 14 years ago

update models due to changes of template

  • Property mode set to 100644
File size: 6.1 KB
Line 
1#!/usr/bin/env python
2
3##############################################################################
4#       This software was developed by the University of Tennessee as part of the
5#       Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
6#       project funded by the US National Science Foundation.
7#
8#       If you use DANSE applications to do scientific research that leads to
9#       publication, we ask that you acknowledge the use of the software with the
10#       following sentence:
11#
12#       "This work benefited from DANSE software developed under NSF award DMR-0520547."
13#
14#       copyright 2008, University of Tennessee
15##############################################################################
16
17
18"""
19Provide functionality for a C extension model
20
21:WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
22         DO NOT MODIFY THIS FILE, MODIFY ..\c_extensions\core_shell_cylinder.h
23         AND RE-RUN THE GENERATOR SCRIPT
24
25"""
26
27from sans.models.BaseComponent import BaseComponent
28from sans_extension.c_models import CCoreShellCylinderModel
29import copy   
30
31def create_CoreShellCylinderModel():
32    obj = CoreShellCylinderModel()
33    #CCoreShellCylinderModel.__init__(obj) is called by CoreShellCylinderModel constructor
34    return obj
35
36class CoreShellCylinderModel(CCoreShellCylinderModel, BaseComponent):
37    """
38    Class that evaluates a CoreShellCylinderModel model.
39    This file was auto-generated from ..\c_extensions\core_shell_cylinder.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         radius          = 20.0 [A]
45         thickness       = 10.0 [A]
46         length          = 400.0 [A]
47         core_sld        = 1e-006 [1/A^(2)]
48         shell_sld       = 4e-006 [1/A^(2)]
49         solvent_sld     = 1e-006 [1/A^(2)]
50         background      = 0.0 [1/cm]
51         axis_theta      = 90.0 [deg]
52         axis_phi        = 0.0 [deg]
53
54    """
55       
56    def __init__(self):
57        """ Initialization """
58       
59        # Initialize BaseComponent first, then sphere
60        BaseComponent.__init__(self)
61        #apply(CCoreShellCylinderModel.__init__, (self,))
62        CCoreShellCylinderModel.__init__(self)
63       
64        ## Name of the model
65        self.name = "CoreShellCylinderModel"
66        ## Model description
67        self.description ="""P(q,alpha)= scale/Vs*f(q)^(2) + bkg,  where: f(q)= 2(core_sld
68                - solvant_sld)* Vc*sin[qLcos(alpha/2)]
69                /[qLcos(alpha/2)]*J1(qRsin(alpha))
70                /[qRsin(alpha)]+2(shell_sld-solvent_sld)
71                *Vs*sin[q(L+T)cos(alpha/2)][[q(L+T)
72                *cos(alpha/2)]*J1(q(R+T)sin(alpha))
73                /q(R+T)sin(alpha)]
74               
75                alpha:is the angle between the axis of
76                the cylinder and the q-vector
77                Vs: the volume of the outer shell
78                Vc: the volume of the core
79                L: the length of the core
80                shell_sld: the scattering length density
81                of the shell
82                solvent_sld: the scattering length density
83                of the solvent
84                bkg: the background
85                T: the thickness
86                R+T: is the outer radius
87                L+2T: The total length of the outershell
88                J1: the first order Bessel function
89                theta: axis_theta of the cylinder
90                phi: the axis_phi of the cylinder..."""
91       
92        ## Parameter details [units, min, max]
93        self.details = {}
94        self.details['scale'] = ['', None, None]
95        self.details['radius'] = ['[A]', None, None]
96        self.details['thickness'] = ['[A]', None, None]
97        self.details['length'] = ['[A]', None, None]
98        self.details['core_sld'] = ['[1/A^(2)]', None, None]
99        self.details['shell_sld'] = ['[1/A^(2)]', None, None]
100        self.details['solvent_sld'] = ['[1/A^(2)]', None, None]
101        self.details['background'] = ['[1/cm]', None, None]
102        self.details['axis_theta'] = ['[deg]', None, None]
103        self.details['axis_phi'] = ['[deg]', None, None]
104
105        ## fittable parameters
106        self.fixed=['axis_phi.width', 'axis_theta.width', 'length.width', 'radius.width', 'thickness.width']
107       
108        ## non-fittable parameters
109        self.non_fittable = []
110       
111        ## parameters with orientation
112        self.orientation_params = ['axis_phi', 'axis_theta', 'axis_phi.width', 'axis_theta.width']
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        return (create_CoreShellCylinderModel,tuple())
120       
121    def clone(self):
122        """ Return a identical copy of self """
123        return self._clone(CoreShellCylinderModel())   
124       
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       
136        return CCoreShellCylinderModel.run(self, x)
137   
138    def runXY(self, x=0.0):
139        """
140        Evaluate the model in cartesian coordinates
141       
142        :param x: input q, or [qx, qy]
143       
144        :return: scattering function P(q)
145       
146        """
147       
148        return CCoreShellCylinderModel.runXY(self, x)
149       
150    def evalDistribution(self, x=[]):
151        """
152        Evaluate the model in cartesian coordinates
153       
154        :param x: input q[], or [qx[], qy[]]
155       
156        :return: scattering function P(q[])
157       
158        """
159        return CCoreShellCylinderModel.evalDistribution(self, x)
160       
161    def calculate_ER(self):
162        """
163        Calculate the effective radius for P(q)*S(q)
164       
165        :return: the value of the effective radius
166       
167        """       
168        return CCoreShellCylinderModel.calculate_ER(self)
169       
170    def set_dispersion(self, parameter, dispersion):
171        """
172        Set the dispersion object for a model parameter
173       
174        :param parameter: name of the parameter [string]
175        :param dispersion: dispersion object of type DispersionModel
176       
177        """
178        return CCoreShellCylinderModel.set_dispersion(self, parameter, dispersion.cdisp)
179       
180   
181# End of file
Note: See TracBrowser for help on using the repository browser.