1 | """ |
---|
2 | Unit tests for extra models,PolymerexclVolume, RPA10Model |
---|
3 | """ |
---|
4 | import unittest |
---|
5 | class TestPolymerExclVolume(unittest.TestCase): |
---|
6 | """ |
---|
7 | Unit tests for PolymerexclVolume (non-shape) function |
---|
8 | """ |
---|
9 | def setUp(self): |
---|
10 | from sans.models.PolymerExclVolume import PolymerExclVolume |
---|
11 | self.model= PolymerExclVolume() |
---|
12 | |
---|
13 | def test1D(self): |
---|
14 | # the values are from Igor pro calculation |
---|
15 | self.assertAlmostEqual(self.model.run(0.001), 0.998801, 6) |
---|
16 | self.assertAlmostEqual(self.model.run(0.21571), 0.00192041, 6) |
---|
17 | self.assertAlmostEqual(self.model.runXY(0.41959), 0.000261302, 6) |
---|
18 | |
---|
19 | class TestPolymerExclVolume(unittest.TestCase): |
---|
20 | """ |
---|
21 | Unit tests for RPA10Model (non-shape) function |
---|
22 | """ |
---|
23 | def setUp(self): |
---|
24 | from sans.models.RPA10Model import RPA10Model |
---|
25 | self.model0= RPA10Model(0) |
---|
26 | self.model1= RPA10Model(1) |
---|
27 | self.model2= RPA10Model(2) |
---|
28 | self.model3= RPA10Model(3) |
---|
29 | self.model4= RPA10Model(4) |
---|
30 | self.model5= RPA10Model(5) |
---|
31 | self.model6= RPA10Model(6) |
---|
32 | self.model7= RPA10Model(7) |
---|
33 | self.model8= RPA10Model(8) |
---|
34 | self.model9= RPA10Model(9) |
---|
35 | |
---|
36 | def test1D(self): |
---|
37 | # the test values are from Igor pro calculation |
---|
38 | # case 0 |
---|
39 | # set default of vol fration consistent with IGor |
---|
40 | self.model0.setParam('Phic',0.5) |
---|
41 | self.model0.setParam('Phid',0.5) |
---|
42 | self.assertAlmostEqual(self.model0.run(0.001), 0.0716863, 6) |
---|
43 | self.assertAlmostEqual(self.model0.runXY(0.414955), 0.00396997, 6) |
---|
44 | # case 1 |
---|
45 | # set default of vol fration consistent with IGor |
---|
46 | self.model1.setParam('Phic',0.5) |
---|
47 | self.model1.setParam('Phid',0.5) |
---|
48 | self.assertAlmostEqual(self.model1.run(0.001), 0.00395016, 6) |
---|
49 | self.assertAlmostEqual(self.model1.runXY(0.414955), 0.00396735, 6) |
---|
50 | # case 2 |
---|
51 | # set default of vol fration consistent with IGor |
---|
52 | self.model2.setParam('Phib',0.33) |
---|
53 | self.model2.setParam('Phic',0.33) |
---|
54 | self.model2.setParam('Phid',0.33) |
---|
55 | self.assertAlmostEqual(self.model2.run(0.001), 0.0932902, 6) |
---|
56 | self.assertAlmostEqual(self.model2.runXY(0.414955), 0.00355736, 6) |
---|
57 | # case 3 |
---|
58 | # set default of vol fration consistent with IGor |
---|
59 | self.model3.setParam('Phib',0.33) |
---|
60 | self.model3.setParam('Phic',0.33) |
---|
61 | self.model3.setParam('Phid',0.33) |
---|
62 | self.assertAlmostEqual(self.model3.run(0.001), 0.026254, 6) |
---|
63 | self.assertAlmostEqual(self.model3.runXY(0.414955), 0.00355577, 6) |
---|
64 | # case 4 |
---|
65 | # set default of vol fration consistent with IGor |
---|
66 | self.model4.setParam('Phib',0.33) |
---|
67 | self.model4.setParam('Phic',0.33) |
---|
68 | self.model4.setParam('Phid',0.33) |
---|
69 | self.assertAlmostEqual(self.model4.run(0.001), 0.0067433, 6) |
---|
70 | self.assertAlmostEqual(self.model4.runXY(0.414955), 0.00355656, 6) |
---|
71 | # case 5 |
---|
72 | self.assertAlmostEqual(self.model5.run(0.001), 0.102636, 6) |
---|
73 | self.assertAlmostEqual(self.model5.runXY(0.414955), 0.00305812, 6) |
---|
74 | # case 6 |
---|
75 | self.assertAlmostEqual(self.model6.run(0.001), 0.0370357, 6) |
---|
76 | self.assertAlmostEqual(self.model6.runXY(0.414955), 0.00305708, 6) |
---|
77 | # case 7 |
---|
78 | self.assertAlmostEqual(self.model7.run(0.001), 0.0167775, 6) |
---|
79 | self.assertAlmostEqual(self.model7.runXY(0.414955), 0.00305743, 6) |
---|
80 | # case 8 |
---|
81 | self.assertAlmostEqual(self.model8.run(0.001), 0.0378691, 6) |
---|
82 | self.assertAlmostEqual(self.model8.runXY(0.414955), 0.00305743, 6) |
---|
83 | # case 9 |
---|
84 | self.assertAlmostEqual(self.model9.run(0.001), 0.00839376, 6) |
---|
85 | self.assertAlmostEqual(self.model9.runXY(0.414955), 0.00305777, 6) |
---|
86 | |
---|
87 | if __name__ == '__main__': |
---|
88 | unittest.main() |
---|