← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3756: add some more examples, show same functionality as with chained cylinders

 

------------------------------------------------------------
revno: 3756
committer: Klaus Thoeni <klaus.thoeni@xxxxxxxxx>
timestamp: Thu 2015-12-10 23:21:33 +1100
message:
  add some more examples, show same functionality as with chained cylinders
added:
  examples/grids/CohesiveGridConnectionSphere.py
  examples/grids/GridConnection_Spring.py
  examples/grids/Simple_GridConnection_Falling.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/grids/CohesiveGridConnectionSphere.py'
--- examples/grids/CohesiveGridConnectionSphere.py	1970-01-01 00:00:00 +0000
+++ examples/grids/CohesiveGridConnectionSphere.py	2015-12-10 12:21:33 +0000
@@ -0,0 +1,77 @@
+# encoding: utf-8
+"""
+Same example as CohesiveCylinderSphere.py but using gridConnections instead of chainedCylinder.
+"""
+from yade import qt
+from yade.gridpfacet import *
+from numpy import linspace
+
+qt.View()
+
+### Engines need to be defined first since the function gridConnection creates the interaction
+O.engines=[
+	ForceResetter(),
+	InsertionSortCollider([
+		Bo1_Sphere_Aabb(),
+		Bo1_GridConnection_Aabb(),
+	]),
+	InteractionLoop(
+		# Geometric interactions
+		[
+          Ig2_GridNode_GridNode_GridNodeGeom6D(),
+          Ig2_Sphere_GridConnection_ScGridCoGeom(),	# used for the cohesive sphere-cylinder interaction
+        ],
+		[
+		# Interaction phusics
+          Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False),
+        ],
+		# Interaction law
+		[
+          Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
+          Law2_ScGridCoGeom_CohFrictPhys_CundallStrack(),	# used for the cohesive sphere-cylinder interaction
+        ]
+	),
+	NewtonIntegrator(gravity=(0,0,0),damping=0.3,label='newton'),
+	PyRunner(command='main()',iterPeriod=1000),
+]
+
+O.dt=5e-07
+
+O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='gridNodeMat'))
+
+O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=1e5,shearCohesion=1e5,momentRotationLaw=True,label='gridCoMat'))
+
+O.materials.append(CohFrictMat(young=8e5,poisson=0.3,density=4e3,frictionAngle=radians(30),normalCohesion=4e4,shearCohesion=1e5,momentRotationLaw=False,label='spheremat'))
+
+rCyl=0.006
+nL=15
+L=0.3
+
+### Create all nodes first :
+nodesIds=[]
+for i in linspace(0,L,nL):
+  nodesIds.append( O.bodies.append(
+    gridNode([i,0,0],rCyl,wire=False,fixed=False,material='gridNodeMat') ) )
+
+### Now create connection between the nodes
+for i,j in zip( nodesIds[:-1], nodesIds[1:]):
+  O.bodies.append( gridConnection(i,j,rCyl,
+                                  material='gridCoMat'
+                                  ) )
+
+### Set fixed nodes
+O.bodies[nodesIds[0]].state.blockedDOFs='xyzXYZ'
+O.bodies[nodesIds[-1]].state.blockedDOFs='xyzXYZ'
+
+IdSphere=O.bodies.append(sphere([0.15,0,2.*rCyl],rCyl,wire=False,fixed=False,material='spheremat'))
+
+def main():
+	global Fn,Ft
+	if O.iter>50000:
+		O.bodies[IdSphere].dynamic=False
+		O.bodies[IdSphere].state.vel[2]=0.1
+
+
+O.saveTmp()
+
+

=== added file 'examples/grids/GridConnection_Spring.py'
--- examples/grids/GridConnection_Spring.py	1970-01-01 00:00:00 +0000
+++ examples/grids/GridConnection_Spring.py	2015-12-10 12:21:33 +0000
@@ -0,0 +1,83 @@
+#--- bruno.chareyre@xxxxxxxxxxx ---
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Experiment beam-like behaviour with chained cylinders + CohFrict connexions
+
+from yade.gridpfacet import *
+
+young=1.0e10
+poisson=4
+density=2.60e3 
+frictionAngle=radians(30)
+O.materials.append(CohFrictMat(young=young,poisson=poisson,density=density,frictionAngle=frictionAngle,normalCohesion=1e13,shearCohesion=1e13,momentRotationLaw=True,label='mat'))
+
+
+O.engines=[
+	ForceResetter(),
+	InsertionSortCollider([
+		Bo1_Sphere_Aabb(),
+		Bo1_GridConnection_Aabb(),
+	]),
+	InteractionLoop(
+		# Geometric interactions
+		[
+          Ig2_GridNode_GridNode_GridNodeGeom6D(),
+          Ig2_Sphere_GridConnection_ScGridCoGeom(),	# used for the cohesive sphere-cylinder interaction
+        ],
+		[
+		# Interaction phusics
+          Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=True),
+        ],
+		# Interaction law
+		[
+          Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),
+          Law2_ScGridCoGeom_CohFrictPhys_CundallStrack(),	# used for the cohesive sphere-cylinder interaction
+        ]
+	),
+    GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8,label='ts'),
+    NewtonIntegrator(gravity=(0,-9.81,0),damping=0.15,label='newton'),
+    PyRunner(iterPeriod=500,command='history()'),
+
+]
+
+### Generate a spiral
+
+### Create all nodes first
+nodesIds=[]
+rCyl=0.005
+Ne=200
+for i in range(0, Ne+1):
+	omega=60.0/float(Ne); hy=0.10; hz=0.15;
+	px=float(i)*(omega/60.0); py=sin(float(i)*omega)*hy; pz=cos(float(i)*omega)*hz;
+	nodesIds.append( O.bodies.append( gridNode([px,py,pz],rCyl,wire=False,fixed=False,color=Vector3(0.6,0.5,0.5),material='mat') ) )
+
+### Now create connection between the nodes
+for i,j in zip( nodesIds[:-1], nodesIds[1:]):
+  O.bodies.append( gridConnection(i,j,rCyl,color=Vector3(0.6,0.5,0.5),material='mat') )
+
+
+def outp(id=1):
+	for i in O.interactions:
+		if i.id1 == 1:
+			print i.phys.shearForce
+			print i.phys.normalForce
+			return  i
+
+O.bodies[Ne-1].state.blockedDOFs='xyzXYZ'
+yade.qt.View();
+
+
+#plot some results
+from yade import plot
+plot.plots={'t':('pos1',None,'vel1')}
+def history():
+  	plot.addData(pos1=O.bodies[0].state.pos[1], # potential elastic energy
+		     vel1=O.bodies[0].state.vel[1],
+		     t=O.time)
+
+#yade.qt.Renderer().bound=True
+plot.plot(subPlots=False)
+O.saveTmp()
+#O.bodies[0].state.angVel=Vector3(0.05,0,0)
+

=== added file 'examples/grids/Simple_GridConnection_Falling.py'
--- examples/grids/Simple_GridConnection_Falling.py	1970-01-01 00:00:00 +0000
+++ examples/grids/Simple_GridConnection_Falling.py	2015-12-10 12:21:33 +0000
@@ -0,0 +1,46 @@
+# encoding: utf-8
+
+from yade import pack,geom,qt
+from yade.gridpfacet import *
+from pylab import *
+qt.View()
+
+
+O.engines=[
+	ForceResetter(),
+	InsertionSortCollider([Bo1_GridConnection_Aabb()]),
+	InteractionLoop(
+		[Ig2_GridNode_GridNode_GridNodeGeom6D()],
+		[Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True,setCohesionOnNewContacts=False)],
+		[Law2_ScGeom6D_CohFrictPhys_CohesionMoment()]
+	),
+	NewtonIntegrator(gravity=(0,0,-10),damping=0.1,label='newton')
+]
+
+
+O.materials.append(CohFrictMat(young=3e2,poisson=0.3,density=1e1,frictionAngle=10,normalCohesion=1e7,shearCohesion=1e7,momentRotationLaw=True,label='mat'))
+
+
+### Parameters ###
+L=0.1 #length [m]
+n=10	#number of nodes for the length	[#]
+r=L/100.	#radius
+color=[255./255.,102./255.,0./255.]
+
+### Create all nodes first
+nodeIds=[]
+for i in range(0,n):
+  nodeIds.append( O.bodies.append( gridNode([i*L/n,0,0],r,wire=False,fixed=False,material='mat',color=color) ) )
+
+### Create connections between the nodes
+connectionIds=[]
+for i,j in zip(nodeIds[:-1],nodeIds[1:]):
+  connectionIds.append( O.bodies.append( gridConnection(i,j,r,color=color) ) )
+
+### Set a fixed node
+O.bodies[0].dynamic=False
+
+O.dt=1e-06
+O.saveTmp()
+
+