source: sasview/sansmodels/test/utest_sphere_dispersity.py @ 9f51c2c

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 9f51c2c was 07dfdb8, checked in by Jae Cho <jhjcho@…>, 13 years ago

test for sphere polydispersion w/ gauss and schulz

  • Property mode set to 100644
File size: 2.0 KB
Line 
1"""
2    Unit tests for Gauss and Shulz dispersion functionality of
3    C++ model classes
4"""
5
6import unittest, math, numpy
7from sans.dataloader.loader import  Loader
8
9       
10class TestSphereGauss(unittest.TestCase):
11    """
12        Testing C++  Polydispersion w/ sphere comparing to IGOR/NIST computation
13    """
14    def setUp(self):
15        loader = Loader()
16        ## IGOR/NIST computation
17        self.output_gauss=loader.load('Gausssphere.txt')
18        self.output_shulz=loader.load('Schulzsphere.txt')
19
20        from sans.models.SphereModel import SphereModel
21        self.model= SphereModel()
22
23        self.model.setParam('scale', 0.01)
24        self.model.setParam('radius', 60.0)
25        self.model.setParam('sldSph', 1.e-6)
26        self.model.setParam('sldSolv', 3.e-6)
27        self.model.setParam('background', 0.001)
28
29    def test_gauss(self):
30        from sans.models.dispersion_models import GaussianDispersion
31        disp_g = GaussianDispersion()
32        self.model.set_dispersion('radius', disp_g)
33        self.model.dispersion['radius']['width'] = 0.2
34        self.model.dispersion['radius']['npts'] = 100
35        self.model.dispersion['radius']['nsigmas'] = 10
36        for ind in range(len(self.output_gauss.x)):
37            self.assertAlmostEqual(self.model.run(self.output_gauss.x[ind]), 
38                                   self.output_gauss.y[ind], 2)
39       
40    def test_shulz(self):
41        from sans.models.dispersion_models import SchulzDispersion
42        disp_s = SchulzDispersion()
43        self.model.set_dispersion('radius', disp_s)
44        self.model.dispersion['radius']['width'] = 0.2
45        self.model.dispersion['radius']['npts'] = 100
46        self.model.dispersion['radius']['nsigmas'] = 10
47        for ind in range(len(self.output_shulz.x)):
48            self.assertAlmostEqual(self.model.run(self.output_gauss.x[ind]), 
49                                   self.output_shulz.y[ind], 3)       
50
51if __name__ == '__main__':
52    unittest.main()
53   
Note: See TracBrowser for help on using the repository browser.