source: sasview/sansmodels/test/utest_model_pearlnecklace.py @ d2dfafd

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since d2dfafd was d9547e7, checked in by Jae Cho <jhjcho@…>, 13 years ago

Added linearpearlsmodel and a test

  • Property mode set to 100644
File size: 3.1 KB
Line 
1"""
2    Unit tests for specific models II
3"""
4
5import unittest, time, math
6     
7class TestPerlNecklace(unittest.TestCase):
8    """ Unit tests for PerlNecklace """
9   
10    def setUp(self):
11        from sans.models.PearlNecklaceModel import PearlNecklaceModel
12        self.pnl = PearlNecklaceModel()
13        from sans.models.LinearPearlsModel import LinearPearlsModel
14        self.lpm = LinearPearlsModel()
15        from sans.models.SphereModel import SphereModel
16        self.sphere = SphereModel()
17        from sans.models.BarBellModel import BarBellModel
18        self.bar = BarBellModel()
19       
20    def testwithsphere(self):
21        """ Compare 1D model with sphere """
22        self.pnl.setParam("radius", 60)
23        self.pnl.setParam("num_pearls", 1)
24        self.pnl.setParam("sld_pearl", 2e-06)
25        self.pnl.setParam("sld_solv", 1e-06)
26        self.assertAlmostEqual(self.pnl.run(0.001), self.sphere.run(0.001), 5)
27        self.assertAlmostEqual(self.pnl.run(0.005), self.sphere.run(0.005), 5)
28        self.assertAlmostEqual(self.pnl.run(0.01), self.sphere.run(0.01), 5)
29        self.assertAlmostEqual(self.pnl.run(0.05), self.sphere.run(0.05), 5)
30        self.assertAlmostEqual(self.pnl.run(0.1), self.sphere.run(0.1), 5)
31        self.assertAlmostEqual(self.pnl.run(0.5), self.sphere.run(0.5), 5)
32       
33    def testwithbarbell(self):
34        """
35        Compare 1D model with barbell
36       
37        Note:  pearlnecklace assumes infinite thin rod
38        """
39        self.pnl.setParam("radius", 20)
40        self.pnl.setParam("num_pearls", 2)
41        self.pnl.setParam("sld_pearl", 1e-06)
42        self.pnl.setParam("sld_string", 1e-06)
43        self.pnl.setParam("sld_solv", 6.3e-06)
44        self.pnl.setParam("thick_string", 0.1)
45        self.pnl.setParam("edge_separation", 400)
46        self.bar.setParam("rad_bar", 0.1)
47        self.bar.setParam("rad_bell", 20)
48        self.lpm.setParam("radius", 20)
49        self.lpm.setParam("num_pearls", 2)
50        self.lpm.setParam("sld_pearl", 1e-06)
51        self.lpm.setParam("sld_solv", 6.3e-06)
52        self.lpm.setParam("edge_separation", 400)
53               
54        self.assertAlmostEqual(self.pnl.run(0.001), self.bar.run(0.001), 1)
55        self.assertAlmostEqual(self.pnl.run(0.005), self.bar.run(0.005), 1)
56        self.assertAlmostEqual(self.pnl.run(0.01), self.bar.run(0.01), 1)
57        self.assertAlmostEqual(self.pnl.run(0.05), self.bar.run(0.05), 1)
58        self.assertAlmostEqual(self.pnl.run(0.1), self.bar.run(0.1), 1)
59        self.assertAlmostEqual(self.pnl.run(0.5), self.bar.run(0.5), 1)
60       
61        self.assertAlmostEqual(self.pnl.run(0.001), self.lpm.run(0.001), 1)
62        self.assertAlmostEqual(self.pnl.run(0.005), self.lpm.run(0.005), 1)
63        self.assertAlmostEqual(self.pnl.run(0.01), self.lpm.run(0.01), 1)
64        self.assertAlmostEqual(self.pnl.run(0.05), self.lpm.run(0.05), 1)
65        self.assertAlmostEqual(self.pnl.run(0.1), self.lpm.run(0.1), 1)
66        self.assertAlmostEqual(self.pnl.run(0.5), self.lpm.run(0.5), 1)
67       
68
69if __name__ == '__main__':
70    unittest.main()
Note: See TracBrowser for help on using the repository browser.