← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3821: Add billiard example script.

 

------------------------------------------------------------
revno: 3821
committer: Anton Gladky <gladk@xxxxxxxxxx>
timestamp: Sun 2014-02-16 18:35:46 +0100
message:
  Add billiard example script.
added:
  examples/billiard.py


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== added file 'examples/billiard.py'
--- examples/billiard.py	1970-01-01 00:00:00 +0000
+++ examples/billiard.py	2014-02-16 17:35:46 +0000
@@ -0,0 +1,58 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# The script was implemented to check the following task
+# http://math.stackexchange.com/questions/658871/perfectly-centered-break-of-a-perfectly-aligned-pool-ball-rack/659318#659318
+
+massBall   = 1.0
+radiusBall = 1.0
+rowsN = 5
+velBall = 10.0
+
+vBall = 4.0/3.0 * math.pi * math.pow(radiusBall, 3.0)
+rhoBall = massBall/vBall
+
+
+## PhysicalParameters 
+Density=rhoBall
+frictionAngle=0.0
+kn = 10e+11
+ks = 10e+11
+cn = 0.0
+cs = 0.0
+
+## Import wall's geometry
+param = {'kn':kn*2.0, 'ks':ks*2.0, 'cn':cn*2.0, 'cs':cs*2.0}
+sphereMat=O.materials.append(ViscElMat(density=Density,frictionAngle=frictionAngle,**param))
+
+## Spheres
+sphereIds = []
+for r in range(0,rowsN):
+  yPos = r*pow(3.0, 1.0/2.0)*radiusBall
+  for i in range(r+1):
+    xPos = i*2*radiusBall - r*pow(radiusBall, 3.0/2.0)
+    sphereIds.append(O.bodies.append(sphere([xPos,yPos,0.0],radiusBall,material=sphereMat)))
+
+## schlagBall
+
+schlagBall = O.bodies.append(sphere([0.0,-2.0*radiusBall,0.0],radiusBall,material=sphereMat))
+
+O.bodies[schlagBall].state.vel=Vector3(0,velBall,0)
+## Timestep 
+O.dt=.01*PWaveTimeStep()
+
+## 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()],
+  ),
+  NewtonIntegrator(damping=0),
+]
+
+from yade import qt
+qt.View()
+#O.run(int(0.3/O.dt), True)