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 | """ |
---|
19 | Provide 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 | |
---|
27 | from sans.models.BaseComponent import BaseComponent |
---|
28 | from sans_extension.c_models import CCoreShellCylinderModel |
---|
29 | import copy |
---|
30 | |
---|
31 | def create_CoreShellCylinderModel(): |
---|
32 | obj = CoreShellCylinderModel() |
---|
33 | #CCoreShellCylinderModel.__init__(obj) is called by CoreShellCylinderModel constructor |
---|
34 | return obj |
---|
35 | |
---|
36 | class 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 __setstate__(self, state): |
---|
115 | """ |
---|
116 | restore the state of a model from pickle |
---|
117 | """ |
---|
118 | self.__dict__, self.params, self.dispersion = state |
---|
119 | |
---|
120 | def __reduce_ex__(self, proto): |
---|
121 | """ |
---|
122 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
123 | c model. |
---|
124 | """ |
---|
125 | state = (self.__dict__, self.params, self.dispersion) |
---|
126 | return (create_CoreShellCylinderModel,tuple(), state, None, None) |
---|
127 | |
---|
128 | def clone(self): |
---|
129 | """ Return a identical copy of self """ |
---|
130 | return self._clone(CoreShellCylinderModel()) |
---|
131 | |
---|
132 | |
---|
133 | def run(self, x=0.0): |
---|
134 | """ |
---|
135 | Evaluate the model |
---|
136 | |
---|
137 | :param x: input q, or [q,phi] |
---|
138 | |
---|
139 | :return: scattering function P(q) |
---|
140 | |
---|
141 | """ |
---|
142 | |
---|
143 | return CCoreShellCylinderModel.run(self, x) |
---|
144 | |
---|
145 | def runXY(self, x=0.0): |
---|
146 | """ |
---|
147 | Evaluate the model in cartesian coordinates |
---|
148 | |
---|
149 | :param x: input q, or [qx, qy] |
---|
150 | |
---|
151 | :return: scattering function P(q) |
---|
152 | |
---|
153 | """ |
---|
154 | |
---|
155 | return CCoreShellCylinderModel.runXY(self, x) |
---|
156 | |
---|
157 | def evalDistribution(self, x=[]): |
---|
158 | """ |
---|
159 | Evaluate the model in cartesian coordinates |
---|
160 | |
---|
161 | :param x: input q[], or [qx[], qy[]] |
---|
162 | |
---|
163 | :return: scattering function P(q[]) |
---|
164 | |
---|
165 | """ |
---|
166 | return CCoreShellCylinderModel.evalDistribution(self, x) |
---|
167 | |
---|
168 | def calculate_ER(self): |
---|
169 | """ |
---|
170 | Calculate the effective radius for P(q)*S(q) |
---|
171 | |
---|
172 | :return: the value of the effective radius |
---|
173 | |
---|
174 | """ |
---|
175 | return CCoreShellCylinderModel.calculate_ER(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 CCoreShellCylinderModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
186 | |
---|
187 | |
---|
188 | # End of file |
---|