Changeset 8f20419d in sasview for sansmodels/src/sans


Ignore:
Timestamp:
Oct 14, 2010 2:30:23 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:
29100cb
Parents:
4cc8285c
Message:

more models and some tests

Location:
sansmodels/src/sans/models
Files:
8 added
6 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/bcc.c

    rd5b6a9d r8f20419d  
    9191    b1_y = cos(pars->psi); 
    9292    // b2 axis orientation 
    93     b2_x = sqrt(1-sin(pars->theta)*cos(pars->phi))*cos(pars->psi); 
    94     b2_y = sqrt(1-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
     93    b2_x = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*cos(pars->psi); 
     94    b2_y = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
    9595 
    9696    // a3 axis orientation 
  • sansmodels/src/sans/models/c_extensions/ellipsoid.c

    rf10063e r8f20419d  
    3232 
    3333        // Spherical scattering ampliture, with modified length for ellipsoid 
    34         sph_func = 3*( sin(q*length) - q*length*cos(q*length) ) / (q*q*q*length*length*length); 
     34        sph_func = 3.0*( sin(q*length) - q*length*cos(q*length) ) / (q*q*q*length*length*length); 
    3535 
    3636        return sph_func*sph_func; 
     
    9999 
    100100    // q vector 
    101     q_z = 0; 
     101    q_z = 0.0; 
    102102 
    103103    // Compute the angle btw vector q and the 
  • sansmodels/src/sans/models/c_extensions/fcc.c

    r339ce67 r8f20419d  
    9191    b1_y = cos(pars->psi); 
    9292    // b2 axis orientation 
    93     b2_x = sqrt(1-sin(pars->theta)*cos(pars->phi))*cos(pars->psi); 
    94     b2_y = sqrt(1-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
     93    b2_x = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*cos(pars->psi); 
     94    b2_y = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
    9595 
    9696    // a3 axis orientation 
     
    109109 
    110110    // Compute the angle btw vector q and the a3 axis 
    111     cos_val_a3 = a3_x*q_x + a3_y*q_y + a3_z*q_z; 
     111    cos_val_a3 = a3_x*q_x + a3_y*q_y;// + a3_z*q_z; 
    112112    a3_dot_q = aa*q*cos_val_a3; 
    113113 
  • sansmodels/src/sans/models/c_extensions/sc.c

    rd5b6a9d r8f20419d  
    9999 
    100100    // a2 axis orientation 
    101     a2_x = sqrt(1-sin(pars->theta)*cos(pars->phi))*cos(pars->psi); 
    102     a2_y = sqrt(1-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
     101    a2_x = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*cos(pars->psi); 
     102    a2_y = sqrt(1.0-sin(pars->theta)*cos(pars->phi))*sin(pars->psi); 
    103103    // a2 axis 
    104     cos_val_a2 = sin(acos(cos_val_a1)) ; 
     104    cos_val_a2 =  a2_x*q_x + a2_y*q_y;//sin(acos(cos_val_a1)) ; 
    105105    a2_dot_q = aa*q*cos_val_a2; 
    106106 
  • sansmodels/src/sans/models/c_extensions/triaxial_ellipsoid.c

    r13eb1c4 r8f20419d  
    9797 
    9898    // q vector 
    99     q_z = 0; 
     99    q_z = 0.0; 
    100100 
    101101        //dx = 1.0; 
  • sansmodels/src/sans/models/test/utest_extra_models.py

    r339ce67 r8f20419d  
    178178        self.assertAlmostEqual(self.model.run(0.215268), 0.00927739, 6) 
    179179        self.assertAlmostEqual(self.model.runXY(0.414467), 0.000406973, 6) 
    180                                                          
     180                                
     181 
     182class TestGuinierPorod(unittest.TestCase): 
     183    """ 
     184    Unit tests for GuinierPorod Model function 
     185    """ 
     186    def setUp(self): 
     187        from sans.models.GuinierPorodModel import GuinierPorodModel  
     188        self.model= GuinierPorodModel() 
     189         
     190    def test1D(self):         
     191        # the values are from Igor pro calculation   
     192        # the different digits are due to precision of q values   
     193        self.assertAlmostEqual(self.model.run(0.001), 995.112, 3) 
     194        self.assertAlmostEqual(self.model.run(0.105363), 0.162904, 5) 
     195        self.assertAlmostEqual(self.model.runXY(0.441623), 0.100854, 6) 
     196 
     197class TestGaussLorentzGel(unittest.TestCase): 
     198    """ 
     199    Unit tests for GuinierPorod Model function 
     200    """ 
     201    def setUp(self): 
     202        from sans.models.GaussLorentzGelModel import GaussLorentzGelModel 
     203        self.model= GaussLorentzGelModel() 
     204         
     205    def test1D(self):         
     206        # the values are from Igor pro calculation   
     207        # the different digits are due to precision of q values   
     208        self.assertAlmostEqual(self.model.run(0.001), 149.481, 3) 
     209        self.assertAlmostEqual(self.model.run(0.105363), 9.1903, 4) 
     210        self.assertAlmostEqual(self.model.runXY(0.441623), 0.632811, 5) 
     211                                 
     212 
     213class TestTwoPowerLaw(unittest.TestCase): 
     214    """ 
     215    Unit tests for TwoPowerLaw Model function 
     216    """ 
     217    def setUp(self): 
     218        from sans.models.TwoPowerLawModel import TwoPowerLawModel 
     219        self.model= TwoPowerLawModel() 
     220         
     221    def test1D(self):         
     222        # the values are from Igor pro calculation   
     223        # the different digits are due to precision of q values   
     224        self.assertEqual(self.model.run(0.001), 1000) 
     225        self.assertAlmostEqual(self.model.run(0.150141), 0.125945, 5) 
     226        self.assertAlmostEqual(self.model.runXY(0.442528), 0.00166884, 7) 
     227                                 
     228class TestTwoLorentzian(unittest.TestCase): 
     229    """ 
     230    Unit tests for TwoLorentzian Model function 
     231    """ 
     232    def setUp(self): 
     233        from sans.models.TwoLorentzianModel import TwoLorentzianModel 
     234        self.model= TwoLorentzianModel() 
     235         
     236    def test1D(self):         
     237        # the values are from Igor pro calculation   
     238        # the different digits are due to precision of q values   
     239        self.assertAlmostEqual(self.model.run(0.001), 11.0899, 3) 
     240        self.assertAlmostEqual(self.model.run(0.150141), 0.410245, 5) 
     241        self.assertAlmostEqual(self.model.runXY(0.442528), 0.148699, 6) 
     242                                 
     243 
     244class TestCorrLengthLaw(unittest.TestCase): 
     245    """ 
     246    Unit tests for CorrLength Model function 
     247    """ 
     248    def setUp(self): 
     249        from sans.models.CorrLengthModel import CorrLengthModel 
     250        self.model= CorrLengthModel() 
     251         
     252    def test1D(self):         
     253        # the values are from Igor pro calculation   
     254        # the different digits are due to precision of q values   
     255        self.assertAlmostEqual(self.model.run(0.001), 1010.08, 1) 
     256        self.assertAlmostEqual(self.model.run(0.150141), 0.274645, 5) 
     257        self.assertAlmostEqual(self.model.runXY(0.442528), 0.120396, 6) 
     258                                 
     259 
     260class TestBroadPeak(unittest.TestCase): 
     261    """ 
     262    Unit tests for BroadPeak Model function 
     263    """ 
     264    def setUp(self): 
     265        from sans.models.BroadPeakModel import BroadPeakModel 
     266        self.model= BroadPeakModel() 
     267         
     268    def test1D(self):         
     269        # the values are from Igor pro calculation   
     270        # the different digits are due to precision of q values   
     271        self.assertAlmostEqual(self.model.run(0.001), 10000.5, 1) 
     272        self.assertAlmostEqual(self.model.run(0.1501412), 1.47557, 5) 
     273        self.assertAlmostEqual(self.model.runXY(0.4425284), 0.134093, 6) 
     274         
     275class TestFractalCoreShell(unittest.TestCase): 
     276    """ 
     277    Unit tests for FractalCoreShell Model function 
     278    """ 
     279    def setUp(self): 
     280        from sans.models.FractalCoreShellModel import FractalCoreShellModel 
     281        self.model= FractalCoreShellModel() 
     282         
     283    def test1D(self):         
     284        #self.model.setParam('radius.width', 2.0) 
     285        # the values are from Igor pro calculation   
     286        # the different digits are due to precision of q values   
     287        self.assertAlmostEqual(self.model.run(0.001), 273.742, 3) 
     288        self.assertAlmostEqual(self.model.run(0.1501412), 0.040079, 6) 
     289        self.assertAlmostEqual(self.model.runXY(0.4425284), 0.00141167, 6)                              
     290                                                                                                                
    181291if __name__ == '__main__': 
    182292    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.