← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2780: 1. Added new checkWeight test to --check scripts

 

------------------------------------------------------------
revno: 2780
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Fri 2011-03-04 21:09:03 +0100
message:
  1. Added new checkWeight test to --check scripts
  2. It is not neccessary now to add the script name into the checkList.py, just drop a new script into the scripts/test/checks directory
added:
  scripts/test/checks/checkWeight.py
modified:
  scripts/test/checks/README
  scripts/test/checks/checkList.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 'scripts/test/checks/README'
--- scripts/test/checks/README	2011-01-19 18:22:56 +0000
+++ scripts/test/checks/README	2011-03-04 20:09:03 +0000
@@ -10,6 +10,6 @@
 
 5. An example check test can be found in checkTestTriax.py. It shows results comparison, output, and how to define the path to data files using "checksPath".
 
-6. Users are encouraged to add their own scripts and list them in checkList.py. Discussion of some specific checktests design in users question is welcome.
+6. Users are encouraged to add their own scripts into the scripts/test/checks/ folder. Discussion of some specific checktests design in users question is welcome.
 
-7. A check test should never need more than a few seconds to run. If your typical script needs more, try and reduce the number of element or the number of steps.
\ No newline at end of file
+7. A check test should never need more than a few seconds to run. If your typical script needs more, try and reduce the number of element or the number of steps.

=== modified file 'scripts/test/checks/checkList.py'
--- scripts/test/checks/checkList.py	2011-02-23 15:50:17 +0000
+++ scripts/test/checks/checkList.py	2011-03-04 20:09:03 +0000
@@ -1,16 +1,15 @@
 # encoding: utf-8
 # 2011 © Bruno Chareyre <bruno.chareyre@xxxxxxxxxxx>
-import math,os,sys
+import yade,math,os,sys
 
-#List your scripts here
-for script in ["checkTestDummy","checkTestTriax"]:
-	try:
-	 	print "###################################"
-		print "running: ",script
-		execfile(checksPath+"/"+script+".py")
-		print "___________________________________"
-	except:
-		print script," failure"
-	#this "else" is redundant with scriipt output, not needed
-	#else:
-		#print script," sucess, inspect results."
+scriptsToRun=os.listdir(checksPath)
+for script in scriptsToRun:
+	if (script[len(script)-3:]==".py" and not(script=="checkList.py")):
+		try:
+	 		print "###################################"
+			print "running: ",script
+			execfile(checksPath+"/"+script)
+			print "___________________________________"
+		except:
+			print script," failure"
+		O.reset()

=== added file 'scripts/test/checks/checkWeight.py'
--- scripts/test/checks/checkWeight.py	1970-01-01 00:00:00 +0000
+++ scripts/test/checks/checkWeight.py	2011-03-04 20:09:03 +0000
@@ -0,0 +1,58 @@
+# -*- coding: utf-8
+
+# Several spheres falling down into the box.
+# Their weight is measured and compares with real mass particles
+
+from yade import utils,pack,log,export,geom
+
+tc=0.001
+en=.003
+es=.003
+frictionAngle=radians(35)
+density=2300
+
+params=utils.getViscoelasticFromSpheresInteraction(tc,en,es)
+defMat=O.materials.append(ViscElMat(density=density,frictionAngle=frictionAngle,**params)) # **params sets kn, cn, ks, cs
+
+
+O.dt=.1*tc # time step
+rad=0.2 # particle radius
+tolerance = 0.0001
+
+
+SpheresID=[]
+SpheresID+=O.bodies.append(pack.regularHexa(pack.inSphere((Vector3(0.0,0.0,0.0)),0.5),radius=rad,gap=rad*0.5,material=defMat))
+
+floorId=[]
+floorId+=O.bodies.append(geom.facetBox((0,0,0),(0.6,0.6,0.6),material=defMat)) #Floor
+
+#Calculate the weight of spheres
+sphMass = utils.getSpheresVolume()*density*9.81
+
+
+# Create engines
+O.engines=[
+	ForceResetter(),
+	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
+	InteractionLoop(
+		[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
+		[Ip2_ViscElMat_ViscElMat_ViscElPhys()],
+		[Law2_ScGeom_ViscElPhys_Basic()],
+	),
+	GravityEngine(gravity=[0.0,0.0,-9.81]),
+	NewtonIntegrator(damping=0.0)
+]
+
+
+O.run(10000)
+O.wait()
+curForce = utils.sumForces(ids=floorId,direction=Vector3(0,0,1))*(-1)
+print ("Precalculated weight %f" % sphMass)
+print ("Obtained weight %f" % curForce)
+
+if (((sphMass-curForce)/curForce)<tolerance):
+	print "checkWeight test is success"
+else:
+	print "checkWeight test is failed!"
+	RuntimeError()
+