source: sasview/sansmodels/test/utest_model_sphericalsldmodel.py @ b11e127

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 b11e127 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.9 KB
Line 
1"""
2    Unit tests for specific models
3    @author: JHJ Cho / UTK
4"""
5
6import unittest
7
8class TestSphericalSLDModel(unittest.TestCase):
9    """
10        Unit tests for OnionExpShellModel
11    """
12    def setUp(self):
13
14        from sans.models.SphericalSLDModel import SphericalSLDModel
15        from sans.models.OnionExpShellModel import OnionExpShellModel
16       
17        # intit models and the multifactor
18        # layer
19        self.model = SphericalSLDModel(1)
20        self.model2 = OnionExpShellModel(3)
21       
22    def test_compare_SphericalSLD_OnionExpShell(self):
23        """
24        Check if SphericalSLD equals (up to 1%) to
25        OnionExpShellModel with an equivalent SLD profile
26        """
27        note = "\n*****Note: This test was passes since Nov. 1st, 2010..."
28        print note
29        # set params
30        self.model.setParam("npts_inter", 35)
31        self.model.setParam("rad_core0", 100)
32        self.model.setParam("thick_inter0", 200)
33        self.model.setParam("nu_inter0", 4)
34        # Rexp func
35        self.model.setParam("func_inter0", 3)
36        self.model.setParam("thick_inter1", 200)
37        self.model.setParam("nu_inter1", 4)
38        self.model.setParam("func_inter1", 3)
39        # set A_shell=1
40        self.model2.setParam("sld_core0", 2.07e-006)
41        # change the function to flat function
42        self.model2.setParam("rad_core0", 100)
43        self.model2.setParam("thick_shell1", 200)
44        self.model2.setParam("sld_out_shell1", 4e-006)
45        self.model2.setParam("sld_in_shell1", 2.07e-006)
46        self.model2.setParam("A_shell1", -4)
47        self.model2.setParam("thick_shell2", 100)
48        self.model2.setParam("sld_out_shell2", 4e-006)
49        self.model2.setParam("sld_in_shell2", 4e-006)
50        self.model2.setParam("A_shell2", 0)
51        self.model2.setParam("thick_shell3", 200)
52        self.model2.setParam("sld_out_shell3", 1e-006)
53        self.model2.setParam("sld_in_shell3", 4e-006)
54        self.model2.setParam("A_shell3", -4)
55        self.model2.setParam("sld_solv", 1e-006)
56       
57        #sphericalsld model runs
58        model_run_0_1 = self.model.run(0.1)
59        model_run_0_01 = self.model.run(0.01)
60        model_run_0_001 = self.model.run(0.001)
61        #onionexp model runs
62        model2_run_0_1 = self.model2.run(0.1)
63        model2_run_0_01 = self.model2.run(0.01)
64        model2_run_0_001 = self.model2.run(0.001)
65        import time
66        st = time.time()
67        qs = []
68        qs = [i/10000 for i in range(1,1000)]
69        out = map(self.model.run,qs)
70        print time.time()-st
71        #Compare exp(A=0) to flat (where A_shell is null) function
72        self.assertAlmostEqual(self.model.run(0.1),self.model2.run(0.1),4)
73        self.assertAlmostEqual(self.model.run(0.01),self.model2.run(0.01),0)
74        self.assertAlmostEqual(self.model.run(0.001),self.model2.run(0.001),-3)
75                       
76if __name__ == '__main__':
77    unittest.main()
Note: See TracBrowser for help on using the repository browser.