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\spheroid.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 CCoreShellEllipsoidModel |
---|
29 | import copy |
---|
30 | |
---|
31 | class CoreShellEllipsoidModel(CCoreShellEllipsoidModel, BaseComponent): |
---|
32 | """ |
---|
33 | Class that evaluates a CoreShellEllipsoidModel model. |
---|
34 | This file was auto-generated from ..\c_extensions\spheroid.h. |
---|
35 | Refer to that file and the structure it contains |
---|
36 | for details of the model. |
---|
37 | List of default parameters: |
---|
38 | scale = 1.0 |
---|
39 | equat_core = 200.0 [A] |
---|
40 | polar_core = 20.0 [A] |
---|
41 | equat_shell = 250.0 [A] |
---|
42 | polar_shell = 30.0 [A] |
---|
43 | sld_core = 2e-006 [1/A^(2)] |
---|
44 | sld_shell = 1e-006 [1/A^(2)] |
---|
45 | sld_solvent = 6.3e-006 [1/A^(2)] |
---|
46 | background = 0.001 [1/cm] |
---|
47 | axis_theta = 0.0 [deg] |
---|
48 | axis_phi = 0.0 [deg] |
---|
49 | |
---|
50 | """ |
---|
51 | |
---|
52 | def __init__(self): |
---|
53 | """ Initialization """ |
---|
54 | |
---|
55 | # Initialize BaseComponent first, then sphere |
---|
56 | BaseComponent.__init__(self) |
---|
57 | CCoreShellEllipsoidModel.__init__(self) |
---|
58 | |
---|
59 | ## Name of the model |
---|
60 | self.name = "CoreShellEllipsoidModel" |
---|
61 | ## Model description |
---|
62 | self.description ="""[SpheroidCoreShellModel] Calculates the form factor for an spheroid |
---|
63 | ellipsoid particle with a core_shell structure. |
---|
64 | The form factor is averaged over all possible |
---|
65 | orientations of the ellipsoid such that P(q) |
---|
66 | = scale*<f^2>/Vol + bkg, where f is the |
---|
67 | single particle scattering amplitude. |
---|
68 | [Parameters]: |
---|
69 | equat_core = equatorial radius of core, |
---|
70 | polar_core = polar radius of core, |
---|
71 | equat_shell = equatorial radius of shell, |
---|
72 | polar_shell = polar radius (revolution axis) of shell, |
---|
73 | sld_core = SLD_core |
---|
74 | sld_shell = SLD_shell |
---|
75 | sld_solvent = SLD_solvent |
---|
76 | background = Incoherent bkg |
---|
77 | scale =scale |
---|
78 | Note:It is the users' responsibility to ensure |
---|
79 | that shell radii are larger than core radii. |
---|
80 | oblate: polar radius < equatorial radius |
---|
81 | prolate : polar radius > equatorial radius""" |
---|
82 | |
---|
83 | ## Parameter details [units, min, max] |
---|
84 | self.details = {} |
---|
85 | self.details['scale'] = ['', None, None] |
---|
86 | self.details['equat_core'] = ['[A]', None, None] |
---|
87 | self.details['polar_core'] = ['[A]', None, None] |
---|
88 | self.details['equat_shell'] = ['[A]', None, None] |
---|
89 | self.details['polar_shell'] = ['[A]', None, None] |
---|
90 | self.details['sld_core'] = ['[1/A^(2)]', None, None] |
---|
91 | self.details['sld_shell'] = ['[1/A^(2)]', None, None] |
---|
92 | self.details['sld_solvent'] = ['[1/A^(2)]', None, None] |
---|
93 | self.details['background'] = ['[1/cm]', None, None] |
---|
94 | self.details['axis_theta'] = ['[deg]', None, None] |
---|
95 | self.details['axis_phi'] = ['[deg]', None, None] |
---|
96 | |
---|
97 | ## fittable parameters |
---|
98 | self.fixed=['equat_core.width', 'polar_core.width', 'equat_shell.width', 'polar_shell.width', 'axis_phi.width', 'axis_theta.width'] |
---|
99 | |
---|
100 | ## non-fittable parameters |
---|
101 | self.non_fittable=[] |
---|
102 | |
---|
103 | ## parameters with orientation |
---|
104 | self.orientation_params =['axis_phi', 'axis_theta', 'axis_phi.width', 'axis_theta.width'] |
---|
105 | |
---|
106 | def clone(self): |
---|
107 | """ Return a identical copy of self """ |
---|
108 | return self._clone(CoreShellEllipsoidModel()) |
---|
109 | |
---|
110 | def __getstate__(self): |
---|
111 | """ |
---|
112 | return object state for pickling and copying |
---|
113 | """ |
---|
114 | model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log} |
---|
115 | |
---|
116 | return self.__dict__, model_state |
---|
117 | |
---|
118 | def __setstate__(self, state): |
---|
119 | """ |
---|
120 | create object from pickled state |
---|
121 | |
---|
122 | :param state: the state of the current model |
---|
123 | |
---|
124 | """ |
---|
125 | |
---|
126 | self.__dict__, model_state = state |
---|
127 | self.params = model_state['params'] |
---|
128 | self.dispersion = model_state['dispersion'] |
---|
129 | self.log = model_state['log'] |
---|
130 | |
---|
131 | |
---|
132 | def run(self, x=0.0): |
---|
133 | """ |
---|
134 | Evaluate the model |
---|
135 | |
---|
136 | :param x: input q, or [q,phi] |
---|
137 | |
---|
138 | :return: scattering function P(q) |
---|
139 | |
---|
140 | """ |
---|
141 | |
---|
142 | return CCoreShellEllipsoidModel.run(self, x) |
---|
143 | |
---|
144 | def runXY(self, x=0.0): |
---|
145 | """ |
---|
146 | Evaluate the model in cartesian coordinates |
---|
147 | |
---|
148 | :param x: input q, or [qx, qy] |
---|
149 | |
---|
150 | :return: scattering function P(q) |
---|
151 | |
---|
152 | """ |
---|
153 | |
---|
154 | return CCoreShellEllipsoidModel.runXY(self, x) |
---|
155 | |
---|
156 | def evalDistribution(self, x=[]): |
---|
157 | """ |
---|
158 | Evaluate the model in cartesian coordinates |
---|
159 | |
---|
160 | :param x: input q[], or [qx[], qy[]] |
---|
161 | |
---|
162 | :return: scattering function P(q[]) |
---|
163 | |
---|
164 | """ |
---|
165 | return CCoreShellEllipsoidModel.evalDistribution(self, x) |
---|
166 | |
---|
167 | def calculate_ER(self): |
---|
168 | """ |
---|
169 | Calculate the effective radius for P(q)*S(q) |
---|
170 | |
---|
171 | :return: the value of the effective radius |
---|
172 | |
---|
173 | """ |
---|
174 | return CCoreShellEllipsoidModel.calculate_ER(self) |
---|
175 | |
---|
176 | def set_dispersion(self, parameter, dispersion): |
---|
177 | """ |
---|
178 | Set the dispersion object for a model parameter |
---|
179 | |
---|
180 | :param parameter: name of the parameter [string] |
---|
181 | :param dispersion: dispersion object of type DispersionModel |
---|
182 | |
---|
183 | """ |
---|
184 | return CCoreShellEllipsoidModel.set_dispersion(self, parameter, dispersion.cdisp) |
---|
185 | |
---|
186 | |
---|
187 | # End of file |
---|