Changeset 1e40ed1 in sasview for sansmodels


Ignore:
Timestamp:
Aug 23, 2012 10:22:16 AM (12 years ago)
Author:
Kieran Campbell <kieranrcampbell@…>
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:
10b3e1e
Parents:
fe112d1a
Message:

Small problem with the maths in starpolymer

Location:
sansmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/c_models/starpolymer.cpp

    rf1e0c1eb r1e40ed1  
    2727  double d_background = background(); 
    2828 
    29   double u = d_R2 * pow(q,2); 
    30   double v = pow(u,2.0) * d_arms / (3.0 * d_arms - 2.0); 
     29  double u_2 = d_R2 * pow(q,2); 
     30  double v = u_2 * d_arms / (3.0 * d_arms - 2.0); 
    3131 
    3232  double term1 = v - 1.0 + exp(-v); 
  • sansmodels/test/utest_models.py

    r4680e75 r1e40ed1  
    107107        self.star.setParam('R2', 100.0) 
    108108        self.star.setParam('background', 1.0) 
    109         self.assertAlmostEqual(self.star.run(0.01), 3.9998999827681025) 
     109        self.assertAlmostEqual(self.star.run(0.01), 3.9900214150405686) 
    110110 
    111111    def test2D(self): 
     
    117117        self.star.setParam('R2', 100.0) 
    118118        self.star.setParam('background', 1.0) 
    119         self.assertAlmostEqual(self.star.runXY([x, y]), 3.9998999827681025) 
     119        self.assertAlmostEqual(self.star.runXY([x, y]), 3.9900214150405686) 
    120120 
    121121    def test2Dphi(self): 
     
    125125        self.star.setParam('background', 1.0) 
    126126         
    127         self.assertAlmostEqual(self.star.run([0.01, math.pi/4.0]), 3.9998999827681025) 
     127        self.assertAlmostEqual(self.star.run([0.01, math.pi/4.0]), 3.9900214150405686) 
    128128 
    129129 
  • sansmodels/test/utest_other_models.py

    rf1e0c1eb r1e40ed1  
    12341234        self.assert_(numpy.isfinite(self.comp.run(0.0)))            
    12351235 
    1236 class TestStarPolymer(unittest.TestCase): 
    1237     """ Unit tests for StarPolymer""" 
    1238      
    1239     def setUp(self): 
    1240         from sans.models.StarPolymer import StarPolymer 
    1241         self.comp = StarPolymer() 
    1242         self.comp.setParam('arms',3.0) 
    1243         self.comp.setParam('scale',5.0) 
    1244         self.comp.setParam('background',1.0) 
    1245         self.comp.setParam('R2',100.0) 
    1246          
    1247          
    1248     def test1D(self): 
    1249         """ Test 1D model for a StarPolymer""" 
    1250         # our variables 
    1251         q = 0.001 
    1252         rg = 100.0 
    1253         f = 3.0 
    1254         bkg = 1.0 
    1255         scale = 5.0 
    1256  
    1257         # equation set up 
    1258         u = rg * q * q 
    1259         v = u * u * f / (3*f - 2) 
    1260         p = 2 / (f * v * v) 
    1261         temp = v - 1 + math.exp(-v) 
    1262         temp += (f - 1)/2 * math.pow(1 - math.exp(-v), 2) 
    1263         p *= (temp * scale) 
    1264         p += bkg 
    1265          
    1266         self.assertAlmostEquals(self.comp.run(q), p, 5) 
    1267          
    1268     def test1D_2(self): 
    1269         """ Test 2D model for a StarPolymer""" 
    1270         qx = 0.001 
    1271         qy = 1.3 
    1272         q = math.sqrt(qx*qx + qy*qy) 
    1273         rg = 100.0 
    1274         f = 3.0 
    1275         bkg = 1.0 
    1276         scale = 5.0 
    1277  
    1278         # equation set up 
    1279         u = rg * q * q 
    1280         v = u * u * f / (3*f - 2) 
    1281         p = 2 / (f * v * v) 
    1282         temp = v - 1 + math.exp(-v) 
    1283         temp += (f - 1)/2 * math.pow(1 - math.exp(-v), 2) 
    1284         p *= (temp * scale) 
    1285         p += bkg 
    1286  
    1287         self.assertAlmostEqual(self.comp.runXY([0.001, 1.3]), p, 5) 
    12881236              
    12891237     
Note: See TracChangeset for help on using the changeset viewer.