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 | """ |
---|
16 | Provide 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\sc.h |
---|
21 | AND RE-RUN THE GENERATOR SCRIPT |
---|
22 | """ |
---|
23 | |
---|
24 | from sans.models.BaseComponent import BaseComponent |
---|
25 | from sans.models.sans_extension.c_models import CSCCrystalModel |
---|
26 | |
---|
27 | def create_SCCrystalModel(): |
---|
28 | """ |
---|
29 | Create a model instance |
---|
30 | """ |
---|
31 | obj = SCCrystalModel() |
---|
32 | # CSCCrystalModel.__init__(obj) is called by |
---|
33 | # the SCCrystalModel constructor |
---|
34 | return obj |
---|
35 | |
---|
36 | class SCCrystalModel(CSCCrystalModel, BaseComponent): |
---|
37 | """ |
---|
38 | Class that evaluates a SCCrystalModel model. |
---|
39 | This file was auto-generated from src\sans\models\include\sc.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 | dnn = 220.0 [A] |
---|
45 | d_factor = 0.06 |
---|
46 | radius = 40.0 [A] |
---|
47 | sldSph = 3e-06 [1/A^(2)] |
---|
48 | sldSolv = 6.3e-06 [1/A^(2)] |
---|
49 | background = 0.0 [1/cm] |
---|
50 | theta = 0.0 [deg] |
---|
51 | phi = 0.0 [deg] |
---|
52 | psi = 0.0 [deg] |
---|
53 | |
---|
54 | """ |
---|
55 | |
---|
56 | def __init__(self, multfactor=1): |
---|
57 | """ Initialization """ |
---|
58 | self.__dict__ = {} |
---|
59 | |
---|
60 | # Initialize BaseComponent first, then sphere |
---|
61 | BaseComponent.__init__(self) |
---|
62 | #apply(CSCCrystalModel.__init__, (self,)) |
---|
63 | |
---|
64 | CSCCrystalModel.__init__(self) |
---|
65 | self.is_multifunc = False |
---|
66 | |
---|
67 | ## Name of the model |
---|
68 | self.name = "SCCrystalModel" |
---|
69 | ## Model description |
---|
70 | self.description = """ |
---|
71 | P(q)=(scale/Vp)*V_lattice*P(q)*Z(q)+bkg where scale is the volume |
---|
72 | fraction of sphere, |
---|
73 | Vp = volume of the primary particle, |
---|
74 | V_lattice = volume correction for |
---|
75 | for the crystal structure, |
---|
76 | P(q)= form factor of the sphere (normalized), |
---|
77 | Z(q)= paracrystalline structure factor |
---|
78 | for a simple cubic structure. |
---|
79 | [Simple Cubic ParaCrystal Model] |
---|
80 | Parameters; |
---|
81 | scale: volume fraction of spheres |
---|
82 | bkg:background, R: radius of sphere |
---|
83 | dnn: Nearest neighbor distance |
---|
84 | d_factor: Paracrystal distortion factor |
---|
85 | radius: radius of the spheres |
---|
86 | sldSph: SLD of the sphere |
---|
87 | sldSolv: SLD of the solvent |
---|
88 | |
---|
89 | """ |
---|
90 | |
---|
91 | ## Parameter details [units, min, max] |
---|
92 | self.details = {} |
---|
93 | self.details['scale'] = ['', None, None] |
---|
94 | self.details['dnn'] = ['[A]', None, None] |
---|
95 | self.details['d_factor'] = ['', None, None] |
---|
96 | self.details['radius'] = ['[A]', None, None] |
---|
97 | self.details['sldSph'] = ['[1/A^(2)]', None, None] |
---|
98 | self.details['sldSolv'] = ['[1/A^(2)]', None, None] |
---|
99 | self.details['background'] = ['[1/cm]', None, None] |
---|
100 | self.details['theta'] = ['[deg]', None, None] |
---|
101 | self.details['phi'] = ['[deg]', None, None] |
---|
102 | self.details['psi'] = ['[deg]', None, None] |
---|
103 | |
---|
104 | ## fittable parameters |
---|
105 | self.fixed = ['radius.width', |
---|
106 | 'phi.width', |
---|
107 | 'psi.width', |
---|
108 | 'theta.width'] |
---|
109 | |
---|
110 | ## non-fittable parameters |
---|
111 | self.non_fittable = [] |
---|
112 | |
---|
113 | ## parameters with orientation |
---|
114 | self.orientation_params = ['phi', |
---|
115 | 'psi', |
---|
116 | 'theta', |
---|
117 | 'phi.width', |
---|
118 | 'psi.width', |
---|
119 | 'theta.width'] |
---|
120 | |
---|
121 | ## parameters with magnetism |
---|
122 | self.magnetic_params = [] |
---|
123 | |
---|
124 | self.category = None |
---|
125 | self.multiplicity_info = None |
---|
126 | |
---|
127 | def __setstate__(self, state): |
---|
128 | """ |
---|
129 | restore the state of a model from pickle |
---|
130 | """ |
---|
131 | self.__dict__, self.params, self.dispersion = state |
---|
132 | |
---|
133 | def __reduce_ex__(self, proto): |
---|
134 | """ |
---|
135 | Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of |
---|
136 | c model. |
---|
137 | """ |
---|
138 | state = (self.__dict__, self.params, self.dispersion) |
---|
139 | return (create_SCCrystalModel, tuple(), state, None, None) |
---|
140 | |
---|
141 | def clone(self): |
---|
142 | """ Return a identical copy of self """ |
---|
143 | return self._clone(SCCrystalModel()) |
---|
144 | |
---|
145 | def run(self, x=0.0): |
---|
146 | """ |
---|
147 | Evaluate the model |
---|
148 | |
---|
149 | :param x: input q, or [q,phi] |
---|
150 | |
---|
151 | :return: scattering function P(q) |
---|
152 | |
---|
153 | """ |
---|
154 | return CSCCrystalModel.run(self, x) |
---|
155 | |
---|
156 | def runXY(self, x=0.0): |
---|
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 CSCCrystalModel.runXY(self, x) |
---|
166 | |
---|
167 | def evalDistribution(self, x): |
---|
168 | """ |
---|
169 | Evaluate the model in cartesian coordinates |
---|
170 | |
---|
171 | :param x: input q[], or [qx[], qy[]] |
---|
172 | |
---|
173 | :return: scattering function P(q[]) |
---|
174 | |
---|
175 | """ |
---|
176 | return CSCCrystalModel.evalDistribution(self, x) |
---|
177 | |
---|
178 | def calculate_ER(self): |
---|
179 | """ |
---|
180 | Calculate the effective radius for P(q)*S(q) |
---|
181 | |
---|
182 | :return: the value of the effective radius |
---|
183 | |
---|
184 | """ |
---|
185 | return CSCCrystalModel.calculate_ER(self) |
---|
186 | |
---|
187 | def calculate_VR(self): |
---|
188 | """ |
---|
189 | Calculate the volf ratio for P(q)*S(q) |
---|
190 | |
---|
191 | :return: the value of the volf ratio |
---|
192 | |
---|
193 | """ |
---|
194 | return CSCCrystalModel.calculate_VR(self) |
---|
195 | |
---|
196 | def set_dispersion(self, parameter, dispersion): |
---|
197 | """ |
---|
198 | Set the dispersion object for a model parameter |
---|
199 | |
---|
200 | :param parameter: name of the parameter [string] |
---|
201 | :param dispersion: dispersion object of type DispersionModel |
---|
202 | |
---|
203 | """ |
---|
204 | return CSCCrystalModel.set_dispersion(self, |
---|
205 | parameter, dispersion.cdisp) |
---|
206 | |
---|
207 | |
---|
208 | # End of file |
---|
209 | |
---|