------------------------------------------------------------ revno: 2564 committer: Anton Gladky <[email protected]> branch nick: trunk timestamp: Fri 2010-11-19 16:29:34 +0100 message: 1. Regression tests for translation and rotation engines are added (not fully tested yet, but "all tests passed") modified: py/tests/__init__.py 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/__init__.py' --- py/tests/__init__.py 2010-11-14 14:44:55 +0000 +++ py/tests/__init__.py 2010-11-19 15:29:34 +0000 @@ -19,7 +19,7 @@ def testModule(module): """Run all tests defined in the module specified, return TestResult object - (http://www.python.org/doc/2.6/lib/unittest.html#testresult-objects.html) + (http://docs.python.org/library/unittest.html#unittest.TextTestResult) for further processing. @param module: fully-qualified module name, e.g. yade.tests.wrapper === modified file 'py/tests/omega.py' --- py/tests/omega.py 2010-11-12 09:48:58 +0000 +++ py/tests/omega.py 2010-11-19 15:29:34 +0000 @@ -11,6 +11,7 @@ from yade._customConverters import * from yade import utils from yade import * +from math import * ## TODO tests class TestInteractions(unittest.TestCase): pass @@ -59,6 +60,34 @@ '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) + def testTranslationRotationEngines(self): + tolerance = 1e-5 + angVelTemp = 5.0 + 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)) + 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]), + ForceResetter(), + NewtonIntegrator() + ] + O.dt = 1.0 + print + for i in range(0,5): + 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 class TestIO(unittest.TestCase):
_______________________________________________ Mailing list: https://launchpad.net/~yade-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp

