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

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 c911f34 was 18e250c, checked in by Gervaise Alina <gervyh@…>, 13 years ago

move test to sansmodels top level

  • Property mode set to 100644
File size: 2.3 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.SphereModel import SphereModel
14        self.sphere = SphereModel()
15        from sans.models.BarBellModel import BarBellModel
16        self.bar = BarBellModel()
17       
18    def testwithsphere(self):
19        """ Compare 1D model with sphere """
20        self.pnl.setParam("radius", 60)
21        self.pnl.setParam("num_pearls", 1)
22        self.pnl.setParam("sld_pearl", 2e-06)
23        self.pnl.setParam("sld_solv", 1e-06)
24        self.assertAlmostEqual(self.pnl.run(0.001), self.sphere.run(0.001), 5)
25        self.assertAlmostEqual(self.pnl.run(0.005), self.sphere.run(0.005), 5)
26        self.assertAlmostEqual(self.pnl.run(0.01), self.sphere.run(0.01), 5)
27        self.assertAlmostEqual(self.pnl.run(0.05), self.sphere.run(0.05), 5)
28        self.assertAlmostEqual(self.pnl.run(0.1), self.sphere.run(0.1), 5)
29        self.assertAlmostEqual(self.pnl.run(0.5), self.sphere.run(0.5), 5)
30       
31    def testwithbarbell(self):
32        """
33        Compare 1D model with barbell
34       
35        Note:  pearlnecklace assumes infinite thin rod
36        """
37        self.pnl.setParam("radius", 20)
38        self.pnl.setParam("num_pearls", 2)
39        self.pnl.setParam("sld_pearl", 1e-06)
40        self.pnl.setParam("sld_string", 1e-06)
41        self.pnl.setParam("sld_solv", 6.3e-06)
42        self.pnl.setParam("thick_string", 0.1)
43        self.pnl.setParam("edge_separation", 400)
44        self.bar.setParam("rad_bar", 0.1)
45        self.bar.setParam("rad_bell", 20)
46       
47        self.assertAlmostEqual(self.pnl.run(0.001), self.bar.run(0.001), 1)
48        self.assertAlmostEqual(self.pnl.run(0.005), self.bar.run(0.005), 1)
49        self.assertAlmostEqual(self.pnl.run(0.01), self.bar.run(0.01), 1)
50        self.assertAlmostEqual(self.pnl.run(0.05), self.bar.run(0.05), 1)
51        self.assertAlmostEqual(self.pnl.run(0.1), self.bar.run(0.1), 1)
52        self.assertAlmostEqual(self.pnl.run(0.5), self.bar.run(0.5), 1)
53       
54       
55
56if __name__ == '__main__':
57    unittest.main()
Note: See TracBrowser for help on using the repository browser.