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 | |
---|
381 | class TestStackedDisksModel(unittest.TestCase): |
---|
382 | """ Unit tests for StackedDisks Model""" |
---|
383 | |
---|
384 | def setUp(self): |
---|
385 | from sans.models.StackedDisksModel import StackedDisksModel |
---|
386 | self.comp = StackedDisksModel() |
---|
387 | #Give initial value to model |
---|
388 | self.comp.setParam("scale", 0.01 ) |
---|
389 | self.comp.setParam("radius",3000.0 ) |
---|
390 | self.comp.setParam("core_thick", 10.0) |
---|
391 | self.comp.setParam("layer_thick",15.0 ) |
---|
392 | self.comp.setParam("core_sld",4e-006 ) |
---|
393 | self.comp.setParam("layer_sld",-4e-007 ) |
---|
394 | self.comp.setParam("solvent_sld", 5e-006 ) |
---|
395 | self.comp.setParam("n_stacking",1.0 ) |
---|
396 | self.comp.setParam("sigma_d", 0.0) |
---|
397 | self.comp.setParam("background",0.001) |
---|
398 | self.comp.setParam("axis_theta", 0.0 ) |
---|
399 | self.comp.setParam("axis_phi",0.0) |
---|
400 | |
---|
401 | self.x = numpy.array([0.4, 1.3]) |
---|
402 | self.y = numpy.array([0.5, 1.57]) |
---|
403 | self.x_array = self.comp.evalDistribution(self.x) |
---|
404 | self.y_array = self.comp.evalDistribution(self.y) |
---|
405 | |
---|
406 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
407 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
408 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
409 | |
---|
410 | self.q = 0.001 |
---|
411 | self.phi= math.pi/2 |
---|
412 | self.qx= self.q*math.cos(self.phi) |
---|
413 | self.qy= self.q*math.sin(self.phi) |
---|
414 | |
---|
415 | def test1D(self): |
---|
416 | """ Test 1D model for a StackedDisks Model""" |
---|
417 | self.assertAlmostEqual(self.comp.run(0.001), 5075.12, 1) |
---|
418 | |
---|
419 | def test1D_2(self): |
---|
420 | """ Test 2D model for a StackedDisks Model""" |
---|
421 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
422 | self.comp.runXY([self.qx, self.qy]),1) |
---|
423 | |
---|
424 | def testEval_1D(self): |
---|
425 | """ Test 1D model for a StackedDisks Model with evalDistribution""" |
---|
426 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
427 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
428 | |
---|
429 | def testEval_2D(self): |
---|
430 | """ Test 2D model for a StackedDisks Model with evalDistribution""" |
---|
431 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
432 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
433 | |
---|
434 | # No more singular point |
---|
435 | #def testCriticalPoint(self): |
---|
436 | # """ Test StackedDisks at the critical point""" |
---|
437 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
438 | |
---|
439 | |
---|
440 | class TestParallelepipedModel(unittest.TestCase): |
---|
441 | """ Unit tests for Parallelepiped Model""" |
---|
442 | |
---|
443 | def setUp(self): |
---|
444 | from sans.models.ParallelepipedModel import ParallelepipedModel |
---|
445 | self.comp = ParallelepipedModel() |
---|
446 | #Give initial value to model |
---|
447 | self.comp.setParam("background", 0.0 ) |
---|
448 | self.comp.setParam("short_a",35) |
---|
449 | self.comp.setParam("short_b", 75) |
---|
450 | self.comp.setParam("long_c",400 ) |
---|
451 | self.comp.setParam("sldPipe", 6.3e-006 ) |
---|
452 | self.comp.setParam("sldSolv", 1e-006 ) |
---|
453 | self.comp.setParam("scale",1.0 ) |
---|
454 | |
---|
455 | self.x = numpy.array([0.4, 1.3]) |
---|
456 | self.y = numpy.array([0.5, 1.57]) |
---|
457 | self.x_array = self.comp.evalDistribution(self.x) |
---|
458 | self.y_array = self.comp.evalDistribution(self.y) |
---|
459 | |
---|
460 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
461 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
462 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
463 | |
---|
464 | self.q = 0.001 |
---|
465 | self.phi= math.pi/2 |
---|
466 | self.qx= self.q*math.cos(self.phi) |
---|
467 | self.qy= self.q*math.sin(self.phi) |
---|
468 | |
---|
469 | |
---|
470 | def test1D(self): |
---|
471 | """ Test 1D model for a Parallelepiped Model""" |
---|
472 | self.assertAlmostEqual(self.comp.run(0.001), 2935.82, 2) |
---|
473 | |
---|
474 | def test1D_2(self): |
---|
475 | """ Test 2D model for a Parallelepiped Model""" |
---|
476 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
477 | self.comp.runXY([self.qx, self.qy]),1) |
---|
478 | |
---|
479 | def testEval_1D(self): |
---|
480 | """ Test 1D model for a Parallelepiped Model with evalDistribution""" |
---|
481 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
482 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
483 | |
---|
484 | def testEval_2D(self): |
---|
485 | """ Test 2D model for a Parallelepiped Model with evalDistribution""" |
---|
486 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
487 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
488 | |
---|
489 | |
---|
490 | def testCriticalPoint(self): |
---|
491 | """ Test Parallelepiped at the critical point""" |
---|
492 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
493 | |
---|
494 | class TestEllipticalCylinderModel(unittest.TestCase): |
---|
495 | """ Unit tests for EllipticalCylinder Model""" |
---|
496 | |
---|
497 | def setUp(self): |
---|
498 | from sans.models.EllipticalCylinderModel import EllipticalCylinderModel |
---|
499 | self.comp = EllipticalCylinderModel() |
---|
500 | self.comp.setParam("scale",1.0) |
---|
501 | self.comp.setParam("r_minor",20.0) |
---|
502 | self.comp.setParam("r_ratio",1.5) |
---|
503 | self.comp.setParam("length",400.0) |
---|
504 | self.comp.setParam("sldCyl",4e-006) |
---|
505 | self.comp.setParam("sldSolv",1e-006) |
---|
506 | self.comp.setParam("background",0.0) |
---|
507 | self.comp.setParam("cyl_theta",0.0) |
---|
508 | self.comp.setParam("cyl_phi",0.0) |
---|
509 | self.comp.setParam("cyl_psi",0.0) |
---|
510 | |
---|
511 | self.x = numpy.array([0.4, 1.3]) |
---|
512 | self.y = numpy.array([0.5, 1.57]) |
---|
513 | self.x_array = self.comp.evalDistribution(self.x) |
---|
514 | self.y_array = self.comp.evalDistribution(self.y) |
---|
515 | |
---|
516 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
517 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
518 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
519 | |
---|
520 | self.q = 0.001 |
---|
521 | self.phi= math.pi/2 |
---|
522 | self.qx= self.q*math.cos(self.phi) |
---|
523 | self.qy= self.q*math.sin(self.phi) |
---|
524 | |
---|
525 | def test1D(self): |
---|
526 | """ Test 1D model for a EllipticalCylinder Model""" |
---|
527 | self.assertAlmostEqual(self.comp.run(0.001), 675.504402, 4) |
---|
528 | |
---|
529 | def test1D_2(self): |
---|
530 | """ Test 2D model for a EllipticalCylinder Model""" |
---|
531 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
532 | self.comp.runXY([self.qx, self.qy]),1) |
---|
533 | |
---|
534 | def testEval_1D(self): |
---|
535 | """ Test 1D model for a EllipticalCylinder with evalDistribution""" |
---|
536 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
537 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
538 | |
---|
539 | def testEval_2D(self): |
---|
540 | """ Test 2D model for a EllipticalCylinder with evalDistribution""" |
---|
541 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
542 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
543 | |
---|
544 | |
---|
545 | def testCriticalPoint(self): |
---|
546 | """ Test EllipticalCylinder at the critical point""" |
---|
547 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
548 | |
---|
549 | |
---|
550 | class TestEllipsoidModel(unittest.TestCase): |
---|
551 | """ Unit tests for Ellipsoid Model""" |
---|
552 | |
---|
553 | def setUp(self): |
---|
554 | from sans.models.EllipsoidModel import EllipsoidModel |
---|
555 | self.comp = EllipsoidModel() |
---|
556 | self.comp.setParam("scale",1.0) |
---|
557 | self.comp.setParam("radius_a",20.0) |
---|
558 | self.comp.setParam("radius_b",400.0) |
---|
559 | self.comp.setParam("sldEll",4e-006) |
---|
560 | self.comp.setParam("sldSolv",1e-006) |
---|
561 | self.comp.setParam("background",0.0) |
---|
562 | self.comp.setParam("axis_theta",1.57) |
---|
563 | self.comp.setParam("axis_phi",0.0) |
---|
564 | |
---|
565 | self.x = numpy.array([0.4, 1.3]) |
---|
566 | self.y = numpy.array([0.5, 1.57]) |
---|
567 | self.x_array = self.comp.evalDistribution(self.x) |
---|
568 | self.y_array = self.comp.evalDistribution(self.y) |
---|
569 | |
---|
570 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
571 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
572 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
573 | |
---|
574 | self.q = 0.001 |
---|
575 | self.phi= math.pi/2 |
---|
576 | self.qx= self.q*math.cos(self.phi) |
---|
577 | self.qy= self.q*math.sin(self.phi) |
---|
578 | |
---|
579 | def test1D(self): |
---|
580 | """ Test 1D model for a Ellipsoid Model""" |
---|
581 | self.assertAlmostEqual(self.comp.run(1.0), 0.000733968, 4) |
---|
582 | |
---|
583 | def test1D_2(self): |
---|
584 | """ Test 2D model for a Ellipsoid Model""" |
---|
585 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
586 | self.comp.runXY([self.qx, self.qy]),1) |
---|
587 | def testEval_1D(self): |
---|
588 | """ Test 1D model for a Ellipsoid Model with evalDistribution""" |
---|
589 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
590 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
591 | |
---|
592 | def testEval_2D(self): |
---|
593 | """ Test 2D model for a Ellipsoid Model with evalDistribution""" |
---|
594 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
595 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
596 | |
---|
597 | |
---|
598 | def testCriticalPoint(self): |
---|
599 | """ Test Ellipsoid at the critical point""" |
---|
600 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
601 | |
---|
602 | class TestCoreShellEllipsoidModel(unittest.TestCase): |
---|
603 | """ Unit tests for CoreShellEllipsoid Model""" |
---|
604 | |
---|
605 | def setUp(self): |
---|
606 | from sans.models.CoreShellEllipsoidModel import CoreShellEllipsoidModel |
---|
607 | self.comp = CoreShellEllipsoidModel() |
---|
608 | #Give initial value to model |
---|
609 | self.comp.setParam("scale", 1.0) |
---|
610 | self.comp.setParam("equat_core", 200.0) |
---|
611 | self.comp.setParam("polar_core", 20.0) |
---|
612 | self.comp.setParam("equat_shell",250.0) |
---|
613 | self.comp.setParam("polar_shell", 30.0) |
---|
614 | self.comp.setParam("sld_shell",1e-006) |
---|
615 | self.comp.setParam("sld_core",2e-006) |
---|
616 | self.comp.setParam("sld_solvent",6.3e-006) |
---|
617 | self.comp.setParam("background",0.001) |
---|
618 | self.comp.setParam("axis_theta", 0.0) |
---|
619 | self.comp.setParam("axis_phi",0.0) |
---|
620 | |
---|
621 | self.x = numpy.array([0.4, 1.3]) |
---|
622 | self.y = numpy.array([0.5, 1.57]) |
---|
623 | self.x_array = self.comp.evalDistribution(self.x) |
---|
624 | self.y_array = self.comp.evalDistribution(self.y) |
---|
625 | |
---|
626 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
627 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
628 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
629 | |
---|
630 | self.q = 0.001 |
---|
631 | self.phi= math.pi/2 |
---|
632 | self.qx= self.q*math.cos(self.phi) |
---|
633 | self.qy= self.q*math.sin(self.phi) |
---|
634 | |
---|
635 | def test1D(self): |
---|
636 | """ Test 1D model for a CoreShellEllipsoid Model""" |
---|
637 | self.assertAlmostEqual(self.comp.run(1.0), 0.001894, 4) |
---|
638 | |
---|
639 | def test1D_2(self): |
---|
640 | """ Test 2D model for a CoreShellEllipsoid Model""" |
---|
641 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
642 | self.comp.runXY([self.qx, self.qy]),1) |
---|
643 | |
---|
644 | def testEval_1D(self): |
---|
645 | """ Test 1D model for a CoreShellEllipsoid with evalDistribution""" |
---|
646 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
647 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
648 | |
---|
649 | def testEval_2D(self): |
---|
650 | """ Test 2D model for a CoreShellEllipsoid with evalDistribution""" |
---|
651 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
652 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
653 | |
---|
654 | |
---|
655 | def testCriticalPoint(self): |
---|
656 | """ Test CoreShellEllipsoid at the critical point""" |
---|
657 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
658 | |
---|
659 | class TestTriaxialEllipsoidModel(unittest.TestCase): |
---|
660 | """ Unit tests for TriaxialEllipsoid Model""" |
---|
661 | |
---|
662 | def setUp(self): |
---|
663 | from sans.models.TriaxialEllipsoidModel import TriaxialEllipsoidModel |
---|
664 | self.comp = TriaxialEllipsoidModel() |
---|
665 | self.comp.setParam("scale",1.0) |
---|
666 | self.comp.setParam("semi_axisA",35.0) |
---|
667 | self.comp.setParam("semi_axisB", 100.0) |
---|
668 | self.comp.setParam("semi_axisC",400.0 ) |
---|
669 | self.comp.setParam("sldSolv",6.3e-6) |
---|
670 | self.comp.setParam("sldEll",1e-6) |
---|
671 | self.comp.setParam("background",0.0) |
---|
672 | self.comp.setParam("axis_theta", 1.0) |
---|
673 | self.comp.setParam("axis_phi",0.0 ) |
---|
674 | self.comp.setParam("axis_psi",0.0 ) |
---|
675 | |
---|
676 | self.x = numpy.array([0.4, 1.3]) |
---|
677 | self.y = numpy.array([0.5, 1.57]) |
---|
678 | |
---|
679 | self.x_array = self.comp.evalDistribution(self.x) |
---|
680 | self.y_array = self.comp.evalDistribution(self.y) |
---|
681 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
682 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
683 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
684 | |
---|
685 | self.q = 0.001 |
---|
686 | self.phi= math.pi/2 |
---|
687 | self.qx= self.q*math.cos(self.phi) |
---|
688 | self.qy= self.q*math.sin(self.phi) |
---|
689 | |
---|
690 | |
---|
691 | def test1D(self): |
---|
692 | """ Test 1D model for a TriaxialEllipsoid Model""" |
---|
693 | self.assertAlmostEquals(self.comp.run(0.001),16285.6, 1) |
---|
694 | |
---|
695 | def test1D_2(self): |
---|
696 | """ Test 2D model for a TriaxialEllipsoid Model""" |
---|
697 | self.assertAlmostEqual(self.comp.run([self.q, self.phi]), |
---|
698 | self.comp.runXY([self.qx, self.qy]),1) |
---|
699 | |
---|
700 | def testEval_1D(self): |
---|
701 | """ Test 1D model for a TriaxialEllipsoid Model with evalDistribution""" |
---|
702 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
703 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
704 | |
---|
705 | def testEval_2D(self): |
---|
706 | """ Test 2D model for a TriaxialEllipsoid Model with evalDistribution""" |
---|
707 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
708 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
709 | |
---|
710 | |
---|
711 | def testCriticalPoint(self): |
---|
712 | """ Test TriaxialEllipsoid at the critical point""" |
---|
713 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
714 | |
---|
715 | class TestLamellarModel(unittest.TestCase): |
---|
716 | """ Unit tests for Lamellar Model""" |
---|
717 | |
---|
718 | def setUp(self): |
---|
719 | from sans.models.LamellarModel import LamellarModel |
---|
720 | self.comp = LamellarModel() |
---|
721 | self.comp.setParam("scale",1.0) |
---|
722 | self.comp.setParam("bi_thick",50.0) |
---|
723 | self.comp.setParam("sld_bi",1e-006) |
---|
724 | self.comp.setParam("sld_sol",6.3e-006) |
---|
725 | self.comp.setParam("background",0.0) |
---|
726 | |
---|
727 | self.x = numpy.array([0.4, 1.3]) |
---|
728 | self.y = numpy.array([0.5, 1.57]) |
---|
729 | |
---|
730 | self.x_array = self.comp.evalDistribution(self.x) |
---|
731 | self.y_array = self.comp.evalDistribution(self.y) |
---|
732 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
733 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
734 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
735 | |
---|
736 | def test1D(self): |
---|
737 | """ Test 1D model for a Lamellar Model""" |
---|
738 | self.assertAlmostEquals(self.comp.run(0.001), 882289.54309, 3) |
---|
739 | |
---|
740 | def test1D_2(self): |
---|
741 | """ Test 2D model for a Lamellar Model""" |
---|
742 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),882289.54309, 3) |
---|
743 | |
---|
744 | def testEval_1D(self): |
---|
745 | """ Test 1D model for a Lamellar Model with evalDistribution""" |
---|
746 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
747 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
748 | |
---|
749 | def testEval_2D(self): |
---|
750 | """ Test 2D model for a Lamellar Model with evalDistribution""" |
---|
751 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
752 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
753 | |
---|
754 | # No more singular point |
---|
755 | #def testCriticalPoint(self): |
---|
756 | # """ Test Lamellar at the critical point""" |
---|
757 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
758 | |
---|
759 | class TestLamellarFFHGModel(unittest.TestCase): |
---|
760 | """ Unit tests for LamellarFFHG Model""" |
---|
761 | |
---|
762 | def setUp(self): |
---|
763 | from sans.models.LamellarFFHGModel import LamellarFFHGModel |
---|
764 | self.comp = LamellarFFHGModel() |
---|
765 | self.comp.setParam("scale",1.0) |
---|
766 | self.comp.setParam("t_length",15.0) |
---|
767 | self.comp.setParam("h_thickness",10.0) |
---|
768 | self.comp.setParam("sld_tail",4e-007) |
---|
769 | self.comp.setParam("sld_head",3e-006) |
---|
770 | self.comp.setParam("sld_solvent",6e-006) |
---|
771 | self.comp.setParam("background",0.0) |
---|
772 | |
---|
773 | self.x = numpy.array([0.4, 1.3]) |
---|
774 | self.y = numpy.array([0.5, 1.57]) |
---|
775 | |
---|
776 | self.x_array = self.comp.evalDistribution(self.x) |
---|
777 | self.y_array = self.comp.evalDistribution(self.y) |
---|
778 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
779 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
780 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
781 | |
---|
782 | |
---|
783 | def test1D(self): |
---|
784 | """ Test 1D model for a LamellarFFHG Model""" |
---|
785 | self.assertAlmostEquals(self.comp.run(0.001),653143.9209, 3) |
---|
786 | |
---|
787 | def test1D_2(self): |
---|
788 | """ Test 2D model for a LamellarFFHG Model""" |
---|
789 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),653143.9209, 3) |
---|
790 | |
---|
791 | def testEval_1D(self): |
---|
792 | """ Test 1D model for a LamellarFFHG Model with evalDistribution""" |
---|
793 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
794 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
795 | |
---|
796 | def testEval_2D(self): |
---|
797 | """ Test 2D model for a LamellarFFHG Model with evalDistribution""" |
---|
798 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
799 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
800 | |
---|
801 | # No more singular point |
---|
802 | #def testCriticalPoint(self): |
---|
803 | # """ Test LamellarFFHG at the critical point""" |
---|
804 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
805 | |
---|
806 | class TestLamellarPSModel(unittest.TestCase): |
---|
807 | """ Unit tests for LamellarPS Model""" |
---|
808 | |
---|
809 | def setUp(self): |
---|
810 | from sans.models.LamellarPSModel import LamellarPSModel |
---|
811 | self.comp = LamellarPSModel() |
---|
812 | self.comp.setParam("scale",1.0) |
---|
813 | self.comp.setParam("spacing",400.0) |
---|
814 | self.comp.setParam("delta",30.0) |
---|
815 | self.comp.setParam("sld_bi",6.3e-006) |
---|
816 | self.comp.setParam("sld_sol",1e-006) |
---|
817 | self.comp.setParam("n_plates",20.0) |
---|
818 | self.comp.setParam("caille", 0.1) |
---|
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 LamellarPS Model""" |
---|
833 | self.assertAlmostEquals(self.comp.run(0.001), 27899.30836, 1) |
---|
834 | |
---|
835 | def test1D_2(self): |
---|
836 | """ Test 2D model for a LamellarPS Model""" |
---|
837 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),27899.30836, 1) |
---|
838 | |
---|
839 | def testEval_1D(self): |
---|
840 | """ Test 1D model for a LamellarPS 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 LamellarPS 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 LamellarPS at the critical point""" |
---|
852 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
853 | |
---|
854 | class TestLamellarPSHGModel(unittest.TestCase): |
---|
855 | """ Unit tests for LamellarPSHG Model""" |
---|
856 | |
---|
857 | def setUp(self): |
---|
858 | from sans.models.LamellarPSHGModel import LamellarPSHGModel |
---|
859 | self.comp = LamellarPSHGModel() |
---|
860 | self.comp.setParam("scale",1.0) |
---|
861 | self.comp.setParam("spacing",40.0) |
---|
862 | self.comp.setParam("deltaT",10.0) |
---|
863 | self.comp.setParam("deltaH",2.0) |
---|
864 | self.comp.setParam("sld_tail",4e-7) |
---|
865 | self.comp.setParam("sld_head",2e-6) |
---|
866 | self.comp.setParam("sld_solvent",6e-6) |
---|
867 | self.comp.setParam("n_plates",30) |
---|
868 | self.comp.setParam("caille",0.001) |
---|
869 | self.comp.setParam("background",0.001) |
---|
870 | |
---|
871 | self.x = numpy.array([0.4, 1.3]) |
---|
872 | self.y = numpy.array([0.5, 1.57]) |
---|
873 | |
---|
874 | self.x_array = self.comp.evalDistribution(self.x) |
---|
875 | self.y_array = self.comp.evalDistribution(self.y) |
---|
876 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
877 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
878 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
879 | |
---|
880 | def test1D(self): |
---|
881 | """ Test 1D model for a LamellarPSHG Model""" |
---|
882 | self.assertAlmostEquals(self.comp.run(0.001),6831387.29466, 3) |
---|
883 | |
---|
884 | def test1D_2(self): |
---|
885 | """ Test 2D model for a LamellarPSHG Model""" |
---|
886 | self.assertAlmostEquals(self.comp.run([0.001, 1.3]),6831387.29466,3) |
---|
887 | |
---|
888 | def testEval_1D(self): |
---|
889 | """ Test 1D model for a LamellarPSHG Model with evalDistribution""" |
---|
890 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
891 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
892 | |
---|
893 | def testEval_2D(self): |
---|
894 | """ Test 2D model for a LamellarPSHG Model with evalDistribution""" |
---|
895 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
896 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
897 | |
---|
898 | # No more singular point |
---|
899 | #def testCriticalPoint(self): |
---|
900 | # """ Test LamellarPSHG at the critical point""" |
---|
901 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
902 | |
---|
903 | class TestSquareWellStructure(unittest.TestCase): |
---|
904 | """ Unit tests for SquareWellStructure """ |
---|
905 | |
---|
906 | def setUp(self): |
---|
907 | from sans.models.SquareWellStructure import SquareWellStructure |
---|
908 | self.comp = SquareWellStructure() |
---|
909 | self.comp.setParam("effect_radius",50.0) |
---|
910 | self.comp.setParam("volfraction",0.04) |
---|
911 | self.comp.setParam("welldepth",1.5 ) |
---|
912 | self.comp.setParam("wellwidth",1.2) |
---|
913 | |
---|
914 | self.x = numpy.array([0.4, 1.3]) |
---|
915 | self.y = numpy.array([0.5, 1.57]) |
---|
916 | |
---|
917 | self.x_array = self.comp.evalDistribution(self.x) |
---|
918 | self.y_array = self.comp.evalDistribution(self.y) |
---|
919 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
920 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
921 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
922 | |
---|
923 | |
---|
924 | def test1D(self): |
---|
925 | """ Test 1D model for a SquareWellStructure""" |
---|
926 | self.assertAlmostEqual(self.comp.run(0.001), 0.976657, 2) |
---|
927 | |
---|
928 | def test1D_2(self): |
---|
929 | """ Test 2D model for a SquareWellStructure""" |
---|
930 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.9776657,2) |
---|
931 | |
---|
932 | def testEval_1D(self): |
---|
933 | """ Test 1D model for a SquareWellStructure with evalDistribution""" |
---|
934 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
935 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
936 | |
---|
937 | def testEval_2D(self): |
---|
938 | """ Test 2D model for a SquareWellStructure with evalDistribution""" |
---|
939 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
940 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
941 | |
---|
942 | # No more singular point |
---|
943 | #def testCriticalPoint(self): |
---|
944 | # """ Test SquareWellStructure at the critical point""" |
---|
945 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
946 | |
---|
947 | class TestHardsphereStructure(unittest.TestCase): |
---|
948 | """ Unit tests for HardsphereStructure""" |
---|
949 | |
---|
950 | def setUp(self): |
---|
951 | from sans.models.HardsphereStructure import HardsphereStructure |
---|
952 | self.comp = HardsphereStructure() |
---|
953 | self.comp.setParam("effect_radius",50.0) |
---|
954 | self.comp.setParam("volfraction", 0.2) |
---|
955 | self.x = numpy.array([0.4, 1.3]) |
---|
956 | self.y = numpy.array([0.5, 1.57]) |
---|
957 | |
---|
958 | self.x_array = self.comp.evalDistribution(self.x) |
---|
959 | self.y_array = self.comp.evalDistribution(self.y) |
---|
960 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
961 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
962 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
963 | |
---|
964 | |
---|
965 | def test1D(self): |
---|
966 | """ Test 1D model for a HardsphereStructure""" |
---|
967 | self.assertAlmostEqual(self.comp.run(0.001),0.209128, 4) |
---|
968 | |
---|
969 | def test1D_2(self): |
---|
970 | """ Test 2D model for a HardsphereStructure""" |
---|
971 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.209128, 4) |
---|
972 | |
---|
973 | def testEval_1D(self): |
---|
974 | """ Test 1D model for a HardsphereStructure with evalDistribution""" |
---|
975 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
976 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
977 | |
---|
978 | def testEval_2D(self): |
---|
979 | """ Test 2D model for a HardsphereStructure with evalDistribution""" |
---|
980 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
981 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
982 | |
---|
983 | # No more singular point |
---|
984 | #def testCriticalPoint(self): |
---|
985 | # """ Test HardsphereStructure at the critical point""" |
---|
986 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
987 | |
---|
988 | class TestStickyHSStructure(unittest.TestCase): |
---|
989 | """ Unit tests for StickyHSStructure""" |
---|
990 | |
---|
991 | def setUp(self): |
---|
992 | from sans.models.StickyHSStructure import StickyHSStructure |
---|
993 | self.comp = StickyHSStructure() |
---|
994 | self.comp.setParam("effect_radius",50.0) |
---|
995 | self.comp.setParam("volfraction",0.1) |
---|
996 | self.comp.setParam("perturb",0.05) |
---|
997 | self.comp.setParam("stickiness",0.2) |
---|
998 | |
---|
999 | self.x = numpy.array([0.4, 1.3]) |
---|
1000 | self.y = numpy.array([0.5, 1.57]) |
---|
1001 | |
---|
1002 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1003 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1004 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1005 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1006 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1007 | |
---|
1008 | def test1D(self): |
---|
1009 | """ Test 1D model for a StickyHSStructure""" |
---|
1010 | self.assertAlmostEqual(self.comp.run(0.001),1.09718, 4) |
---|
1011 | |
---|
1012 | def test1D_2(self): |
---|
1013 | """ Test 2D model for a StickyHSStructure""" |
---|
1014 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),1.09718, 4) |
---|
1015 | |
---|
1016 | def testEval_1D(self): |
---|
1017 | """ Test 1D model for a StickyHSStructure with evalDistribution""" |
---|
1018 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1019 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1020 | |
---|
1021 | def testEval_2D(self): |
---|
1022 | """ Test 2D model for a StickyHSStructure with evalDistribution""" |
---|
1023 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1024 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1025 | |
---|
1026 | # No more singular point |
---|
1027 | #def testCriticalPoint(self): |
---|
1028 | # """ Test StickyHSStructure at the critical point""" |
---|
1029 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1030 | |
---|
1031 | class TestHayterMSAStructure(unittest.TestCase): |
---|
1032 | """ Unit tests for HayterMSAStructure""" |
---|
1033 | |
---|
1034 | def setUp(self): |
---|
1035 | from sans.models.HayterMSAStructure import HayterMSAStructure |
---|
1036 | self.comp = HayterMSAStructure() |
---|
1037 | self.comp.setParam("effect_radius",20.75) |
---|
1038 | self.comp.setParam("charge",19.0) |
---|
1039 | self.comp.setParam("volfraction",0.0192 ) |
---|
1040 | self.comp.setParam("temperature",298) |
---|
1041 | self.comp.setParam("saltconc",0.0) |
---|
1042 | self.comp.setParam("dielectconst",78) |
---|
1043 | |
---|
1044 | self.x = numpy.array([0.4, 1.3]) |
---|
1045 | self.y = numpy.array([0.5, 1.57]) |
---|
1046 | |
---|
1047 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1048 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1049 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1050 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1051 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1052 | |
---|
1053 | def test1D(self): |
---|
1054 | """ Test 1D model for a HayterMSAStructure""" |
---|
1055 | self.assertAlmostEqual(self.comp.run(0.001),0.0712928, 4) |
---|
1056 | |
---|
1057 | def test1D_2(self): |
---|
1058 | """ Test 2D model for a HayterMSAStructure""" |
---|
1059 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.0712928, 4) |
---|
1060 | |
---|
1061 | def testEval_1D(self): |
---|
1062 | """ Test 1D model for a HayterMSAStructure with evalDistribution""" |
---|
1063 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1064 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1065 | |
---|
1066 | def testEval_2D(self): |
---|
1067 | """ Test 2D model for a HayterMSAStructure with evalDistribution""" |
---|
1068 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1069 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1070 | |
---|
1071 | |
---|
1072 | def testCriticalPoint(self): |
---|
1073 | """ Test HayterMSAStructure at the critical point""" |
---|
1074 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1075 | |
---|
1076 | |
---|
1077 | class TestBEPolyelectrolyte(unittest.TestCase): |
---|
1078 | """ Unit tests for BEPolyelectrolyte""" |
---|
1079 | |
---|
1080 | def setUp(self): |
---|
1081 | from sans.models.BEPolyelectrolyte import BEPolyelectrolyte |
---|
1082 | self.comp = BEPolyelectrolyte() |
---|
1083 | |
---|
1084 | self.comp.setParam('k',10) |
---|
1085 | self.comp.setParam('lb',7.1) |
---|
1086 | self.comp.setParam('h',12) |
---|
1087 | self.comp.setParam('b',10) |
---|
1088 | self.comp.setParam('cs', 0.0) |
---|
1089 | self.comp.setParam('alpha',0.05) |
---|
1090 | self.comp.setParam('c', 0.7) |
---|
1091 | self.comp.setParam('background',0.001) |
---|
1092 | |
---|
1093 | self.x = numpy.array([0.4, 1.3]) |
---|
1094 | self.y = numpy.array([0.5, 1.57]) |
---|
1095 | |
---|
1096 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1097 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1098 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1099 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1100 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1101 | |
---|
1102 | def test1D(self): |
---|
1103 | """ Test 1D model for a BEPolyelectrolyte""" |
---|
1104 | self.assertAlmostEqual(self.comp.run(0.001),0.0948, 3) |
---|
1105 | |
---|
1106 | def test1D_2(self): |
---|
1107 | """ Test 2D model for a BEPolyelectrolyte""" |
---|
1108 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),0.0948, 3) |
---|
1109 | |
---|
1110 | def testEval_1D(self): |
---|
1111 | """ Test 1D model for a BEPolyelectrolyte with evalDistribution""" |
---|
1112 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1113 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1114 | |
---|
1115 | def testEval_2D(self): |
---|
1116 | """ Test 2D model for a BEPolyelectrolyte with evalDistribution""" |
---|
1117 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1118 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1119 | |
---|
1120 | |
---|
1121 | def testCriticalPoint(self): |
---|
1122 | """ Test BEPolyelectrolyte at the critical point""" |
---|
1123 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1124 | |
---|
1125 | |
---|
1126 | class TestDABModel(unittest.TestCase): |
---|
1127 | """ Unit tests for DABModel""" |
---|
1128 | |
---|
1129 | def setUp(self): |
---|
1130 | from sans.models.DABModel import DABModel |
---|
1131 | self.comp = DABModel() |
---|
1132 | self.comp.setParam('length',40.0) |
---|
1133 | self.comp.setParam('scale',10.0) |
---|
1134 | self.comp.setParam('background',1.0) |
---|
1135 | |
---|
1136 | self.x = numpy.array([0.4, 1.3]) |
---|
1137 | self.y = numpy.array([0.5, 1.57]) |
---|
1138 | |
---|
1139 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1140 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1141 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1142 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1143 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1144 | |
---|
1145 | def test1D(self): |
---|
1146 | """ Test 1D model for a DABModel""" |
---|
1147 | self.assertAlmostEqual(self.comp.run(0.001),637957.9047, 3) |
---|
1148 | |
---|
1149 | def test1D_2(self): |
---|
1150 | """ Test 2D model for a DABModel""" |
---|
1151 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),637957.90473, 3) |
---|
1152 | |
---|
1153 | def testEval_1D(self): |
---|
1154 | """ Test 1D model for a DABModel with evalDistribution""" |
---|
1155 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1156 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1157 | |
---|
1158 | def testEval_2D(self): |
---|
1159 | """ Test 2D model for a DABModel with evalDistribution""" |
---|
1160 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1161 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1162 | |
---|
1163 | |
---|
1164 | def testCriticalPoint(self): |
---|
1165 | """ Test DABModel at the critical point""" |
---|
1166 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1167 | |
---|
1168 | |
---|
1169 | class TestGuinierModel(unittest.TestCase): |
---|
1170 | """ Unit tests for Guinier Model""" |
---|
1171 | |
---|
1172 | def setUp(self): |
---|
1173 | from sans.models.GuinierModel import GuinierModel |
---|
1174 | self.comp = GuinierModel() |
---|
1175 | self.comp.setParam('scale',1.0) |
---|
1176 | self.comp.setParam('rg', 1) |
---|
1177 | |
---|
1178 | self.x = numpy.array([0.4, 1.3]) |
---|
1179 | self.y = numpy.array([0.5, 1.57]) |
---|
1180 | |
---|
1181 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1182 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1183 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1184 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1185 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1186 | |
---|
1187 | def test1D(self): |
---|
1188 | """ Test 1D model for a GuinierModel""" |
---|
1189 | self.assertAlmostEqual(self.comp.run(1.0),0.716531, 4) |
---|
1190 | |
---|
1191 | def test1D_2(self): |
---|
1192 | """ Test 2D model for a GuinierModel""" |
---|
1193 | self.assertAlmostEqual(self.comp.run([1.0, 1.3]),0.716531, 4) |
---|
1194 | |
---|
1195 | def testEval_1D(self): |
---|
1196 | """ Test 1D model for a GuinierModel with evalDistribution""" |
---|
1197 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1198 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1199 | |
---|
1200 | def testEval_2D(self): |
---|
1201 | """ Test 2D model for a GuinierModel with evalDistribution""" |
---|
1202 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1203 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1204 | |
---|
1205 | |
---|
1206 | def testCriticalPoint(self): |
---|
1207 | """ Test GuinierModel at the critical point""" |
---|
1208 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1209 | |
---|
1210 | |
---|
1211 | class TestDebyeModel(unittest.TestCase): |
---|
1212 | """ Unit tests for Debye Model""" |
---|
1213 | |
---|
1214 | def setUp(self): |
---|
1215 | from sans.models.DebyeModel import DebyeModel |
---|
1216 | self.comp = DebyeModel() |
---|
1217 | self.comp.setParam('rg', 50.0) |
---|
1218 | self.comp.setParam('scale',1.0) |
---|
1219 | self.comp.setParam('background',0.001) |
---|
1220 | |
---|
1221 | self.x = numpy.array([0.4, 1.3]) |
---|
1222 | self.y = numpy.array([0.5, 1.57]) |
---|
1223 | |
---|
1224 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1225 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1226 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1227 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1228 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1229 | |
---|
1230 | def test1D(self): |
---|
1231 | """ Test 1D model for a DebyeModel""" |
---|
1232 | self.assertAlmostEqual(self.comp.run(0.001),1.00017,4) |
---|
1233 | |
---|
1234 | def test1D_2(self): |
---|
1235 | """ Test 2D model for a DebyeModel""" |
---|
1236 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),1.00017,4) |
---|
1237 | |
---|
1238 | def testEval_1D(self): |
---|
1239 | """ Test 1D model for a DebyeModel with evalDistribution""" |
---|
1240 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1241 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1242 | |
---|
1243 | def testEval_2D(self): |
---|
1244 | """ Test 2D model for a DebyeModel with evalDistribution""" |
---|
1245 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1246 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1247 | |
---|
1248 | |
---|
1249 | def testCriticalPoint(self): |
---|
1250 | """ Test DebyeModel at the critical point""" |
---|
1251 | self.assertEquals(self.comp.run(0.0),1.001) |
---|
1252 | |
---|
1253 | |
---|
1254 | class TestPorodModel(unittest.TestCase): |
---|
1255 | """ Unit tests for PorodModel""" |
---|
1256 | |
---|
1257 | def setUp(self): |
---|
1258 | from sans.models.PorodModel import PorodModel |
---|
1259 | self.comp = PorodModel() |
---|
1260 | self.comp.setParam('scale', 1.0) |
---|
1261 | self.comp.setParam('background', 0.0) |
---|
1262 | |
---|
1263 | self.x = numpy.array([0.4, 1.3]) |
---|
1264 | self.y = numpy.array([0.5, 1.57]) |
---|
1265 | |
---|
1266 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1267 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1268 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1269 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1270 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1271 | |
---|
1272 | def test1D(self): |
---|
1273 | """ Test 1D model for a PorodModel""" |
---|
1274 | self.assertEquals(self.comp.run(0.5), 16) |
---|
1275 | |
---|
1276 | def test1D_2(self): |
---|
1277 | """ Test 2D model for a PorodModel""" |
---|
1278 | self.assertEquals(self.comp.run([0.5, 1.3]),16) |
---|
1279 | |
---|
1280 | def testEval_1D(self): |
---|
1281 | """ Test 1D model for a PorodModel with evalDistribution""" |
---|
1282 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1283 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1284 | |
---|
1285 | def testEval_2D(self): |
---|
1286 | """ Test 2D model for a PorodModel with evalDistribution""" |
---|
1287 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1288 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1289 | |
---|
1290 | |
---|
1291 | def testCreaticalPoint(self): |
---|
1292 | """ Test for critical point for PorodModel run""" |
---|
1293 | self.assertRaises(ZeroDivisionError, self.comp.run, 0.0) |
---|
1294 | |
---|
1295 | |
---|
1296 | class TestPeakGaussModel(unittest.TestCase): |
---|
1297 | """ Unit tests for PeakGaussModel""" |
---|
1298 | |
---|
1299 | def setUp(self): |
---|
1300 | from sans.models.PeakGaussModel import PeakGaussModel |
---|
1301 | self.comp = PeakGaussModel() |
---|
1302 | self.comp.setParam('scale', 100) |
---|
1303 | self.comp.setParam('B', 0.005) |
---|
1304 | self.comp.setParam('q0',0.05) |
---|
1305 | self.comp.setParam('background',1.0) |
---|
1306 | |
---|
1307 | self.x = numpy.array([0.4, 1.3]) |
---|
1308 | self.y = numpy.array([0.5, 1.57]) |
---|
1309 | |
---|
1310 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1311 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1312 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1313 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1314 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1315 | |
---|
1316 | def test1D(self): |
---|
1317 | """ Test 1D model for a PeakGauss Model""" |
---|
1318 | self.assertEquals(self.comp.run(0.001),1) |
---|
1319 | |
---|
1320 | def test1D_2(self): |
---|
1321 | """ Test 2D model for a PeakGauss Model""" |
---|
1322 | self.assertEquals(self.comp.run([0.001, 1.3]),1) |
---|
1323 | |
---|
1324 | def testEval_1D(self): |
---|
1325 | """ Test 1D model for a PeakGauss Model with evalDistribution""" |
---|
1326 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1327 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1328 | |
---|
1329 | def testEval_2D(self): |
---|
1330 | """ Test 2D model for a PeakGauss Model with evalDistribution""" |
---|
1331 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1332 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1333 | |
---|
1334 | def testCriticalPoint(self): |
---|
1335 | """ Test PeakGauss at the critical point""" |
---|
1336 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1337 | |
---|
1338 | class TestPeakLorentzModel(unittest.TestCase): |
---|
1339 | """ Unit tests for PeakLorentzModel""" |
---|
1340 | |
---|
1341 | def setUp(self): |
---|
1342 | from sans.models.PeakLorentzModel import PeakLorentzModel |
---|
1343 | self.comp = PeakLorentzModel() |
---|
1344 | self.comp.setParam('scale', 100) |
---|
1345 | self.comp.setParam('B', 0.005) |
---|
1346 | self.comp.setParam('q0',0.05) |
---|
1347 | self.comp.setParam('background',1.0) |
---|
1348 | |
---|
1349 | self.x = numpy.array([0.4, 1.3]) |
---|
1350 | self.y = numpy.array([0.5, 1.57]) |
---|
1351 | |
---|
1352 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1353 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1354 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1355 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1356 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1357 | |
---|
1358 | def test1D(self): |
---|
1359 | """ Test 1D model for a PeakLorentz Model""" |
---|
1360 | self.assertAlmostEqual(self.comp.run(0.001), 2.0305, 3) |
---|
1361 | |
---|
1362 | def test1D_2(self): |
---|
1363 | """ Test 2D model for a PeakLorentz Model""" |
---|
1364 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 2.0305, 3) |
---|
1365 | |
---|
1366 | def testEval_1D(self): |
---|
1367 | """ Test 1D model for a PeakLorentz Model with evalDistribution""" |
---|
1368 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1369 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1370 | |
---|
1371 | def testEval_2D(self): |
---|
1372 | """ Test 2D model for a PeakLorentz Model with evalDistribution""" |
---|
1373 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1374 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1375 | |
---|
1376 | |
---|
1377 | def testCriticalPoint(self): |
---|
1378 | """ Test PeakLorentz at the critical point""" |
---|
1379 | self.comp.setParam('B', 0.0) |
---|
1380 | self.assertRaises(ZeroDivisionError, self.comp.run, 10) |
---|
1381 | #self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1382 | |
---|
1383 | |
---|
1384 | class TestFractalAbsModel(unittest.TestCase): |
---|
1385 | """ Unit tests for FractalAbsModel""" |
---|
1386 | |
---|
1387 | def setUp(self): |
---|
1388 | from sans.models.FractalAbsModel import FractalAbsModel |
---|
1389 | self.comp = FractalAbsModel() |
---|
1390 | self.comp.setParam('scale', 0.05) |
---|
1391 | self.comp.setParam('radius', 5.0) |
---|
1392 | self.comp.setParam('fractal_dim', 2.0) |
---|
1393 | self.comp.setParam('cor_length',100.0) |
---|
1394 | self.comp.setParam('sldBlock', 2.0e-6) |
---|
1395 | self.comp.setParam('sldSolv', 6.35e-6) |
---|
1396 | self.comp.setParam('background',0.0) |
---|
1397 | |
---|
1398 | self.x = numpy.array([0.4, 1.3]) |
---|
1399 | self.y = numpy.array([0.5, 1.57]) |
---|
1400 | |
---|
1401 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1402 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1403 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1404 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1405 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1406 | |
---|
1407 | def test1D(self): |
---|
1408 | """ Test 1D model for a Fractal Abs Model""" |
---|
1409 | self.assertAlmostEqual(self.comp.run(0.001), 39.2881, 3) |
---|
1410 | |
---|
1411 | def test1D_2(self): |
---|
1412 | """ Test 2D model for a Fractal Abs Model""" |
---|
1413 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 39.2881, 3) |
---|
1414 | |
---|
1415 | def testEval_1D(self): |
---|
1416 | """ Test 1D model for a Fractal Abs Model with evalDistribution""" |
---|
1417 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1418 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1419 | |
---|
1420 | def testEval_2D(self): |
---|
1421 | """ Test 2D model for a Fractal Abs Model with evalDistribution""" |
---|
1422 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1423 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1424 | |
---|
1425 | # No more singular point |
---|
1426 | #def testCriticalPoint(self): |
---|
1427 | # """ Test Fractal Abs at the critical point""" |
---|
1428 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1429 | |
---|
1430 | class TestFractalModel(unittest.TestCase): |
---|
1431 | """ Unit tests for FractalModel""" |
---|
1432 | |
---|
1433 | def setUp(self): |
---|
1434 | from sans.models.FractalModel import FractalModel |
---|
1435 | self.comp = FractalModel() |
---|
1436 | self.comp.setParam('scale', 0.05) |
---|
1437 | self.comp.setParam('radius', 5.0) |
---|
1438 | self.comp.setParam('fractal_dim', 2.0) |
---|
1439 | self.comp.setParam('cor_length',100.0) |
---|
1440 | self.comp.setParam('sldBlock', 2.0e-6) |
---|
1441 | self.comp.setParam('sldSolv', 6.35e-6) |
---|
1442 | self.comp.setParam('background',0.0) |
---|
1443 | |
---|
1444 | self.x = numpy.array([0.4, 1.3]) |
---|
1445 | self.y = numpy.array([0.5, 1.57]) |
---|
1446 | |
---|
1447 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1448 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1449 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1450 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1451 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1452 | |
---|
1453 | def test1D(self): |
---|
1454 | """ Test 1D model for a Fractal Model""" |
---|
1455 | self.assertAlmostEqual(self.comp.run(0.001), 39.2881, 3) |
---|
1456 | |
---|
1457 | def test1D_2(self): |
---|
1458 | """ Test 2D model for a Fractal Model""" |
---|
1459 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]), 39.2881, 3) |
---|
1460 | |
---|
1461 | def testEval_1D(self): |
---|
1462 | """ Test 1D model for a Fractal Model with evalDistribution""" |
---|
1463 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1464 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1465 | |
---|
1466 | def testEval_2D(self): |
---|
1467 | """ Test 2D model for a Fractal Model with evalDistribution""" |
---|
1468 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1469 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1470 | |
---|
1471 | # No more singular point |
---|
1472 | #def testCriticalPoint(self): |
---|
1473 | # """ Test Fractal at the critical point""" |
---|
1474 | # self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1475 | |
---|
1476 | class TestLorentzModel(unittest.TestCase): |
---|
1477 | """ Unit tests for LorentzModel""" |
---|
1478 | |
---|
1479 | def setUp(self): |
---|
1480 | from sans.models.LorentzModel import LorentzModel |
---|
1481 | self.comp = LorentzModel() |
---|
1482 | self.comp.setParam("background",1) |
---|
1483 | self.comp.setParam("length",50) |
---|
1484 | self.comp.setParam("scale",100) |
---|
1485 | |
---|
1486 | self.x = numpy.array([0.4, 1.3]) |
---|
1487 | self.y = numpy.array([0.5, 1.57]) |
---|
1488 | |
---|
1489 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1490 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1491 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1492 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1493 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1494 | |
---|
1495 | def test1D(self): |
---|
1496 | """ Test 1D model for a Lorentz Model""" |
---|
1497 | self.assertAlmostEqual(self.comp.run(0.001),100.751, 2) |
---|
1498 | |
---|
1499 | def test1D_2(self): |
---|
1500 | """ Test 2D model for a Lorentz Model""" |
---|
1501 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),100.751, 2) |
---|
1502 | |
---|
1503 | def testEval_1D(self): |
---|
1504 | """ Test 1D model for a Lorentz Model with evalDistribution""" |
---|
1505 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1506 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1507 | |
---|
1508 | def testEval_2D(self): |
---|
1509 | """ Test 2D model for a Lorentz Model with evalDistribution""" |
---|
1510 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1511 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1512 | |
---|
1513 | |
---|
1514 | def testCriticalPoint(self): |
---|
1515 | """ Test Lorentz at the critical point""" |
---|
1516 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1517 | |
---|
1518 | |
---|
1519 | class TestPowerLawAbsModel(unittest.TestCase): |
---|
1520 | """ Unit tests for PowerLawAbsModel""" |
---|
1521 | |
---|
1522 | def setUp(self): |
---|
1523 | from sans.models.PowerLawAbsModel import PowerLawAbsModel |
---|
1524 | self.comp = PowerLawAbsModel() |
---|
1525 | self.comp.setParam("background",1) |
---|
1526 | self.comp.setParam("m",4) |
---|
1527 | self.comp.setParam("scale",1e-6) |
---|
1528 | |
---|
1529 | self.x = numpy.array([0.4, 1.3]) |
---|
1530 | self.y = numpy.array([0.5, 1.57]) |
---|
1531 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1532 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1533 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1534 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1535 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1536 | |
---|
1537 | def test1D(self): |
---|
1538 | """ Test 1D model for a PowerLawAbs Model""" |
---|
1539 | self.assertAlmostEqual(self.comp.run(0.19189), 1.00074,4) |
---|
1540 | |
---|
1541 | def test1D_2(self): |
---|
1542 | """ Test 2D model for a PowerLawAbs Model""" |
---|
1543 | self.assertAlmostEqual(self.comp.run([0.19189,1.3]), 1.00074,4) |
---|
1544 | |
---|
1545 | def testEval_1D(self): |
---|
1546 | """ Test 1D model for a PowerLawAbs Model with evalDistribution""" |
---|
1547 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1548 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1549 | |
---|
1550 | def testEval_2D(self): |
---|
1551 | """ Test 2D model for a PowerLawAbs Model with evalDistribution""" |
---|
1552 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1553 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1554 | |
---|
1555 | |
---|
1556 | def testCriticalPoint(self): |
---|
1557 | """ Test PowerLawAbs at the critical point""" |
---|
1558 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1559 | |
---|
1560 | |
---|
1561 | class TestPowerLawModel(unittest.TestCase): |
---|
1562 | """ Unit tests for PowerLawModel""" |
---|
1563 | |
---|
1564 | def setUp(self): |
---|
1565 | from sans.models.PowerLawModel import PowerLawModel |
---|
1566 | self.comp = PowerLawModel() |
---|
1567 | self.comp.setParam("background",1) |
---|
1568 | self.comp.setParam("m",4) |
---|
1569 | self.comp.setParam("scale",1e-6) |
---|
1570 | |
---|
1571 | self.x = numpy.array([0.4, 1.3]) |
---|
1572 | self.y = numpy.array([0.5, 1.57]) |
---|
1573 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1574 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1575 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1576 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1577 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1578 | |
---|
1579 | def test1D(self): |
---|
1580 | """ Test 1D model for a PowerLaw Model""" |
---|
1581 | self.assertAlmostEquals(self.comp.run(0.19189), 1.00074,4) |
---|
1582 | |
---|
1583 | def test1D_2(self): |
---|
1584 | """ Test 2D model for a PowerLawModel""" |
---|
1585 | self.assertAlmostEquals(self.comp.run([0.19189,1.3]), 1.00074,4) |
---|
1586 | |
---|
1587 | def testEval_1D(self): |
---|
1588 | """ Test 1D model for a PowerLawModel with evalDistribution""" |
---|
1589 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1590 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1591 | |
---|
1592 | def testEval_2D(self): |
---|
1593 | """ Test 2D model for a PowerLawModel with evalDistribution""" |
---|
1594 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1595 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1596 | |
---|
1597 | |
---|
1598 | def testCriticalPoint(self): |
---|
1599 | """ Test PowerLawModel at the critical point""" |
---|
1600 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1601 | |
---|
1602 | |
---|
1603 | class TestTeubnerStreyModel(unittest.TestCase): |
---|
1604 | """ Unit tests for TeubnerStreyModel""" |
---|
1605 | |
---|
1606 | def setUp(self): |
---|
1607 | from sans.models.TeubnerStreyModel import TeubnerStreyModel |
---|
1608 | self.comp = TeubnerStreyModel() |
---|
1609 | self.comp.setParam("background",0.1) |
---|
1610 | self.comp.setParam("c1",-30) |
---|
1611 | self.comp.setParam("c2",5000) |
---|
1612 | self.comp.setParam("scale",0.1) |
---|
1613 | |
---|
1614 | self.x = numpy.array([0.4, 1.3]) |
---|
1615 | self.y = numpy.array([0.5, 1.57]) |
---|
1616 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1617 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1618 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1619 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1620 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1621 | |
---|
1622 | def test1D(self): |
---|
1623 | """ Test 1D model for a TeubnerStrey Model""" |
---|
1624 | self.assertAlmostEqual(self.comp.run(0.001),10.103, 1) |
---|
1625 | |
---|
1626 | def test1D_2(self): |
---|
1627 | """ Test 2D model for a TeubnerStrey Model""" |
---|
1628 | self.assertAlmostEqual(self.comp.run([0.001, 1.3]),10.103, 1) |
---|
1629 | |
---|
1630 | def testEval_1D(self): |
---|
1631 | """ Test 1D model for a TeubnerStrey with evalDistribution""" |
---|
1632 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1633 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1634 | |
---|
1635 | def testEval_2D(self): |
---|
1636 | """ Test 2D model for a TeubnerStrey with evalDistribution""" |
---|
1637 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) |
---|
1638 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1639 | |
---|
1640 | |
---|
1641 | def testCriticalPoint(self): |
---|
1642 | """ Test TeubnerStrey at the critical point""" |
---|
1643 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1644 | |
---|
1645 | |
---|
1646 | class TestLineModel(unittest.TestCase): |
---|
1647 | """ Unit tests for LineModel""" |
---|
1648 | |
---|
1649 | def setUp(self): |
---|
1650 | from sans.models.LineModel import LineModel |
---|
1651 | self.comp = LineModel() |
---|
1652 | self.comp.setParam("A",1) |
---|
1653 | self.comp.setParam("B",1) |
---|
1654 | |
---|
1655 | self.x = numpy.array([0.4, 1.3]) |
---|
1656 | self.y = numpy.array([0.5, 1.57]) |
---|
1657 | self.x_array = self.comp.evalDistribution(self.x) |
---|
1658 | self.y_array = self.comp.evalDistribution(self.y) |
---|
1659 | qx_prime = numpy.reshape(self.x, [1,len(self.x)]) |
---|
1660 | qy_prime = numpy.reshape(self.y, [len(self.y),1]) |
---|
1661 | self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) |
---|
1662 | |
---|
1663 | def test1D(self): |
---|
1664 | """ Test 1D model for a Line Model""" |
---|
1665 | self.assertEquals(self.comp.run(1.0),2) |
---|
1666 | |
---|
1667 | def testEval_1D(self): |
---|
1668 | """ Test 1D model for a Line with evalDistribution""" |
---|
1669 | self.assertEquals(self.comp.run(0.4),self.x_array[0]) |
---|
1670 | self.assertEquals(self.comp.run(1.3),self.x_array[1]) |
---|
1671 | |
---|
1672 | def testEval_2D(self): |
---|
1673 | """ Test 2D model for a Line with evalDistribution""" |
---|
1674 | self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0], 8) |
---|
1675 | self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) |
---|
1676 | |
---|
1677 | |
---|
1678 | def testCriticalPoint(self): |
---|
1679 | """ Test line at the critical point""" |
---|
1680 | self.assert_(numpy.isfinite(self.comp.run(0.0))) |
---|
1681 | |
---|
1682 | if __name__ == '__main__': |
---|
1683 | unittest.main() |
---|