← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2651: 1. regression tests of kinematic engines are updated and activated.

 

------------------------------------------------------------
revno: 2651
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Thu 2011-01-13 15:06:17 +0100
message:
  1. regression tests of kinematic engines are updated and activated.
modified:
  py/tests/omega.py


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'py/tests/omega.py'
--- py/tests/omega.py	2011-01-09 16:34:50 +0000
+++ py/tests/omega.py	2011-01-13 14:06:17 +0000
@@ -59,35 +59,32 @@
 		'Engines: dead engines are not run'
 		O.engines=[PyRunner(dead=True,initRun=True,iterPeriod=1,command='pass')]
 		O.step(); self.assert_(O.engines[0].nDone==0)
-	# must handle "non-dynamic" (a.k.a. DOFs blocked) particles correctly, then rename back
-	def _testTranslationRotationEngines(self):
+	def testKinematicEngines(self):
+		'Engines: test kinematic engines'
 		tolerance = 1e-5
-		angVelTemp = 5.0
+		rotIndex=5.0
+		angVelTemp = pi/rotIndex
 		O.reset()
-		id_dyn_transl = O.bodies.append(utils.sphere((0.0,0.0,0.0),1.0,dynamic=True))
-		id_nodyn_transl = O.bodies.append(utils.sphere((0.0,5.0,0.0),1.0,dynamic=False))
-		id_dyn_rot = O.bodies.append(utils.sphere((0.0,0.0,10.0),1.0,dynamic=False))
-		id_nodyn_rot = O.bodies.append(utils.sphere((0.0,5.0,10.0),1.0,dynamic=False))
+		id_fixed_transl = O.bodies.append(utils.sphere((0.0,0.0,0.0),1.0,fixed=True))
+		id_nonfixed_transl = O.bodies.append(utils.sphere((0.0,5.0,0.0),1.0,fixed=False))
+		id_fixed_rot = O.bodies.append(utils.sphere((0.0,0.0,10.0),1.0,fixed=False))
+		id_nonfixed_rot = O.bodies.append(utils.sphere((0.0,5.0,10.0),1.0,fixed=False))
 		O.engines=[
 			
-			TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_dyn_transl]),
-			TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_nodyn_transl]),
-			RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,0.0,0.0], ids = [id_dyn_rot]),
-			RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,5.0,0.0], ids = [id_nodyn_rot]),
+			TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_fixed_transl]),
+			TranslationEngine(velocity = 1.0, translationAxis = [1.0,0,0], ids = [id_nonfixed_transl]),
+			RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,0.0,0.0], ids = [id_fixed_rot]),
+			RotationEngine(angularVelocity = pi/angVelTemp, rotationAxis = [0.0,1.0,0.0], rotateAroundZero = True, zeroPoint = [0.0,5.0,0.0], ids = [id_nonfixed_rot]),
 			ForceResetter(),
 			NewtonIntegrator()
 		]
 		O.dt = 1.0
-		print
-		for i in range(0,5):
+		for i in range(0,25):
 			O.step()
-			self.assertTrue(int(O.bodies[id_dyn_transl].state.pos[0]) == O.iter)									#Check translation of dynamic bodies
-			self.assertTrue(int(O.bodies[id_nodyn_transl].state.pos[0]) == O.iter)								#Check translation of nondynamic bodies
-			self.assertTrue((O.bodies[id_nodyn_rot].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))/10*sin(pi/angVelTemp*O.iter)<tolerance)		#Check rotation of nondynamic bodies
-			self.assertTrue((O.bodies[id_nodyn_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))/10*cos(pi/angVelTemp*O.iter)<tolerance)		#Check rotation of nondynamic bodies
-			
-			#self.assertTrue((O.bodies[id_dyn_rot].state.pos[0] - 10*sin(pi/angVelTemp*O.iter))/10*sin(pi/angVelTemp*O.iter)<tolerance)		#Check rotation of dynamic bodies
-			#self.assertTrue((O.bodies[id_dyn_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))/10*cos(pi/angVelTemp*O.iter)<tolerance)		#Check rotation of dynamic bodies
+			self.assertTrue((O.bodies[id_fixed_transl].state.pos[0] / O.iter - 1.0) < tolerance)									#Check translation of fixed bodies
+			self.assertTrue((O.bodies[id_nonfixed_transl].state.pos[0] / O.iter - 1.0) < tolerance)								#Check translation of nonfixed bodies
+			self.assertTrue((O.bodies[id_fixed_rot].state.pos[0]-10.0*sin(pi/angVelTemp*O.iter))<tolerance)		#Check rotation of fixed bodies
+			self.assertTrue((O.bodies[id_nonfixed_rot].state.pos[2] - 10*cos(pi/angVelTemp*O.iter))<tolerance)		#Check rotation of nonfixed bodies
 
 
 class TestIO(unittest.TestCase):