Ignore:
Timestamp:
Oct 12, 2010 6:22:08 PM (14 years ago)
Author:
Jae Cho <jhjcho@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
20f00bed
Parents:
aaad3098
Message:

added some models and tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/test/utest_extra_models.py

    r35aface r339ce67  
    11""" 
    2     Unit tests for extra models,PolymerexclVolume, RPA10Model 
     2Unit tests for extra models,PolymerexclVolume, RPA10Model 
     3The reference values are calculated on IGOR/NIST package(Oct.,2010) 
     4@author: JHJ Cho / UTK 
    35""" 
    46import unittest 
    57class TestPolymerExclVolume(unittest.TestCase): 
    68    """ 
    7         Unit tests for PolymerexclVolume (non-shape) function 
     9    Unit tests for PolymerexclVolume (non-shape) function 
    810    """ 
    911    def setUp(self): 
     
    1719        self.assertAlmostEqual(self.model.runXY(0.41959), 0.000261302, 6) 
    1820         
    19 class TestPolymerExclVolume(unittest.TestCase): 
     21class TestRPA10Case(unittest.TestCase): 
    2022    """ 
    21         Unit tests for RPA10Model (non-shape) function 
     23    Unit tests for RPA10Model (non-shape) function 
    2224    """ 
    2325    def setUp(self): 
     
    8385        # case 9 
    8486        self.assertAlmostEqual(self.model9.run(0.001), 0.00839376, 6) 
    85         self.assertAlmostEqual(self.model9.runXY(0.414955), 0.00305777, 6)         
     87        self.assertAlmostEqual(self.model9.runXY(0.414955), 0.00305777, 6)   
     88               
     89class TestBarBell(unittest.TestCase): 
     90    """ 
     91    Unit tests for BarBell function 
     92    """ 
     93    def setUp(self): 
     94        from sans.models.BarBellModel import BarBellModel 
     95        self.model= BarBellModel() 
    8696         
     97    def test1D(self):           
     98        # the values are from Igor pro calculation     
     99        self.assertAlmostEqual(self.model.run(0.001), 2864.7, 1) 
     100        self.assertAlmostEqual(self.model.run(0.215268), 0.526351, 4) 
     101        self.assertAlmostEqual(self.model.runXY(0.414467), 0.0685892, 6) 
     102 
     103class TestCappedCylinder(unittest.TestCase): 
     104    """ 
     105    Unit tests for CappedCylinder function 
     106    """ 
     107    def setUp(self): 
     108        from sans.models.CappedCylinderModel import CappedCylinderModel 
     109        self.model= CappedCylinderModel() 
     110         
     111    def test1D(self):           
     112        # the values are from Igor pro calculation   
     113        # the different digits are due to precision of q values   
     114        self.assertAlmostEqual(self.model.run(0.001), 1424.72, 2) 
     115        self.assertAlmostEqual(self.model.run(0.215268), 0.360736, 4) 
     116        self.assertAlmostEqual(self.model.runXY(0.414467), 0.110283, 5) 
     117 
     118class TestLamellarParaCrystal(unittest.TestCase): 
     119    """ 
     120    Unit tests for LamellarParaCystal function 
     121    """ 
     122    def setUp(self): 
     123        from sans.models.LamellarPCrystalModel import LamellarPCrystalModel 
     124        self.model= LamellarPCrystalModel() 
     125         
     126    def test1D(self):     
     127        self.model.setParam("pd_spacing", 0.2)       
     128        # the values are from Igor pro calculation   
     129        # the different digits are due to precision of q values   
     130        self.assertAlmostEqual(self.model.run(0.001), 21829.3, 1) 
     131        self.assertAlmostEqual(self.model.run(0.215268), 0.00487686, 6) 
     132        self.assertAlmostEqual(self.model.runXY(0.414467), 0.00062029, 6) 
     133 
     134 
     135class TestSCParaCrystal(unittest.TestCase): 
     136    """ 
     137    Unit tests for Simple Cubic ParaCrystal Model function 
     138    """ 
     139    def setUp(self): 
     140        from sans.models.SCCrystalModel import SCCrystalModel 
     141        self.model= SCCrystalModel() 
     142         
     143    def test1D(self):         
     144        # the values are from Igor pro calculation   
     145        # the different digits are due to precision of q values   
     146        self.assertAlmostEqual(self.model.run(0.001), 10.3038, 4) 
     147        self.assertAlmostEqual(self.model.run(0.215268), 0.00714905, 6) 
     148        self.assertAlmostEqual(self.model.runXY(0.414467), 0.000313289, 6) 
     149 
     150class TestFCParaCrystal(unittest.TestCase): 
     151    """ 
     152    Unit tests for Face Centered Cubic ParaCrystal Model function 
     153    """ 
     154    def setUp(self): 
     155        from sans.models.FCCrystalModel import FCCrystalModel 
     156        self.model= FCCrystalModel() 
     157         
     158    def test1D(self):        
     159        self.model.setParam("d_factor", 0.05)   
     160        # the values are from Igor pro calculation   
     161        # the different digits are due to precision of q values   
     162        self.assertAlmostEqual(self.model.run(0.001), 0.121017, 6) 
     163        self.assertAlmostEqual(self.model.run(0.215268), 0.0107218, 6) 
     164        self.assertAlmostEqual(self.model.runXY(0.414467), 0.000443282, 6) 
     165 
     166class TestBCParaCrystal(unittest.TestCase): 
     167    """ 
     168    Unit tests for Body Centered Cubic ParaCrystal Model function 
     169    """ 
     170    def setUp(self): 
     171        from sans.models.BCCrystalModel import BCCrystalModel 
     172        self.model= BCCrystalModel() 
     173         
     174    def test1D(self):         
     175        # the values are from Igor pro calculation   
     176        # the different digits are due to precision of q values   
     177        self.assertAlmostEqual(self.model.run(0.001), 1.77267, 4) 
     178        self.assertAlmostEqual(self.model.run(0.215268), 0.00927739, 6) 
     179        self.assertAlmostEqual(self.model.runXY(0.414467), 0.000406973, 6) 
     180                                                         
    87181if __name__ == '__main__': 
    88182    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.