Changeset 1e40ed1 in sasview for sansmodels
- Timestamp:
- Aug 23, 2012 10:22:16 AM (12 years ago)
- 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
- Location:
- sansmodels
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/c_models/starpolymer.cpp
rf1e0c1eb r1e40ed1 27 27 double d_background = background(); 28 28 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); 31 31 32 32 double term1 = v - 1.0 + exp(-v); -
sansmodels/test/utest_models.py
r4680e75 r1e40ed1 107 107 self.star.setParam('R2', 100.0) 108 108 self.star.setParam('background', 1.0) 109 self.assertAlmostEqual(self.star.run(0.01), 3.99 98999827681025)109 self.assertAlmostEqual(self.star.run(0.01), 3.9900214150405686) 110 110 111 111 def test2D(self): … … 117 117 self.star.setParam('R2', 100.0) 118 118 self.star.setParam('background', 1.0) 119 self.assertAlmostEqual(self.star.runXY([x, y]), 3.99 98999827681025)119 self.assertAlmostEqual(self.star.runXY([x, y]), 3.9900214150405686) 120 120 121 121 def test2Dphi(self): … … 125 125 self.star.setParam('background', 1.0) 126 126 127 self.assertAlmostEqual(self.star.run([0.01, math.pi/4.0]), 3.99 98999827681025)127 self.assertAlmostEqual(self.star.run([0.01, math.pi/4.0]), 3.9900214150405686) 128 128 129 129 -
sansmodels/test/utest_other_models.py
rf1e0c1eb r1e40ed1 1234 1234 self.assert_(numpy.isfinite(self.comp.run(0.0))) 1235 1235 1236 class TestStarPolymer(unittest.TestCase):1237 """ Unit tests for StarPolymer"""1238 1239 def setUp(self):1240 from sans.models.StarPolymer import StarPolymer1241 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 variables1251 q = 0.0011252 rg = 100.01253 f = 3.01254 bkg = 1.01255 scale = 5.01256 1257 # equation set up1258 u = rg * q * q1259 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 += bkg1265 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.0011271 qy = 1.31272 q = math.sqrt(qx*qx + qy*qy)1273 rg = 100.01274 f = 3.01275 bkg = 1.01276 scale = 5.01277 1278 # equation set up1279 u = rg * q * q1280 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 += bkg1286 1287 self.assertAlmostEqual(self.comp.runXY([0.001, 1.3]), p, 5)1288 1236 1289 1237
Note: See TracChangeset
for help on using the changeset viewer.