1 | """ |
---|
2 | Unit tests for specific models. |
---|
3 | @since: 08/25/2009 |
---|
4 | @note: The models are running also with numpy array as input. |
---|
5 | Some models return limit of the function at critical point . |
---|
6 | So the user should expect finite value for some critical points. |
---|
7 | Only critical q=0 will be tested. |
---|
8 | |
---|
9 | Critical points tests that fail. the user is responsible of changing |
---|
10 | the model tested or document the failure. |
---|
11 | |
---|
12 | Initial values for models are given as the one of Igo software. |
---|
13 | @author: Gervaise Alina / UTK |
---|
14 | @summary: Run by G. Alina 10/21/2009 |
---|
15 | Most of the lamellar tests are not passing. Check lamellar im |
---|
16 | plementation. |
---|
17 | critial points tested not passing for: |
---|
18 | - Flexible Cylinder |
---|
19 | - PeakLorenzt |
---|
20 | - Squarewell Structure |
---|
21 | - StickyHstructure |
---|
22 | - hardSphereStructure |
---|
23 | |
---|
24 | @ Note: We don't use matrix for 2D anymore so testEval2D can be ignored (JC) |
---|
25 | |
---|
26 | """ |
---|
27 | |
---|
28 | import unittest |
---|
29 | import numpy |
---|
30 | import math |
---|
31 | |
---|
32 | class TestCoreShell(unittest.TestCase): |
---|
33 | """ Unit tests for coreshell model """ |
---|
34 | |
---|
35 | def setUp(self): |
---|
36 | from sans.models.CoreShellModel import CoreShellModel |
---|
37 | self.comp = CoreShellModel() |
---|
38 | #Give initial value to model |
---|
39 | self.comp.setParam("scale", 1.0) |
---|
40 | self.comp.setParam("radius", 60.0) |
---|
41 | self.comp.setParam("thickness", 10.0) |
---|
42 | self.comp.setParam("core_sld", 1.0e-6) |
---|
43 | self.comp.setParam("shell_sld",2.0e-6) |
---|
44 | self.comp.setParam("solvent_sld",3.0e-6) |
---|
45 | self.comp.setParam("Background", 0.001) |
---|
46 | |
---|
47 | self.x = numpy.array([0.4, 1.3]) |
---|
48 | self.y = numpy.array([0.5, 1.57]) |
---|
49 | self.x_array = self.comp.evalDistribution(self.x) |
---|
50 | self.y_array = self.comp.evalDistribution(self.y) |
---|
51 | |
---|
52 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
53 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
54 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
55 | |
---|
56 | def test1D(self): |
---|
57 | """ Test 1D model for a coreshell """ |
---|
58 | self.assertAlmostEquals(self.comp.run(0.4),0.00169, 4) |
---|
59 | |
---|
60 | def test1D_2(self): |
---|
61 | """ Test 2D model for a coreshell """ |
---|
62 | self.assertAlmostEquals(self.comp.run([0.4, 1.3]),0.00169, 4) |
---|
63 | |
---|
64 | def testEval_1D(self): |
---|
65 | """ Test 1D model for a coreshell with evalDistribution""" |
---|
66 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
67 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
68 | |
---|
69 | def testEval_2D(self): |
---|
70 | """ Test 2D model for a coreshell with evalDistribution""" |
---|
71 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
72 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
73 | |
---|
74 | # No more singular point |
---|
75 | #def testCriticalPoint(self): |
---|
76 | # """ Test coreshell at the critical point""" |
---|
77 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
78 | |
---|
79 | class TestMultiShellModel(unittest.TestCase): |
---|
80 | """ Unit tests for MultiShell Model """ |
---|
81 | |
---|
82 | def setUp(self): |
---|
83 | from sans.models.MultiShellModel import MultiShellModel |
---|
84 | self.comp = MultiShellModel() |
---|
85 | #Give initial value to model |
---|
86 | self.comp.setParam("scale", 1.0) |
---|
87 | self.comp.setParam("core_radius", 60.0) |
---|
88 | self.comp.setParam("s_thickness", 10.0) |
---|
89 | self.comp.setParam("w_thickness",10.0 ) |
---|
90 | self.comp.setParam("core_sld",6.4e-6) |
---|
91 | self.comp.setParam("shell_sld",4e-7) |
---|
92 | self.comp.setParam("n_pairs", 2) |
---|
93 | self.comp.setParam("Background", 0.001) |
---|
94 | |
---|
95 | self.x = numpy.array([0.4, 1.3]) |
---|
96 | self.y = numpy.array([0.5, 1.57]) |
---|
97 | self.x_array = self.comp.evalDistribution(self.x) |
---|
98 | self.y_array = self.comp.evalDistribution(self.y) |
---|
99 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
100 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
101 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
102 | |
---|
103 | def test1D(self): |
---|
104 | """ Test 1D model for a MultiShell Model """ |
---|
105 | self.assertAlmostEquals(self.comp.run(0.001), 2442.81, 2) |
---|
106 | |
---|
107 | def test1D_2(self): |
---|
108 | """ Test 2D model for a MultiShell Model""" |
---|
109 | self.assertAlmostEquals(self.comp.run([0.001, 0.30903]), 2442.81, 2) |
---|
110 | |
---|
111 | def testEval_1D(self): |
---|
112 | """ Test 1D model for a MultiShell with evalDistribution""" |
---|
113 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
114 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
115 | |
---|
116 | def testEval_2D(self): |
---|
117 | """ Test 2D model for a MultiShell with evalDistribution""" |
---|
118 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
119 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
120 | |
---|
121 | # No more singular point |
---|
122 | #def testCriticalPoint(self): |
---|
123 | # """ Test multishell at the critical point""" |
---|
124 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
125 | |
---|
126 | class TestVesicleModel(unittest.TestCase): |
---|
127 | """ Unit tests for Vesicle Model """ |
---|
128 | |
---|
129 | def setUp(self): |
---|
130 | from sans.models.VesicleModel import VesicleModel |
---|
131 | self.comp = VesicleModel() |
---|
132 | #Give initial value to model |
---|
133 | self.comp.setParam("scale", 1.0) |
---|
134 | self.comp.setParam("radius", 100.0) |
---|
135 | self.comp.setParam("core_sld", 6.36e-6) |
---|
136 | self.comp.setParam("shell_sld",5e-7) |
---|
137 | self.comp.setParam("thickness",30.0 ) |
---|
138 | self.comp.setParam("Background", 0.001) |
---|
139 | |
---|
140 | self.x = numpy.array([0.4, 1.3]) |
---|
141 | self.y = numpy.array([0.5, 1.57]) |
---|
142 | self.x_array = self.comp.evalDistribution(self.x) |
---|
143 | self.y_array = self.comp.evalDistribution(self.y) |
---|
144 | #qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
145 | #qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
146 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
147 | |
---|
148 | def test1D(self): |
---|
149 | """ Test 1D model for a Vesicle Model """ |
---|
150 | self.assertAlmostEquals(self.comp.run(0.001), 1.71399e4,1) |
---|
151 | |
---|
152 | def test1D_2(self): |
---|
153 | """ Test 2D model for a Vesicle Model""" |
---|
154 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]), 1.71399e4,1) |
---|
155 | |
---|
156 | def testEval_1D(self): |
---|
157 | """ Test 1D model for a Vesicle with evalDistribution""" |
---|
158 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
159 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
160 | |
---|
161 | def testEval_2D(self): |
---|
162 | """ Test 2D model for a Vesicle with evalDistribution""" |
---|
163 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
164 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
165 | |
---|
166 | |
---|
167 | def testCriticalPoint(self): |
---|
168 | """ Test vesicle at the critical point""" |
---|
169 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
170 | |
---|
171 | |
---|
172 | class TestBinaryHSModel(unittest.TestCase): |
---|
173 | """ Unit tests for BinaryHS Model""" |
---|
174 | |
---|
175 | def setUp(self): |
---|
176 | from sans.models.BinaryHSModel import BinaryHSModel |
---|
177 | self.comp = BinaryHSModel() |
---|
178 | #Give initial value to model |
---|
179 | self.comp.setParam("l_radius", 100.0) |
---|
180 | self.comp.setParam("ls_sld", 3.5e-6) |
---|
181 | self.comp.setParam("s_radius",25) |
---|
182 | self.comp.setParam("solvent_sld",6.36e-6 ) |
---|
183 | self.comp.setParam("ss_sld", 5e-7) |
---|
184 | self.comp.setParam("vol_frac_ss", 0.1) |
---|
185 | self.comp.setParam("vol_frac_ls", 0.2) |
---|
186 | self.comp.setParam("Background", 0.001) |
---|
187 | |
---|
188 | self.x = numpy.array([0.4, 1.3]) |
---|
189 | self.y = numpy.array([0.5, 1.57]) |
---|
190 | self.x_array = self.comp.evalDistribution(self.x) |
---|
191 | self.y_array = self.comp.evalDistribution(self.y) |
---|
192 | #qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
193 | #qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
194 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
195 | |
---|
196 | def test1D(self): |
---|
197 | """ Test 1D model for a BinaryHS Model""" |
---|
198 | self.assertAlmostEquals(self.comp.run(0.001),60.6785, 4) |
---|
199 | |
---|
200 | def test1D_2(self): |
---|
201 | """ Test 2D model for a BinaryHS Model""" |
---|
202 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),60.6785, 4) |
---|
203 | |
---|
204 | def testEval_1D(self): |
---|
205 | """ Test 1D model for a BinaryHS with evalDistribution""" |
---|
206 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
207 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
208 | |
---|
209 | def testEval_2D(self): |
---|
210 | """ Test 2D model for a BinaryHS with evalDistribution""" |
---|
211 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
212 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
213 | |
---|
214 | # No more singular point |
---|
215 | #def testCriticalPoint(self): |
---|
216 | # """ Test BinaryHS at the critical point""" |
---|
217 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
218 | |
---|
219 | |
---|
220 | class TestCoreShellCylinderModel(unittest.TestCase): |
---|
221 | """ Unit tests for CoreShellCylinder Model""" |
---|
222 | |
---|
223 | def setUp(self): |
---|
224 | from sans.models.CoreShellCylinderModel import CoreShellCylinderModel |
---|
225 | self.comp = CoreShellCylinderModel() |
---|
226 | #Give initial value to model |
---|
227 | self.comp.setParam("scale", 1.0) |
---|
228 | self.comp.setParam("core_sld", 1e-6) |
---|
229 | self.comp.setParam("length", 400) |
---|
230 | self.comp.setParam("radius",20) |
---|
231 | self.comp.setParam("solvent_sld",1e-6 ) |
---|
232 | self.comp.setParam("shell_sld", 4e-6) |
---|
233 | self.comp.setParam("thickness", 10.0) |
---|
234 | self.comp.setParam("Background", 0.01) |
---|
235 | |
---|
236 | self.x = numpy.array([0.4, 1.3]) |
---|
237 | self.y = numpy.array([0.5, 1.57]) |
---|
238 | self.x_array = self.comp.evalDistribution(self.x) |
---|
239 | self.y_array = self.comp.evalDistribution(self.y) |
---|
240 | |
---|
241 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
242 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
243 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
244 | |
---|
245 | self.q = 0.001 |
---|
246 | self.phi= math.pi/2 |
---|
247 | self.qx= self.q*math.cos(self.phi) |
---|
248 | self.qy= self.q*math.sin(self.phi) |
---|
249 | |
---|
250 | def test1D(self): |
---|
251 | """ Test 1D model for a CoreShellCylinder Model""" |
---|
252 | self.assertAlmostEqual(self.comp.run(0.001), 353.56,1) |
---|
253 | |
---|
254 | def test1D_2(self): |
---|
255 | """ Test 2D model for a CoreShellCylinder Model""" |
---|
256 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
257 | self.comp.runXY([self.qx, self.qy]),1) |
---|
258 | |
---|
259 | def testEval_1D(self): |
---|
260 | """ Test 1D model for a CoreShellCylinder with evalDistribution""" |
---|
261 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
262 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
263 | |
---|
264 | def testEval_2D(self): |
---|
265 | """ Test 2D model for a CoreShellCylinder with evalDistribution""" |
---|
266 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
267 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
268 | |
---|
269 | # No more singular point |
---|
270 | #def testCriticalPoint(self): |
---|
271 | # """ Test CoreShellCylinder at the critical point""" |
---|
272 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
273 | |
---|
274 | |
---|
275 | class TestHollowCylinderModel(unittest.TestCase): |
---|
276 | """ Unit tests for HollowCylinder Model""" |
---|
277 | |
---|
278 | def setUp(self): |
---|
279 | from sans.models.HollowCylinderModel import HollowCylinderModel |
---|
280 | self.comp = HollowCylinderModel() |
---|
281 | #Give initial value to model |
---|
282 | self.comp.setParam("scale", 1.0) |
---|
283 | self.comp.setParam("core_radius",20.0) |
---|
284 | self.comp.setParam("radius",30) |
---|
285 | self.comp.setParam("length", 400) |
---|
286 | self.comp.setParam("sldCyl",6.3e-6 ) |
---|
287 | self.comp.setParam("sldSolv",1e-6 ) |
---|
288 | self.comp.setParam("Background", 0.01) |
---|
289 | |
---|
290 | self.x = numpy.array([0.4, 1.3]) |
---|
291 | self.y = numpy.array([0.5, 1.57]) |
---|
292 | self.x_array = self.comp.evalDistribution(self.x) |
---|
293 | self.y_array = self.comp.evalDistribution(self.y) |
---|
294 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
295 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
296 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
297 | |
---|
298 | self.q = 0.001 |
---|
299 | self.phi= math.pi/2 |
---|
300 | self.qx= self.q*math.cos(self.phi) |
---|
301 | self.qy= self.q*math.sin(self.phi) |
---|
302 | |
---|
303 | def test1D(self): |
---|
304 | """ Test 1D model for a HollowCylinder Model""" |
---|
305 | self.assertAlmostEqual(self.comp.run(0.001), 1756.76, 1) |
---|
306 | |
---|
307 | def test1D_2(self): |
---|
308 | """ Test 2D model for a HollowCylinder Model""" |
---|
309 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
310 | self.comp.runXY([self.qx, self.qy]),1) |
---|
311 | |
---|
312 | def testEval_1D(self): |
---|
313 | """ Test 1D model for a HollowCylinder with evalDistribution""" |
---|
314 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
315 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
316 | |
---|
317 | def testEval_2D(self): |
---|
318 | """ Test 2D model for a HollowCylinder with evalDistribution""" |
---|
319 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
320 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
321 | |
---|
322 | # No more singular point |
---|
323 | #def testCriticalPoint(self): |
---|
324 | # """ Test HollowCylinder at the critical point""" |
---|
325 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
326 | |
---|
327 | |
---|
328 | class TestFlexibleCylinderModel(unittest.TestCase): |
---|
329 | """ Unit tests for FlexibleCylinder Model""" |
---|
330 | |
---|
331 | def setUp(self): |
---|
332 | from sans.models.FlexibleCylinderModel import FlexibleCylinderModel |
---|
333 | self.comp = FlexibleCylinderModel() |
---|
334 | #Give initial value to model |
---|
335 | self.comp.setParam("scale", 1.0) |
---|
336 | self.comp.setParam("sldSolv",6.3e-6 ) |
---|
337 | self.comp.setParam("sldCyl",1e-6 ) |
---|
338 | self.comp.setParam("kuhn_length",100) |
---|
339 | self.comp.setParam("length", 1000) |
---|
340 | self.comp.setParam("radius",20) |
---|
341 | self.comp.setParam("Background", 0.0001) |
---|
342 | |
---|
343 | self.x = numpy.array([0.4, 1.3]) |
---|
344 | self.y = numpy.array([0.5, 1.57]) |
---|
345 | self.x_array = self.comp.evalDistribution(self.x) |
---|
346 | self.y_array = self.comp.evalDistribution(self.y) |
---|
347 | |
---|
348 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
349 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
350 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
351 | |
---|
352 | self.q = 0.001 |
---|
353 | self.phi= math.pi/2 |
---|
354 | self.qx= self.q*math.cos(self.phi) |
---|
355 | self.qy= self.q*math.sin(self.phi) |
---|
356 | |
---|
357 | def test1D(self): |
---|
358 | """ Test 1D model for a FlexibleCylinder Model""" |
---|
359 | self.assertAlmostEqual(self.comp.run(0.001), 3509.22, 1) |
---|
360 | |
---|
361 | def test1D_2(self): |
---|
362 | """ Test 2D model for a FlexibleCylinder Model""" |
---|
363 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
364 | self.comp.runXY([self.qx, self.qy]),1) |
---|
365 | def testEval_1D(self): |
---|
366 | """ Test 1D model for a FlexibleCylinder Model with evalDistribution""" |
---|
367 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
368 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
369 | |
---|
370 | def testEval_2D(self): |
---|
371 | """ Test 2D model for a FlexibleCylinder Model with evalDistribution""" |
---|
372 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
373 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
374 | |
---|
375 | # No more singular point |
---|
376 | #def testCriticalPoint(self): |
---|
377 | # """ Test FlexibleCylinder at the critical point""" |
---|
378 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
379 | |
---|
380 | class TestFlexCylEllipXModel(unittest.TestCase): |
---|
381 | """ Unit tests for FlexCylEllipXModel""" |
---|
382 | |
---|
383 | def setUp(self): |
---|
384 | from sans.models.FlexCylEllipXModel import FlexCylEllipXModel |
---|
385 | self.comp = FlexCylEllipXModel() |
---|
386 | #Give initial value to model |
---|
387 | self.comp.setParam("scale", 1.0) |
---|
388 | self.comp.setParam("sldSolv",6.3e-6 ) |
---|
389 | self.comp.setParam("sldCyl",1e-6 ) |
---|
390 | self.comp.setParam("kuhn_length",100) |
---|
391 | self.comp.setParam("length", 1000) |
---|
392 | self.comp.setParam("radius",20) |
---|
393 | self.comp.setParam("background", 0.0001) |
---|
394 | self.comp.setParam("axis_ratio", 1.0) |
---|
395 | |
---|
396 | self.x = numpy.array([0.4, 1.3]) |
---|
397 | self.y = numpy.array([0.5, 1.57]) |
---|
398 | self.x_array = self.comp.evalDistribution(self.x) |
---|
399 | self.y_array = self.comp.evalDistribution(self.y) |
---|
400 | |
---|
401 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
402 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
403 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
404 | |
---|
405 | self.q = 0.001 |
---|
406 | self.phi= math.pi/2 |
---|
407 | self.qx= self.q*math.cos(self.phi) |
---|
408 | self.qy= self.q*math.sin(self.phi) |
---|
409 | |
---|
410 | def test1D(self): |
---|
411 | """ Test 1D model for FlexCylEllipXModel""" |
---|
412 | self.assertAlmostEqual(self.comp.run(0.001), 3509.22, 1) |
---|
413 | |
---|
414 | def test1D_2(self): |
---|
415 | """ Test 2D model for FlexCylEllipXModel""" |
---|
416 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
417 | self.comp.runXY([self.qx, self.qy]),1) |
---|
418 | def testEval_1D(self): |
---|
419 | """ Test 1D model for FlexCylEllipXModel with evalDistribution""" |
---|
420 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
421 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
422 | |
---|
423 | def testEval_2D(self): |
---|
424 | """ Test 2D model for FlexCylEllipXModel with evalDistribution""" |
---|
425 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
426 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
427 | |
---|
428 | |
---|
429 | class TestStackedDisksModel(unittest.TestCase): |
---|
430 | """ Unit tests for StackedDisks Model""" |
---|
431 | |
---|
432 | def setUp(self): |
---|
433 | from sans.models.StackedDisksModel import StackedDisksModel |
---|
434 | self.comp = StackedDisksModel() |
---|
435 | #Give initial value to model |
---|
436 | self.comp.setParam("scale", 0.01 ) |
---|
437 | self.comp.setParam("radius",3000.0 ) |
---|
438 | self.comp.setParam("core_thick", 10.0) |
---|
439 | self.comp.setParam("layer_thick",15.0 ) |
---|
440 | self.comp.setParam("core_sld",4e-006 ) |
---|
441 | self.comp.setParam("layer_sld",-4e-007 ) |
---|
442 | self.comp.setParam("solvent_sld", 5e-006 ) |
---|
443 | self.comp.setParam("n_stacking",1.0 ) |
---|
444 | self.comp.setParam("sigma_d", 0.0) |
---|
445 | self.comp.setParam("background",0.001) |
---|
446 | self.comp.setParam("axis_theta", 0.0 ) |
---|
447 | self.comp.setParam("axis_phi",0.0) |
---|
448 | |
---|
449 | self.x = numpy.array([0.4, 1.3]) |
---|
450 | self.y = numpy.array([0.5, 1.57]) |
---|
451 | self.x_array = self.comp.evalDistribution(self.x) |
---|
452 | self.y_array = self.comp.evalDistribution(self.y) |
---|
453 | |
---|
454 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
455 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
456 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
457 | |
---|
458 | self.q = 0.001 |
---|
459 | self.phi= math.pi/2 |
---|
460 | self.qx= self.q*math.cos(self.phi) |
---|
461 | self.qy= self.q*math.sin(self.phi) |
---|
462 | |
---|
463 | def test1D(self): |
---|
464 | """ Test 1D model for a StackedDisks Model""" |
---|
465 | self.assertAlmostEqual(self.comp.run(0.001), 5075.12, 1) |
---|
466 | |
---|
467 | def test1D_2(self): |
---|
468 | """ Test 2D model for a StackedDisks Model""" |
---|
469 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
470 | self.comp.runXY([self.qx, self.qy]),1) |
---|
471 | |
---|
472 | def testEval_1D(self): |
---|
473 | """ Test 1D model for a StackedDisks Model with evalDistribution""" |
---|
474 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
475 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
476 | |
---|
477 | def testEval_2D(self): |
---|
478 | """ Test 2D model for a StackedDisks Model with evalDistribution""" |
---|
479 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
480 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
481 | |
---|
482 | # No more singular point |
---|
483 | #def testCriticalPoint(self): |
---|
484 | # """ Test StackedDisks at the critical point""" |
---|
485 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
486 | |
---|
487 | |
---|
488 | class TestParallelepipedModel(unittest.TestCase): |
---|
489 | """ Unit tests for Parallelepiped Model""" |
---|
490 | |
---|
491 | def setUp(self): |
---|
492 | from sans.models.ParallelepipedModel import ParallelepipedModel |
---|
493 | self.comp = ParallelepipedModel() |
---|
494 | #Give initial value to model |
---|
495 | self.comp.setParam("background", 0.0 ) |
---|
496 | self.comp.setParam("short_a",35) |
---|
497 | self.comp.setParam("short_b", 75) |
---|
498 | self.comp.setParam("long_c",400 ) |
---|
499 | self.comp.setParam("sldPipe", 6.3e-006 ) |
---|
500 | self.comp.setParam("sldSolv", 1e-006 ) |
---|
501 | self.comp.setParam("scale",1.0 ) |
---|
502 | |
---|
503 | self.x = numpy.array([0.4, 1.3]) |
---|
504 | self.y = numpy.array([0.5, 1.57]) |
---|
505 | self.x_array = self.comp.evalDistribution(self.x) |
---|
506 | self.y_array = self.comp.evalDistribution(self.y) |
---|
507 | |
---|
508 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
509 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
510 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
511 | |
---|
512 | self.q = 0.001 |
---|
513 | self.phi= math.pi/2 |
---|
514 | self.qx= self.q*math.cos(self.phi) |
---|
515 | self.qy= self.q*math.sin(self.phi) |
---|
516 | |
---|
517 | |
---|
518 | def test1D(self): |
---|
519 | """ Test 1D model for a Parallelepiped Model""" |
---|
520 | self.assertAlmostEqual(self.comp.run(0.001), 2935.82, 2) |
---|
521 | |
---|
522 | def test1D_2(self): |
---|
523 | """ Test 2D model for a Parallelepiped Model""" |
---|
524 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
525 | self.comp.runXY([self.qx, self.qy]),1) |
---|
526 | |
---|
527 | def testEval_1D(self): |
---|
528 | """ Test 1D model for a Parallelepiped Model with evalDistribution""" |
---|
529 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
530 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
531 | |
---|
532 | def testEval_2D(self): |
---|
533 | """ Test 2D model for a Parallelepiped Model with evalDistribution""" |
---|
534 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
535 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
536 | |
---|
537 | |
---|
538 | def testCriticalPoint(self): |
---|
539 | """ Test Parallelepiped at the critical point""" |
---|
540 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
541 | |
---|
542 | class TestEllipticalCylinderModel(unittest.TestCase): |
---|
543 | """ Unit tests for EllipticalCylinder Model""" |
---|
544 | |
---|
545 | def setUp(self): |
---|
546 | from sans.models.EllipticalCylinderModel import EllipticalCylinderModel |
---|
547 | self.comp = EllipticalCylinderModel() |
---|
548 | self.comp.setParam("scale",1.0) |
---|
549 | self.comp.setParam("r_minor",20.0) |
---|
550 | self.comp.setParam("r_ratio",1.5) |
---|
551 | self.comp.setParam("length",400.0) |
---|
552 | self.comp.setParam("sldCyl",4e-006) |
---|
553 | self.comp.setParam("sldSolv",1e-006) |
---|
554 | self.comp.setParam("background",0.0) |
---|
555 | self.comp.setParam("cyl_theta",0.0) |
---|
556 | self.comp.setParam("cyl_phi",0.0) |
---|
557 | self.comp.setParam("cyl_psi",0.0) |
---|
558 | |
---|
559 | self.x = numpy.array([0.4, 1.3]) |
---|
560 | self.y = numpy.array([0.5, 1.57]) |
---|
561 | self.x_array = self.comp.evalDistribution(self.x) |
---|
562 | self.y_array = self.comp.evalDistribution(self.y) |
---|
563 | |
---|
564 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
565 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
566 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
567 | |
---|
568 | self.q = 0.001 |
---|
569 | self.phi= math.pi/2 |
---|
570 | self.qx= self.q*math.cos(self.phi) |
---|
571 | self.qy= self.q*math.sin(self.phi) |
---|
572 | |
---|
573 | def test1D(self): |
---|
574 | """ Test 1D model for a EllipticalCylinder Model""" |
---|
575 | self.assertAlmostEqual(self.comp.run(0.001), 675.504402, 4) |
---|
576 | |
---|
577 | def test1D_2(self): |
---|
578 | """ Test 2D model for a EllipticalCylinder Model""" |
---|
579 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
580 | self.comp.runXY([self.qx, self.qy]),1) |
---|
581 | |
---|
582 | def testEval_1D(self): |
---|
583 | """ Test 1D model for a EllipticalCylinder with evalDistribution""" |
---|
584 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
585 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
586 | |
---|
587 | def testEval_2D(self): |
---|
588 | """ Test 2D model for a EllipticalCylinder with evalDistribution""" |
---|
589 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
590 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
591 | |
---|
592 | |
---|
593 | def testCriticalPoint(self): |
---|
594 | """ Test EllipticalCylinder at the critical point""" |
---|
595 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
596 | |
---|
597 | |
---|
598 | class TestEllipsoidModel(unittest.TestCase): |
---|
599 | """ Unit tests for Ellipsoid Model""" |
---|
600 | |
---|
601 | def setUp(self): |
---|
602 | from sans.models.EllipsoidModel import EllipsoidModel |
---|
603 | self.comp = EllipsoidModel() |
---|
604 | self.comp.setParam("scale",1.0) |
---|
605 | self.comp.setParam("radius_a",20.0) |
---|
606 | self.comp.setParam("radius_b",400.0) |
---|
607 | self.comp.setParam("sldEll",4e-006) |
---|
608 | self.comp.setParam("sldSolv",1e-006) |
---|
609 | self.comp.setParam("background",0.0) |
---|
610 | self.comp.setParam("axis_theta",1.57) |
---|
611 | self.comp.setParam("axis_phi",0.0) |
---|
612 | |
---|
613 | self.x = numpy.array([0.4, 1.3]) |
---|
614 | self.y = numpy.array([0.5, 1.57]) |
---|
615 | self.x_array = self.comp.evalDistribution(self.x) |
---|
616 | self.y_array = self.comp.evalDistribution(self.y) |
---|
617 | |
---|
618 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
619 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
620 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
621 | |
---|
622 | self.q = 0.001 |
---|
623 | self.phi= math.pi/2 |
---|
624 | self.qx= self.q*math.cos(self.phi) |
---|
625 | self.qy= self.q*math.sin(self.phi) |
---|
626 | |
---|
627 | def test1D(self): |
---|
628 | """ Test 1D model for a Ellipsoid Model""" |
---|
629 | self.assertAlmostEqual(self.comp.run(1.0), 0.000733968, 4) |
---|
630 | |
---|
631 | def test1D_2(self): |
---|
632 | """ Test 2D model for a Ellipsoid Model""" |
---|
633 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
634 | self.comp.runXY([self.qx, self.qy]),1) |
---|
635 | def testEval_1D(self): |
---|
636 | """ Test 1D model for a Ellipsoid Model with evalDistribution""" |
---|
637 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
638 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
639 | |
---|
640 | def testEval_2D(self): |
---|
641 | """ Test 2D model for a Ellipsoid Model with evalDistribution""" |
---|
642 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
643 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
644 | |
---|
645 | |
---|
646 | def testCriticalPoint(self): |
---|
647 | """ Test Ellipsoid at the critical point""" |
---|
648 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
649 | |
---|
650 | class TestCoreShellEllipsoidModel(unittest.TestCase): |
---|
651 | """ Unit tests for CoreShellEllipsoid Model""" |
---|
652 | |
---|
653 | def setUp(self): |
---|
654 | from sans.models.CoreShellEllipsoidModel import CoreShellEllipsoidModel |
---|
655 | self.comp = CoreShellEllipsoidModel() |
---|
656 | #Give initial value to model |
---|
657 | self.comp.setParam("scale", 1.0) |
---|
658 | self.comp.setParam("equat_core", 200.0) |
---|
659 | self.comp.setParam("polar_core", 20.0) |
---|
660 | self.comp.setParam("equat_shell",250.0) |
---|
661 | self.comp.setParam("polar_shell", 30.0) |
---|
662 | self.comp.setParam("sld_shell",1e-006) |
---|
663 | self.comp.setParam("sld_core",2e-006) |
---|
664 | self.comp.setParam("sld_solvent",6.3e-006) |
---|
665 | self.comp.setParam("background",0.001) |
---|
666 | self.comp.setParam("axis_theta", 0.0) |
---|
667 | self.comp.setParam("axis_phi",0.0) |
---|
668 | |
---|
669 | self.x = numpy.array([0.4, 1.3]) |
---|
670 | self.y = numpy.array([0.5, 1.57]) |
---|
671 | self.x_array = self.comp.evalDistribution(self.x) |
---|
672 | self.y_array = self.comp.evalDistribution(self.y) |
---|
673 | |
---|
674 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
675 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
676 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
677 | |
---|
678 | self.q = 0.001 |
---|
679 | self.phi= math.pi/2 |
---|
680 | self.qx= self.q*math.cos(self.phi) |
---|
681 | self.qy= self.q*math.sin(self.phi) |
---|
682 | |
---|
683 | def test1D(self): |
---|
684 | """ Test 1D model for a CoreShellEllipsoid Model""" |
---|
685 | self.assertAlmostEqual(self.comp.run(1.0), 0.001894, 4) |
---|
686 | |
---|
687 | def test1D_2(self): |
---|
688 | """ Test 2D model for a CoreShellEllipsoid Model""" |
---|
689 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
690 | self.comp.runXY([self.qx, self.qy]),1) |
---|
691 | |
---|
692 | def testEval_1D(self): |
---|
693 | """ Test 1D model for a CoreShellEllipsoid with evalDistribution""" |
---|
694 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
695 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
696 | |
---|
697 | def testEval_2D(self): |
---|
698 | """ Test 2D model for a CoreShellEllipsoid with evalDistribution""" |
---|
699 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
700 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
701 | |
---|
702 | |
---|
703 | def testCriticalPoint(self): |
---|
704 | """ Test CoreShellEllipsoid at the critical point""" |
---|
705 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
706 | |
---|
707 | class TestTriaxialEllipsoidModel(unittest.TestCase): |
---|
708 | """ Unit tests for TriaxialEllipsoid Model""" |
---|
709 | |
---|
710 | def setUp(self): |
---|
711 | from sans.models.TriaxialEllipsoidModel import TriaxialEllipsoidModel |
---|
712 | self.comp = TriaxialEllipsoidModel() |
---|
713 | self.comp.setParam("scale",1.0) |
---|
714 | self.comp.setParam("semi_axisA",35.0) |
---|
715 | self.comp.setParam("semi_axisB", 100.0) |
---|
716 | self.comp.setParam("semi_axisC",400.0 ) |
---|
717 | self.comp.setParam("sldSolv",6.3e-6) |
---|
718 | self.comp.setParam("sldEll",1e-6) |
---|
719 | self.comp.setParam("background",0.0) |
---|
720 | self.comp.setParam("axis_theta", 1.0) |
---|
721 | self.comp.setParam("axis_phi",0.0 ) |
---|
722 | self.comp.setParam("axis_psi",0.0 ) |
---|
723 | |
---|
724 | self.x = numpy.array([0.4, 1.3]) |
---|
725 | self.y = numpy.array([0.5, 1.57]) |
---|
726 | |
---|
727 | self.x_array = self.comp.evalDistribution(self.x) |
---|
728 | self.y_array = self.comp.evalDistribution(self.y) |
---|
729 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
730 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
731 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
732 | |
---|
733 | self.q = 0.001 |
---|
734 | self.phi= math.pi/2 |
---|
735 | self.qx= self.q*math.cos(self.phi) |
---|
736 | self.qy= self.q*math.sin(self.phi) |
---|
737 | |
---|
738 | |
---|
739 | def test1D(self): |
---|
740 | """ Test 1D model for a TriaxialEllipsoid Model""" |
---|
741 | self.assertAlmostEquals(self.comp.run(0.001),16285.6, 1) |
---|
742 | |
---|
743 | def test1D_2(self): |
---|
744 | """ Test 2D model for a TriaxialEllipsoid Model""" |
---|
745 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
746 | self.comp.runXY([self.qx, self.qy]),1) |
---|
747 | |
---|
748 | def testEval_1D(self): |
---|
749 | """ Test 1D model for a TriaxialEllipsoid Model with evalDistribution""" |
---|
750 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
751 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
752 | |
---|
753 | def testEval_2D(self): |
---|
754 | """ Test 2D model for a TriaxialEllipsoid Model with evalDistribution""" |
---|
755 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
756 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
757 | |
---|
758 | |
---|
759 | def testCriticalPoint(self): |
---|
760 | """ Test TriaxialEllipsoid at the critical point""" |
---|
761 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
762 | |
---|
763 | class TestLamellarModel(unittest.TestCase): |
---|
764 | """ Unit tests for Lamellar Model""" |
---|
765 | |
---|
766 | def setUp(self): |
---|
767 | from sans.models.LamellarModel import LamellarModel |
---|
768 | self.comp = LamellarModel() |
---|
769 | self.comp.setParam("scale",1.0) |
---|
770 | self.comp.setParam("bi_thick",50.0) |
---|
771 | self.comp.setParam("sld_bi",1e-006) |
---|
772 | self.comp.setParam("sld_sol",6.3e-006) |
---|
773 | self.comp.setParam("background",0.0) |
---|
774 | |
---|
775 | self.x = numpy.array([0.4, 1.3]) |
---|
776 | self.y = numpy.array([0.5, 1.57]) |
---|
777 | |
---|
778 | self.x_array = self.comp.evalDistribution(self.x) |
---|
779 | self.y_array = self.comp.evalDistribution(self.y) |
---|
780 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
781 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
782 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
783 | |
---|
784 | def test1D(self): |
---|
785 | """ Test 1D model for a Lamellar Model""" |
---|
786 | self.assertAlmostEquals(self.comp.run(0.001), 882289.54309, 3) |
---|
787 | |
---|
788 | def test1D_2(self): |
---|
789 | """ Test 2D model for a Lamellar Model""" |
---|
790 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),882289.54309, 3) |
---|
791 | |
---|
792 | def testEval_1D(self): |
---|
793 | """ Test 1D model for a Lamellar Model with evalDistribution""" |
---|
794 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
795 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
796 | |
---|
797 | def testEval_2D(self): |
---|
798 | """ Test 2D model for a Lamellar Model with evalDistribution""" |
---|
799 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
800 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
801 | |
---|
802 | # No more singular point |
---|
803 | #def testCriticalPoint(self): |
---|
804 | # """ Test Lamellar at the critical point""" |
---|
805 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
806 | |
---|
807 | class TestLamellarFFHGModel(unittest.TestCase): |
---|
808 | """ Unit tests for LamellarFFHG Model""" |
---|
809 | |
---|
810 | def setUp(self): |
---|
811 | from sans.models.LamellarFFHGModel import LamellarFFHGModel |
---|
812 | self.comp = LamellarFFHGModel() |
---|
813 | self.comp.setParam("scale",1.0) |
---|
814 | self.comp.setParam("t_length",15.0) |
---|
815 | self.comp.setParam("h_thickness",10.0) |
---|
816 | self.comp.setParam("sld_tail",4e-007) |
---|
817 | self.comp.setParam("sld_head",3e-006) |
---|
818 | self.comp.setParam("sld_solvent",6e-006) |
---|
819 | self.comp.setParam("background",0.0) |
---|
820 | |
---|
821 | self.x = numpy.array([0.4, 1.3]) |
---|
822 | self.y = numpy.array([0.5, 1.57]) |
---|
823 | |
---|
824 | self.x_array = self.comp.evalDistribution(self.x) |
---|
825 | self.y_array = self.comp.evalDistribution(self.y) |
---|
826 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
827 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
828 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
829 | |
---|
830 | |
---|
831 | def test1D(self): |
---|
832 | """ Test 1D model for a LamellarFFHG Model""" |
---|
833 | self.assertAlmostEquals(self.comp.run(0.001),653143.9209, 3) |
---|
834 | |
---|
835 | def test1D_2(self): |
---|
836 | """ Test 2D model for a LamellarFFHG Model""" |
---|
837 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),653143.9209, 3) |
---|
838 | |
---|
839 | def testEval_1D(self): |
---|
840 | """ Test 1D model for a LamellarFFHG Model with evalDistribution""" |
---|
841 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
842 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
843 | |
---|
844 | def testEval_2D(self): |
---|
845 | """ Test 2D model for a LamellarFFHG Model with evalDistribution""" |
---|
846 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
847 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
848 | |
---|
849 | # No more singular point |
---|
850 | #def testCriticalPoint(self): |
---|
851 | # """ Test LamellarFFHG at the critical point""" |
---|
852 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
853 | |
---|
854 | class TestLamellarPSModel(unittest.TestCase): |
---|
855 | """ Unit tests for LamellarPS Model""" |
---|
856 | |
---|
857 | def setUp(self): |
---|
858 | from sans.models.LamellarPSModel import LamellarPSModel |
---|
859 | self.comp = LamellarPSModel() |
---|
860 | self.comp.setParam("scale",1.0) |
---|
861 | self.comp.setParam("spacing",400.0) |
---|
862 | self.comp.setParam("delta",30.0) |
---|
863 | self.comp.setParam("sld_bi",6.3e-006) |
---|
864 | self.comp.setParam("sld_sol",1e-006) |
---|
865 | self.comp.setParam("n_plates",20.0) |
---|
866 | self.comp.setParam("caille", 0.1) |
---|
867 | self.comp.setParam("background",0.0) |
---|
868 | |
---|
869 | self.x = numpy.array([0.4, 1.3]) |
---|
870 | self.y = numpy.array([0.5, 1.57]) |
---|
871 | |
---|
872 | self.x_array = self.comp.evalDistribution(self.x) |
---|
873 | self.y_array = self.comp.evalDistribution(self.y) |
---|
874 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
875 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
876 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
877 | |
---|
878 | |
---|
879 | def test1D(self): |
---|
880 | """ Test 1D model for a LamellarPS Model""" |
---|
881 | self.assertAlmostEquals(self.comp.run(0.001), 27899.30836, 1) |
---|
882 | |
---|
883 | def test1D_2(self): |
---|
884 | """ Test 2D model for a LamellarPS Model""" |
---|
885 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),27899.30836, 1) |
---|
886 | |
---|
887 | def testEval_1D(self): |
---|
888 | """ Test 1D model for a LamellarPS Model with evalDistribution""" |
---|
889 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
890 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
891 | |
---|
892 | def testEval_2D(self): |
---|
893 | """ Test 2D model for a LamellarPS Model with evalDistribution""" |
---|
894 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
895 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
896 | |
---|
897 | # No more singular point |
---|
898 | #def testCriticalPoint(self): |
---|
899 | # """ Test LamellarPS at the critical point""" |
---|
900 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
901 | |
---|
902 | class TestLamellarPSHGModel(unittest.TestCase): |
---|
903 | """ Unit tests for LamellarPSHG Model""" |
---|
904 | |
---|
905 | def setUp(self): |
---|
906 | from sans.models.LamellarPSHGModel import LamellarPSHGModel |
---|
907 | self.comp = LamellarPSHGModel() |
---|
908 | self.comp.setParam("scale",1.0) |
---|
909 | self.comp.setParam("spacing",40.0) |
---|
910 | self.comp.setParam("deltaT",10.0) |
---|
911 | self.comp.setParam("deltaH",2.0) |
---|
912 | self.comp.setParam("sld_tail",4e-7) |
---|
913 | self.comp.setParam("sld_head",2e-6) |
---|
914 | self.comp.setParam("sld_solvent",6e-6) |
---|
915 | self.comp.setParam("n_plates",30) |
---|
916 | self.comp.setParam("caille",0.001) |
---|
917 | self.comp.setParam("background",0.001) |
---|
918 | |
---|
919 | self.x = numpy.array([0.4, 1.3]) |
---|
920 | self.y = numpy.array([0.5, 1.57]) |
---|
921 | |
---|
922 | self.x_array = self.comp.evalDistribution(self.x) |
---|
923 | self.y_array = self.comp.evalDistribution(self.y) |
---|
924 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
925 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
926 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
927 | |
---|
928 | def test1D(self): |
---|
929 | """ Test 1D model for a LamellarPSHG Model""" |
---|
930 | self.assertAlmostEquals(self.comp.run(0.001),6831387.29466, 3) |
---|
931 | |
---|
932 | def test1D_2(self): |
---|
933 | """ Test 2D model for a LamellarPSHG Model""" |
---|
934 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),6831387.29466,3) |
---|
935 | |
---|
936 | def testEval_1D(self): |
---|
937 | """ Test 1D model for a LamellarPSHG Model with evalDistribution""" |
---|
938 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
939 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
940 | |
---|
941 | def testEval_2D(self): |
---|
942 | """ Test 2D model for a LamellarPSHG Model with evalDistribution""" |
---|
943 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
944 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
945 | |
---|
946 | # No more singular point |
---|
947 | #def testCriticalPoint(self): |
---|
948 | # """ Test LamellarPSHG at the critical point""" |
---|
949 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
950 | |
---|
951 | class TestSquareWellStructure(unittest.TestCase): |
---|
952 | """ Unit tests for SquareWellStructure """ |
---|
953 | |
---|
954 | def setUp(self): |
---|
955 | from sans.models.SquareWellStructure import SquareWellStructure |
---|
956 | self.comp = SquareWellStructure() |
---|
957 | self.comp.setParam("effect_radius",50.0) |
---|
958 | self.comp.setParam("volfraction",0.04) |
---|
959 | self.comp.setParam("welldepth",1.5 ) |
---|
960 | self.comp.setParam("wellwidth",1.2) |
---|
961 | |
---|
962 | self.x = numpy.array([0.4, 1.3]) |
---|
963 | self.y = numpy.array([0.5, 1.57]) |
---|
964 | |
---|
965 | self.x_array = self.comp.evalDistribution(self.x) |
---|
966 | self.y_array = self.comp.evalDistribution(self.y) |
---|
967 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
968 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
969 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
970 | |
---|
971 | |
---|
972 | def test1D(self): |
---|
973 | """ Test 1D model for a SquareWellStructure""" |
---|
974 | self.assertAlmostEqual(self.comp.run(0.001), 0.976657, 2) |
---|
975 | |
---|
976 | def test1D_2(self): |
---|
977 | """ Test 2D model for a SquareWellStructure""" |
---|
978 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.9776657,2) |
---|
979 | |
---|
980 | def testEval_1D(self): |
---|
981 | """ Test 1D model for a SquareWellStructure with evalDistribution""" |
---|
982 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
983 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
984 | |
---|
985 | def testEval_2D(self): |
---|
986 | """ Test 2D model for a SquareWellStructure with evalDistribution""" |
---|
987 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
988 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
989 | |
---|
990 | # No more singular point |
---|
991 | #def testCriticalPoint(self): |
---|
992 | # """ Test SquareWellStructure at the critical point""" |
---|
993 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
994 | |
---|
995 | class TestHardsphereStructure(unittest.TestCase): |
---|
996 | """ Unit tests for HardsphereStructure""" |
---|
997 | |
---|
998 | def setUp(self): |
---|
999 | from sans.models.HardsphereStructure import HardsphereStructure |
---|
1000 | self.comp = HardsphereStructure() |
---|
1001 | self.comp.setParam("effect_radius",50.0) |
---|
1002 | self.comp.setParam("volfraction", 0.2) |
---|
1003 | self.x = numpy.array([0.4, 1.3]) |
---|
1004 | self.y = numpy.array([0.5, 1.57]) |
---|
1005 | |
---|
1006 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1007 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1008 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1009 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1010 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1011 | |
---|
1012 | |
---|
1013 | def test1D(self): |
---|
1014 | """ Test 1D model for a HardsphereStructure""" |
---|
1015 | self.assertAlmostEqual(self.comp.run(0.001),0.209128, 4) |
---|
1016 | |
---|
1017 | def test1D_2(self): |
---|
1018 | """ Test 2D model for a HardsphereStructure""" |
---|
1019 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.209128, 4) |
---|
1020 | |
---|
1021 | def testEval_1D(self): |
---|
1022 | """ Test 1D model for a HardsphereStructure with evalDistribution""" |
---|
1023 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1024 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1025 | |
---|
1026 | def testEval_2D(self): |
---|
1027 | """ Test 2D model for a HardsphereStructure with evalDistribution""" |
---|
1028 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1029 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1030 | |
---|
1031 | # No more singular point |
---|
1032 | #def testCriticalPoint(self): |
---|
1033 | # """ Test HardsphereStructure at the critical point""" |
---|
1034 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1035 | |
---|
1036 | class TestStickyHSStructure(unittest.TestCase): |
---|
1037 | """ Unit tests for StickyHSStructure""" |
---|
1038 | |
---|
1039 | def setUp(self): |
---|
1040 | from sans.models.StickyHSStructure import StickyHSStructure |
---|
1041 | self.comp = StickyHSStructure() |
---|
1042 | self.comp.setParam("effect_radius",50.0) |
---|
1043 | self.comp.setParam("volfraction",0.1) |
---|
1044 | self.comp.setParam("perturb",0.05) |
---|
1045 | self.comp.setParam("stickiness",0.2) |
---|
1046 | |
---|
1047 | self.x = numpy.array([0.4, 1.3]) |
---|
1048 | self.y = numpy.array([0.5, 1.57]) |
---|
1049 | |
---|
1050 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1051 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1052 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1053 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1054 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1055 | |
---|
1056 | def test1D(self): |
---|
1057 | """ Test 1D model for a StickyHSStructure""" |
---|
1058 | self.assertAlmostEqual(self.comp.run(0.001),1.09718, 4) |
---|
1059 | |
---|
1060 | def test1D_2(self): |
---|
1061 | """ Test 2D model for a StickyHSStructure""" |
---|
1062 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),1.09718, 4) |
---|
1063 | |
---|
1064 | def testEval_1D(self): |
---|
1065 | """ Test 1D model for a StickyHSStructure with evalDistribution""" |
---|
1066 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1067 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1068 | |
---|
1069 | def testEval_2D(self): |
---|
1070 | """ Test 2D model for a StickyHSStructure with evalDistribution""" |
---|
1071 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1072 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1073 | |
---|
1074 | # No more singular point |
---|
1075 | #def testCriticalPoint(self): |
---|
1076 | # """ Test StickyHSStructure at the critical point""" |
---|
1077 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1078 | |
---|
1079 | class TestHayterMSAStructure(unittest.TestCase): |
---|
1080 | """ Unit tests for HayterMSAStructure""" |
---|
1081 | |
---|
1082 | def setUp(self): |
---|
1083 | from sans.models.HayterMSAStructure import HayterMSAStructure |
---|
1084 | self.comp = HayterMSAStructure() |
---|
1085 | self.comp.setParam("effect_radius",20.75) |
---|
1086 | self.comp.setParam("charge",19.0) |
---|
1087 | self.comp.setParam("volfraction",0.0192 ) |
---|
1088 | self.comp.setParam("temperature",298) |
---|
1089 | self.comp.setParam("saltconc",0.0) |
---|
1090 | self.comp.setParam("dielectconst",78) |
---|
1091 | |
---|
1092 | self.x = numpy.array([0.4, 1.3]) |
---|
1093 | self.y = numpy.array([0.5, 1.57]) |
---|
1094 | |
---|
1095 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1096 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1097 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1098 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1099 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1100 | |
---|
1101 | def test1D(self): |
---|
1102 | """ Test 1D model for a HayterMSAStructure""" |
---|
1103 | self.assertAlmostEqual(self.comp.run(0.001),0.0712928, 4) |
---|
1104 | |
---|
1105 | def test1D_2(self): |
---|
1106 | """ Test 2D model for a HayterMSAStructure""" |
---|
1107 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.0712928, 4) |
---|
1108 | |
---|
1109 | def testEval_1D(self): |
---|
1110 | """ Test 1D model for a HayterMSAStructure with evalDistribution""" |
---|
1111 | self.assertTrue(math.fabs(self.comp.run(0.4)-self.x_array[0])<0.025, "Difference too big: %g" % math.fabs(self.comp.run(0.4)-self.x_array[0])) |
---|
1112 | self.assertTrue(math.fabs(self.comp.run(1.3)-self.x_array[1])<0.025, "Difference too big: %g" % math.fabs(self.comp.run(1.3)-self.x_array[1])) |
---|
1113 | |
---|
1114 | def testEval_2D(self): |
---|
1115 | """ Test 2D model for a HayterMSAStructure with evalDistribution""" |
---|
1116 | self.assertTrue(math.fabs(self.comp.runXY([0.4, 0.5])-self.xy_matrix[0])<0.05, "Difference too big: %g" % math.fabs(self.comp.runXY([0.4, 0.5])-self.xy_matrix[0])) |
---|
1117 | self.assertTrue(math.fabs(self.comp.runXY([1.3,1.57])-self.xy_matrix[1])<0.05, "Difference too big: %g" % math.fabs(self.comp.runXY([1.3,1.57])-self.xy_matrix[1])) |
---|
1118 | |
---|
1119 | |
---|
1120 | def testCriticalPoint(self): |
---|
1121 | """ Test HayterMSAStructure at the critical point""" |
---|
1122 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1123 | |
---|
1124 | |
---|
1125 | class TestBEPolyelectrolyte(unittest.TestCase): |
---|
1126 | """ Unit tests for BEPolyelectrolyte""" |
---|
1127 | |
---|
1128 | def setUp(self): |
---|
1129 | from sans.models.BEPolyelectrolyte import BEPolyelectrolyte |
---|
1130 | self.comp = BEPolyelectrolyte() |
---|
1131 | |
---|
1132 | self.comp.setParam('k',10) |
---|
1133 | self.comp.setParam('lb',7.1) |
---|
1134 | self.comp.setParam('h',12) |
---|
1135 | self.comp.setParam('b',10) |
---|
1136 | self.comp.setParam('cs', 0.0) |
---|
1137 | self.comp.setParam('alpha',0.05) |
---|
1138 | self.comp.setParam('c', 0.7) |
---|
1139 | self.comp.setParam('background',0.001) |
---|
1140 | |
---|
1141 | self.x = numpy.array([0.4, 1.3]) |
---|
1142 | self.y = numpy.array([0.5, 1.57]) |
---|
1143 | |
---|
1144 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1145 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1146 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1147 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1148 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1149 | |
---|
1150 | def test1D(self): |
---|
1151 | """ Test 1D model for a BEPolyelectrolyte""" |
---|
1152 | self.assertAlmostEqual(self.comp.run(0.001),0.0948, 3) |
---|
1153 | |
---|
1154 | def test1D_2(self): |
---|
1155 | """ Test 2D model for a BEPolyelectrolyte""" |
---|
1156 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.0948, 3) |
---|
1157 | |
---|
1158 | def testEval_1D(self): |
---|
1159 | """ Test 1D model for a BEPolyelectrolyte with evalDistribution""" |
---|
1160 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1161 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1162 | |
---|
1163 | def testEval_2D(self): |
---|
1164 | """ Test 2D model for a BEPolyelectrolyte with evalDistribution""" |
---|
1165 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1166 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1167 | |
---|
1168 | |
---|
1169 | def testCriticalPoint(self): |
---|
1170 | """ Test BEPolyelectrolyte at the critical point""" |
---|
1171 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1172 | |
---|
1173 | |
---|
1174 | class TestDABModel(unittest.TestCase): |
---|
1175 | """ Unit tests for DABModel""" |
---|
1176 | |
---|
1177 | def setUp(self): |
---|
1178 | from sans.models.DABModel import DABModel |
---|
1179 | self.comp = DABModel() |
---|
1180 | self.comp.setParam('length',40.0) |
---|
1181 | self.comp.setParam('scale',10.0) |
---|
1182 | self.comp.setParam('background',1.0) |
---|
1183 | |
---|
1184 | self.x = numpy.array([0.4, 1.3]) |
---|
1185 | self.y = numpy.array([0.5, 1.57]) |
---|
1186 | |
---|
1187 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1188 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1189 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1190 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1191 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1192 | |
---|
1193 | def test1D(self): |
---|
1194 | """ Test 1D model for a DABModel""" |
---|
1195 | self.assertAlmostEqual(self.comp.run(0.001),637957.9047, 3) |
---|
1196 | |
---|
1197 | def test1D_2(self): |
---|
1198 | """ Test 2D model for a DABModel""" |
---|
1199 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),637957.90473, 3) |
---|
1200 | |
---|
1201 | def testEval_1D(self): |
---|
1202 | """ Test 1D model for a DABModel with evalDistribution""" |
---|
1203 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1204 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1205 | |
---|
1206 | def testEval_2D(self): |
---|
1207 | """ Test 2D model for a DABModel with evalDistribution""" |
---|
1208 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1209 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1210 | |
---|
1211 | |
---|
1212 | def testCriticalPoint(self): |
---|
1213 | """ Test DABModel at the critical point""" |
---|
1214 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1215 | |
---|
1216 | |
---|
1217 | class TestGuinierModel(unittest.TestCase): |
---|
1218 | """ Unit tests for Guinier Model""" |
---|
1219 | |
---|
1220 | def setUp(self): |
---|
1221 | from sans.models.GuinierModel import GuinierModel |
---|
1222 | self.comp = GuinierModel() |
---|
1223 | self.comp.setParam('scale',1.0) |
---|
1224 | self.comp.setParam('rg', 1) |
---|
1225 | |
---|
1226 | self.x = numpy.array([0.4, 1.3]) |
---|
1227 | self.y = numpy.array([0.5, 1.57]) |
---|
1228 | |
---|
1229 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1230 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1231 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1232 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1233 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1234 | |
---|
1235 | def test1D(self): |
---|
1236 | """ Test 1D model for a GuinierModel""" |
---|
1237 | self.assertAlmostEqual(self.comp.run(1.0),0.716531, 4) |
---|
1238 | |
---|
1239 | def test1D_2(self): |
---|
1240 | """ Test 2D model for a GuinierModel""" |
---|
1241 | self.assertAlmostEqual(self.comp.run([1.0, 1.3]),0.716531, 4) |
---|
1242 | |
---|
1243 | def testEval_1D(self): |
---|
1244 | """ Test 1D model for a GuinierModel with evalDistribution""" |
---|
1245 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1246 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1247 | |
---|
1248 | def testEval_2D(self): |
---|
1249 | """ Test 2D model for a GuinierModel with evalDistribution""" |
---|
1250 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1251 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1252 | |
---|
1253 | |
---|
1254 | def testCriticalPoint(self): |
---|
1255 | """ Test GuinierModel at the critical point""" |
---|
1256 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1257 | |
---|
1258 | |
---|
1259 | class TestDebyeModel(unittest.TestCase): |
---|
1260 | """ Unit tests for Debye Model""" |
---|
1261 | |
---|
1262 | def setUp(self): |
---|
1263 | from sans.models.DebyeModel import DebyeModel |
---|
1264 | self.comp = DebyeModel() |
---|
1265 | self.comp.setParam('rg', 50.0) |
---|
1266 | self.comp.setParam('scale',1.0) |
---|
1267 | self.comp.setParam('background',0.001) |
---|
1268 | |
---|
1269 | self.x = numpy.array([0.4, 1.3]) |
---|
1270 | self.y = numpy.array([0.5, 1.57]) |
---|
1271 | |
---|
1272 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1273 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1274 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1275 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1276 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1277 | |
---|
1278 | def test1D(self): |
---|
1279 | """ Test 1D model for a DebyeModel""" |
---|
1280 | self.assertAlmostEqual(self.comp.run(0.001),1.00017,4) |
---|
1281 | |
---|
1282 | def test1D_2(self): |
---|
1283 | """ Test 2D model for a DebyeModel""" |
---|
1284 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),1.00017,4) |
---|
1285 | |
---|
1286 | def testEval_1D(self): |
---|
1287 | """ Test 1D model for a DebyeModel with evalDistribution""" |
---|
1288 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1289 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1290 | |
---|
1291 | def testEval_2D(self): |
---|
1292 | """ Test 2D model for a DebyeModel with evalDistribution""" |
---|
1293 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1294 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1295 | |
---|
1296 | |
---|
1297 | def testCriticalPoint(self): |
---|
1298 | """ Test DebyeModel at the critical point""" |
---|
1299 | self.assertEquals(self.comp.run(0.0),1.001) |
---|
1300 | |
---|
1301 | |
---|
1302 | class TestPorodModel(unittest.TestCase): |
---|
1303 | """ Unit tests for PorodModel""" |
---|
1304 | |
---|
1305 | def setUp(self): |
---|
1306 | from sans.models.PorodModel import PorodModel |
---|
1307 | self.comp = PorodModel() |
---|
1308 | self.comp.setParam('scale', 1.0) |
---|
1309 | self.comp.setParam('background', 0.0) |
---|
1310 | |
---|
1311 | self.x = numpy.array([0.4, 1.3]) |
---|
1312 | self.y = numpy.array([0.5, 1.57]) |
---|
1313 | |
---|
1314 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1315 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1316 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1317 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1318 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1319 | |
---|
1320 | def test1D(self): |
---|
1321 | """ Test 1D model for a PorodModel""" |
---|
1322 | self.assertEquals(self.comp.run(0.5), 16) |
---|
1323 | |
---|
1324 | def test1D_2(self): |
---|
1325 | """ Test 2D model for a PorodModel""" |
---|
1326 | self.assertEquals(self.comp.run([0.5, 1.3]),16) |
---|
1327 | |
---|
1328 | def testEval_1D(self): |
---|
1329 | """ Test 1D model for a PorodModel with evalDistribution""" |
---|
1330 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1331 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1332 | |
---|
1333 | def testEval_2D(self): |
---|
1334 | """ Test 2D model for a PorodModel with evalDistribution""" |
---|
1335 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1336 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1337 | |
---|
1338 | |
---|
1339 | def testCreaticalPoint(self): |
---|
1340 | """ Test for critical point for PorodModel run""" |
---|
1341 | self.assertRaises(ZeroDivisionError, self.comp.run, 0.0) |
---|
1342 | |
---|
1343 | |
---|
1344 | class TestPeakGaussModel(unittest.TestCase): |
---|
1345 | """ Unit tests for PeakGaussModel""" |
---|
1346 | |
---|
1347 | def setUp(self): |
---|
1348 | from sans.models.PeakGaussModel import PeakGaussModel |
---|
1349 | self.comp = PeakGaussModel() |
---|
1350 | self.comp.setParam('scale', 100) |
---|
1351 | self.comp.setParam('B', 0.005) |
---|
1352 | self.comp.setParam('q0',0.05) |
---|
1353 | self.comp.setParam('background',1.0) |
---|
1354 | |
---|
1355 | self.x = numpy.array([0.4, 1.3]) |
---|
1356 | self.y = numpy.array([0.5, 1.57]) |
---|
1357 | |
---|
1358 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1359 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1360 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1361 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1362 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1363 | |
---|
1364 | def test1D(self): |
---|
1365 | """ Test 1D model for a PeakGauss Model""" |
---|
1366 | self.assertEquals(self.comp.run(0.001),1) |
---|
1367 | |
---|
1368 | def test1D_2(self): |
---|
1369 | """ Test 2D model for a PeakGauss Model""" |
---|
1370 | self.assertEquals(self.comp.run([0.001, 1.3]),1) |
---|
1371 | |
---|
1372 | def testEval_1D(self): |
---|
1373 | """ Test 1D model for a PeakGauss Model with evalDistribution""" |
---|
1374 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1375 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1376 | |
---|
1377 | def testEval_2D(self): |
---|
1378 | """ Test 2D model for a PeakGauss Model with evalDistribution""" |
---|
1379 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1380 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1381 | |
---|
1382 | def testCriticalPoint(self): |
---|
1383 | """ Test PeakGauss at the critical point""" |
---|
1384 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1385 | |
---|
1386 | class TestPeakLorentzModel(unittest.TestCase): |
---|
1387 | """ Unit tests for PeakLorentzModel""" |
---|
1388 | |
---|
1389 | def setUp(self): |
---|
1390 | from sans.models.PeakLorentzModel import PeakLorentzModel |
---|
1391 | self.comp = PeakLorentzModel() |
---|
1392 | self.comp.setParam('scale', 100) |
---|
1393 | self.comp.setParam('B', 0.005) |
---|
1394 | self.comp.setParam('q0',0.05) |
---|
1395 | self.comp.setParam('background',1.0) |
---|
1396 | |
---|
1397 | self.x = numpy.array([0.4, 1.3]) |
---|
1398 | self.y = numpy.array([0.5, 1.57]) |
---|
1399 | |
---|
1400 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1401 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1402 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1403 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1404 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1405 | |
---|
1406 | def test1D(self): |
---|
1407 | """ Test 1D model for a PeakLorentz Model""" |
---|
1408 | self.assertAlmostEqual(self.comp.run(0.001), 2.0305, 3) |
---|
1409 | |
---|
1410 | def test1D_2(self): |
---|
1411 | """ Test 2D model for a PeakLorentz Model""" |
---|
1412 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 2.0305, 3) |
---|
1413 | |
---|
1414 | def testEval_1D(self): |
---|
1415 | """ Test 1D model for a PeakLorentz Model with evalDistribution""" |
---|
1416 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1417 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1418 | |
---|
1419 | def testEval_2D(self): |
---|
1420 | """ Test 2D model for a PeakLorentz Model with evalDistribution""" |
---|
1421 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1422 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1423 | |
---|
1424 | |
---|
1425 | def testCriticalPoint(self): |
---|
1426 | """ Test PeakLorentz at the critical point""" |
---|
1427 | self.comp.setParam('B', 0.0) |
---|
1428 | self.assertRaises(ZeroDivisionError, self.comp.run, 10) |
---|
1429 | #self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1430 | |
---|
1431 | |
---|
1432 | class TestFractalAbsModel(unittest.TestCase): |
---|
1433 | """ Unit tests for FractalAbsModel""" |
---|
1434 | |
---|
1435 | def setUp(self): |
---|
1436 | from sans.models.FractalAbsModel import FractalAbsModel |
---|
1437 | self.comp = FractalAbsModel() |
---|
1438 | self.comp.setParam('scale', 0.05) |
---|
1439 | self.comp.setParam('radius', 5.0) |
---|
1440 | self.comp.setParam('fractal_dim', 2.0) |
---|
1441 | self.comp.setParam('cor_length',100.0) |
---|
1442 | self.comp.setParam('sldBlock', 2.0e-6) |
---|
1443 | self.comp.setParam('sldSolv', 6.35e-6) |
---|
1444 | self.comp.setParam('background',0.0) |
---|
1445 | |
---|
1446 | self.x = numpy.array([0.4, 1.3]) |
---|
1447 | self.y = numpy.array([0.5, 1.57]) |
---|
1448 | |
---|
1449 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1450 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1451 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1452 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1453 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1454 | |
---|
1455 | def test1D(self): |
---|
1456 | """ Test 1D model for a Fractal Abs Model""" |
---|
1457 | self.assertAlmostEqual(self.comp.run(0.001), 39.2881, 3) |
---|
1458 | |
---|
1459 | def test1D_2(self): |
---|
1460 | """ Test 2D model for a Fractal Abs Model""" |
---|
1461 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 39.2881, 3) |
---|
1462 | |
---|
1463 | def testEval_1D(self): |
---|
1464 | """ Test 1D model for a Fractal Abs Model with evalDistribution""" |
---|
1465 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1466 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1467 | |
---|
1468 | def testEval_2D(self): |
---|
1469 | """ Test 2D model for a Fractal Abs Model with evalDistribution""" |
---|
1470 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1471 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1472 | |
---|
1473 | # No more singular point |
---|
1474 | #def testCriticalPoint(self): |
---|
1475 | # """ Test Fractal Abs at the critical point""" |
---|
1476 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1477 | |
---|
1478 | class TestFractalModel(unittest.TestCase): |
---|
1479 | """ Unit tests for FractalModel""" |
---|
1480 | |
---|
1481 | def setUp(self): |
---|
1482 | from sans.models.FractalModel import FractalModel |
---|
1483 | self.comp = FractalModel() |
---|
1484 | self.comp.setParam('scale', 0.05) |
---|
1485 | self.comp.setParam('radius', 5.0) |
---|
1486 | self.comp.setParam('fractal_dim', 2.0) |
---|
1487 | self.comp.setParam('cor_length',100.0) |
---|
1488 | self.comp.setParam('sldBlock', 2.0e-6) |
---|
1489 | self.comp.setParam('sldSolv', 6.35e-6) |
---|
1490 | self.comp.setParam('background',0.0) |
---|
1491 | |
---|
1492 | self.x = numpy.array([0.4, 1.3]) |
---|
1493 | self.y = numpy.array([0.5, 1.57]) |
---|
1494 | |
---|
1495 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1496 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1497 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1498 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1499 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1500 | |
---|
1501 | def test1D(self): |
---|
1502 | """ Test 1D model for a Fractal Model""" |
---|
1503 | self.assertAlmostEqual(self.comp.run(0.001), 39.2881, 3) |
---|
1504 | |
---|
1505 | def test1D_2(self): |
---|
1506 | """ Test 2D model for a Fractal Model""" |
---|
1507 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 39.2881, 3) |
---|
1508 | |
---|
1509 | def testEval_1D(self): |
---|
1510 | """ Test 1D model for a Fractal Model with evalDistribution""" |
---|
1511 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1512 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1513 | |
---|
1514 | def testEval_2D(self): |
---|
1515 | """ Test 2D model for a Fractal Model with evalDistribution""" |
---|
1516 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1517 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1518 | |
---|
1519 | # No more singular point |
---|
1520 | #def testCriticalPoint(self): |
---|
1521 | # """ Test Fractal at the critical point""" |
---|
1522 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1523 | |
---|
1524 | class TestLorentzModel(unittest.TestCase): |
---|
1525 | """ Unit tests for LorentzModel""" |
---|
1526 | |
---|
1527 | def setUp(self): |
---|
1528 | from sans.models.LorentzModel import LorentzModel |
---|
1529 | self.comp = LorentzModel() |
---|
1530 | self.comp.setParam("background",1) |
---|
1531 | self.comp.setParam("length",50) |
---|
1532 | self.comp.setParam("scale",100) |
---|
1533 | |
---|
1534 | self.x = numpy.array([0.4, 1.3]) |
---|
1535 | self.y = numpy.array([0.5, 1.57]) |
---|
1536 | |
---|
1537 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1538 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1539 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1540 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1541 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1542 | |
---|
1543 | def test1D(self): |
---|
1544 | """ Test 1D model for a Lorentz Model""" |
---|
1545 | self.assertAlmostEqual(self.comp.run(0.001),100.751, 2) |
---|
1546 | |
---|
1547 | def test1D_2(self): |
---|
1548 | """ Test 2D model for a Lorentz Model""" |
---|
1549 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),100.751, 2) |
---|
1550 | |
---|
1551 | def testEval_1D(self): |
---|
1552 | """ Test 1D model for a Lorentz Model with evalDistribution""" |
---|
1553 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1554 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1555 | |
---|
1556 | def testEval_2D(self): |
---|
1557 | """ Test 2D model for a Lorentz Model with evalDistribution""" |
---|
1558 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1559 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1560 | |
---|
1561 | |
---|
1562 | def testCriticalPoint(self): |
---|
1563 | """ Test Lorentz at the critical point""" |
---|
1564 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1565 | |
---|
1566 | |
---|
1567 | class TestPowerLawAbsModel(unittest.TestCase): |
---|
1568 | """ Unit tests for PowerLawAbsModel""" |
---|
1569 | |
---|
1570 | def setUp(self): |
---|
1571 | from sans.models.PowerLawAbsModel import PowerLawAbsModel |
---|
1572 | self.comp = PowerLawAbsModel() |
---|
1573 | self.comp.setParam("background",1) |
---|
1574 | self.comp.setParam("m",4) |
---|
1575 | self.comp.setParam("scale",1e-6) |
---|
1576 | |
---|
1577 | self.x = numpy.array([0.4, 1.3]) |
---|
1578 | self.y = numpy.array([0.5, 1.57]) |
---|
1579 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1580 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1581 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1582 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1583 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1584 | |
---|
1585 | def test1D(self): |
---|
1586 | """ Test 1D model for a PowerLawAbs Model""" |
---|
1587 | self.assertAlmostEqual(self.comp.run(0.19189), 1.00074,4) |
---|
1588 | |
---|
1589 | def test1D_2(self): |
---|
1590 | """ Test 2D model for a PowerLawAbs Model""" |
---|
1591 | self.assertAlmostEqual(self.comp.run([0.19189,1.3]), 1.00074,4) |
---|
1592 | |
---|
1593 | def testEval_1D(self): |
---|
1594 | """ Test 1D model for a PowerLawAbs Model with evalDistribution""" |
---|
1595 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1596 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1597 | |
---|
1598 | def testEval_2D(self): |
---|
1599 | """ Test 2D model for a PowerLawAbs Model with evalDistribution""" |
---|
1600 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1601 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1602 | |
---|
1603 | |
---|
1604 | def testCriticalPoint(self): |
---|
1605 | """ Test PowerLawAbs at the critical point""" |
---|
1606 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1607 | |
---|
1608 | |
---|
1609 | class TestPowerLawModel(unittest.TestCase): |
---|
1610 | """ Unit tests for PowerLawModel""" |
---|
1611 | |
---|
1612 | def setUp(self): |
---|
1613 | from sans.models.PowerLawModel import PowerLawModel |
---|
1614 | self.comp = PowerLawModel() |
---|
1615 | self.comp.setParam("background",1) |
---|
1616 | self.comp.setParam("m",4) |
---|
1617 | self.comp.setParam("scale",1e-6) |
---|
1618 | |
---|
1619 | self.x = numpy.array([0.4, 1.3]) |
---|
1620 | self.y = numpy.array([0.5, 1.57]) |
---|
1621 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1622 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1623 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1624 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1625 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1626 | |
---|
1627 | def test1D(self): |
---|
1628 | """ Test 1D model for a PowerLaw Model""" |
---|
1629 | self.assertAlmostEquals(self.comp.run(0.19189), 1.00074,4) |
---|
1630 | |
---|
1631 | def test1D_2(self): |
---|
1632 | """ Test 2D model for a PowerLawModel""" |
---|
1633 | self.assertAlmostEquals(self.comp.run([0.19189,1.3]), 1.00074,4) |
---|
1634 | |
---|
1635 | def testEval_1D(self): |
---|
1636 | """ Test 1D model for a PowerLawModel with evalDistribution""" |
---|
1637 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1638 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1639 | |
---|
1640 | def testEval_2D(self): |
---|
1641 | """ Test 2D model for a PowerLawModel with evalDistribution""" |
---|
1642 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1643 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1644 | |
---|
1645 | |
---|
1646 | def testCriticalPoint(self): |
---|
1647 | """ Test PowerLawModel at the critical point""" |
---|
1648 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1649 | |
---|
1650 | |
---|
1651 | class TestTeubnerStreyModel(unittest.TestCase): |
---|
1652 | """ Unit tests for TeubnerStreyModel""" |
---|
1653 | |
---|
1654 | def setUp(self): |
---|
1655 | from sans.models.TeubnerStreyModel import TeubnerStreyModel |
---|
1656 | self.comp = TeubnerStreyModel() |
---|
1657 | self.comp.setParam("background",0.1) |
---|
1658 | self.comp.setParam("c1",-30) |
---|
1659 | self.comp.setParam("c2",5000) |
---|
1660 | self.comp.setParam("scale",0.1) |
---|
1661 | |
---|
1662 | self.x = numpy.array([0.4, 1.3]) |
---|
1663 | self.y = numpy.array([0.5, 1.57]) |
---|
1664 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1665 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1666 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1667 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1668 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1669 | |
---|
1670 | def test1D(self): |
---|
1671 | """ Test 1D model for a TeubnerStrey Model""" |
---|
1672 | self.assertAlmostEqual(self.comp.run(0.001),10.103, 1) |
---|
1673 | |
---|
1674 | def test1D_2(self): |
---|
1675 | """ Test 2D model for a TeubnerStrey Model""" |
---|
1676 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),10.103, 1) |
---|
1677 | |
---|
1678 | def testEval_1D(self): |
---|
1679 | """ Test 1D model for a TeubnerStrey with evalDistribution""" |
---|
1680 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1681 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1682 | |
---|
1683 | def testEval_2D(self): |
---|
1684 | """ Test 2D model for a TeubnerStrey with evalDistribution""" |
---|
1685 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1686 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1687 | |
---|
1688 | |
---|
1689 | def testCriticalPoint(self): |
---|
1690 | """ Test TeubnerStrey at the critical point""" |
---|
1691 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1692 | |
---|
1693 | |
---|
1694 | class TestLineModel(unittest.TestCase): |
---|
1695 | """ Unit tests for LineModel""" |
---|
1696 | |
---|
1697 | def setUp(self): |
---|
1698 | from sans.models.LineModel import LineModel |
---|
1699 | self.comp = LineModel() |
---|
1700 | self.comp.setParam("A",1) |
---|
1701 | self.comp.setParam("B",1) |
---|
1702 | |
---|
1703 | self.x = numpy.array([0.4, 1.3]) |
---|
1704 | self.y = numpy.array([0.5, 1.57]) |
---|
1705 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1706 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1707 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1708 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1709 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1710 | |
---|
1711 | def test1D(self): |
---|
1712 | """ Test 1D model for a Line Model""" |
---|
1713 | self.assertEquals(self.comp.run(1.0),2) |
---|
1714 | |
---|
1715 | def testEval_1D(self): |
---|
1716 | """ Test 1D model for a Line with evalDistribution""" |
---|
1717 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1718 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1719 | |
---|
1720 | def testEval_2D(self): |
---|
1721 | """ Test 2D model for a Line with evalDistribution""" |
---|
1722 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0], 8) |
---|
1723 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1724 | |
---|
1725 | |
---|
1726 | def testCriticalPoint(self): |
---|
1727 | """ Test line at the critical point""" |
---|
1728 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1729 | |
---|
1730 | class TestMassFractalModel(unittest.TestCase): |
---|
1731 | """ Unit tests for MassFractalModel: Need to verify the test value""" |
---|
1732 | |
---|
1733 | def setUp(self): |
---|
1734 | from sans.models.MassFractalModel import MassFractalModel |
---|
1735 | self.comp = MassFractalModel() |
---|
1736 | |
---|
1737 | def testEval_1D(self): |
---|
1738 | """ Test 1D model for a MassFractalModel""" |
---|
1739 | self.assertAlmostEquals(self.comp.run(0.05), 279.59322, 4) |
---|
1740 | |
---|
1741 | class TestSurfaceFractalModel(unittest.TestCase): |
---|
1742 | """ Unit tests for SurfaceFractalModel: Need to verify the test value""" |
---|
1743 | |
---|
1744 | def setUp(self): |
---|
1745 | from sans.models.SurfaceFractalModel import SurfaceFractalModel |
---|
1746 | self.comp = SurfaceFractalModel() |
---|
1747 | |
---|
1748 | def testEval_1D(self): |
---|
1749 | """ Test 1D model for a SurfaceFractal""" |
---|
1750 | self.assertAlmostEquals(self.comp.run(0.05), 301428.65916, 4) |
---|
1751 | |
---|
1752 | class TestMassSurfaceFractal(unittest.TestCase): |
---|
1753 | """ Unit tests for MassSurfaceFractal: Need to verify the test value""" |
---|
1754 | |
---|
1755 | def setUp(self): |
---|
1756 | from sans.models.MassSurfaceFractal import MassSurfaceFractal |
---|
1757 | self.comp = MassSurfaceFractal() |
---|
1758 | |
---|
1759 | def testEval_1D(self): |
---|
1760 | """ Test 1D model for a MassSurfaceFractal""" |
---|
1761 | self.assertAlmostEquals(self.comp.run(0.05), 1.77537e-05, 4) |
---|
1762 | |
---|
1763 | if __name__ == '__main__': |
---|
1764 | unittest.main() |
---|