Example #1
0


###############################################################################################################
# Creation of 6 walls at the limit of the simulation domain

# defintiion of the material for walls
O.materials.append(FrictMat(young=50e6,poisson=.5,frictionAngle=0.0,density=3000,label='walls'))

## create walls around the packing
wallOversizeFactor=1.001
thickness=0.00001;
#bottom box
center= ((lowerCornerW[0]+upperCornerW[0])/2,lowerCornerW[1]-thickness/2.0,(lowerCornerW[2]+upperCornerW[2])/2)
halfSize= (wallOversizeFactor*fabs(lowerCornerW[0]-upperCornerW[0])/2+thickness,thickness/2.0,wallOversizeFactor*fabs(lowerCornerW[2]-upperCornerW[2])/2+thickness)
b1=utils.box(center=[center[0],center[1],center[2]],extents=[halfSize[0],halfSize[1],halfSize[2]],color=[0,1,0],fixed=True,wire=True,material='walls')
O.bodies.append(b1)
#--
#Top box
center=((lowerCornerW[0]+upperCornerW[0])/2,upperCornerW[1]+thickness/2.0,(lowerCornerW[2]+upperCornerW[2])/2)
halfSize =(wallOversizeFactor*fabs(lowerCornerW[0]-upperCornerW[0])/2+thickness,thickness/2.0,wallOversizeFactor*fabs(lowerCornerW[2]-upperCornerW[2])/2+thickness)
b2=utils.box(center=[center[0],center[1],center[2]],extents=[halfSize[0],halfSize[1],halfSize[2]],color=[0,1,0],fixed=True,wire=True,material='walls')
O.bodies.append(b2)
#--
center=(lowerCornerW[0]-thickness/2.0,(lowerCornerW[1]+upperCornerW[1])/2,(lowerCornerW[2]+upperCornerW[2])/2)
halfSize=(thickness/2.0,wallOversizeFactor*fabs(lowerCornerW[1]-upperCornerW[1])/2+thickness,wallOversizeFactor*fabs(lowerCornerW[2]-upperCornerW[2])/2+thickness)
b3=utils.box(center=[center[0],center[1],center[2]],extents=[halfSize[0],halfSize[1],halfSize[2]],color=[0,1,0],fixed=True,wire=True,material='walls')
O.bodies.append(b3)
#--
center=(upperCornerW[0]+thickness/2.0,(lowerCornerW[1]+upperCornerW[1])/2,(lowerCornerW[2]+upperCornerW[2])/2)
halfSize=(thickness/2.0,wallOversizeFactor*fabs(lowerCornerW[1]-upperCornerW[1])/2+thickness,wallOversizeFactor*fabs(lowerCornerW[2]-upperCornerW[2])/2+thickness)
Example #2
0
    InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),
                     Ig2_Box_Sphere_ScGeom()],
                    [Ip2_FrictMat_FrictMat_FrictPhys()],
                    [Law2_ScGeom_FrictPhys_CundallStrack()]),
    NewtonIntegrator(damping=.2, gravity=(0, 0, -9.81)),
    ###
    ### NOTE this extra engine:
    ###
    ### You want snapshot to be taken every 1 sec (realTimeLim) or every 50 iterations (iterLim),
    ### whichever comes soones. virtTimeLim attribute is unset, hence virtual time period is not taken into account.
    PyRunner(iterPeriod=20, command='myAddPlotData()')
]
from yade import utils
O.bodies.append(
    utils.box(center=[0, 0, 0],
              extents=[.5, .5, .5],
              fixed=True,
              color=[1, 0, 0]))
O.bodies.append(utils.sphere([0, 0, 2], 1, color=[0, 1, 0]))
O.dt = .002 * utils.PWaveTimeStep()

############################################
##### now the part pertaining to plots #####
############################################

from math import *
from yade import plot
## we will have 2 plots:
## 1. t as function of i (joke test function)
## 2. i as function of t on left y-axis ('|||' makes the separation) and z_sph, v_sph (as green circles connected with line) and z_sph_half again as function of t
plot.plots = {'i': ('t'), 't': ('z_sph', None, ('v_sph', 'go-'), 'z_sph_half')}
Example #3
0
# Test script for OpenGL from python (and from other threads in general)
# With GL locking, 1 view seems to work reliably, not two views, though.
#
# Some drivers (nvidia) raise XBadAccess if there is an attempt to access
#  OpenGL context concurrently from different threads.
# Other drivers (intel, at least on my laptop) freeze the videocard completely
#  if that is the case.
#
# You can enable the "if False:" part (say "if True:" instead) to see what
# it does in your case.
#

from yade import qt
from yade import utils

O.bodies.append(utils.box([0, 0, 0], [1, 1, 1], color=[1, 0, 0]))
O.bodies.append(utils.sphere([0, 2, 0], 1, color=[0, 1, 0]))

print 'Begin here.'
qt.View()
print 'Created view'
glv0 = qt.GLViewer()
print 'view #0'  # get GLViewer instance for the primary view
glv0.grid = True, True, False
print 'grid x,y'
glv0.axes = True
print 'axes shown'
glv0.screenSize = 200, 200
print 'screen size set to 200x200'
glv0.center(True)
print 'median center'  # median center - will fallback since there are only 2 bodies
Example #4
0
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()]
	),
	NewtonIntegrator(damping=.2,gravity=(0,0,-9.81)),
	###
	### NOTE this extra engine:
	###
	### You want snapshot to be taken every 1 sec (realTimeLim) or every 50 iterations (iterLim),
	### whichever comes soones. virtTimeLim attribute is unset, hence virtual time period is not taken into account.
	PyRunner(iterPeriod=20,command='myAddPlotData()')
]
from yade import utils
O.bodies.append(utils.box(center=[0,0,0],extents=[.5,.5,.5],fixed=True,color=[1,0,0]))
O.bodies.append(utils.sphere([0,0,2],1,color=[0,1,0]))
O.dt=.002*utils.PWaveTimeStep()


############################################
##### now the part pertaining to plots #####
############################################

from math import *
from yade import plot
## we will have 2 plots:
## 1. t as function of i (joke test function)
## 2. i as function of t on left y-axis ('|||' makes the separation) and z_sph, v_sph (as green circles connected with line) and z_sph_half again as function of t
plot.plots={'i':('t'),'t':('z_sph',None,('v_sph','go-'),'z_sph_half')}
Example #5
0
    ]),
    InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),
                     Ig2_Box_Sphere_ScGeom()], [
                         Ip2_FrictMat_FrictMat_FrictPhys(),
                     ], [
                         Law2_ScGeom_FrictPhys_CundallStrack(),
                     ]),
    PyRunner(iterPeriod=100,
             command='myAddPlotData()',
             label='plotDataCollector'),
    NewtonIntegrator(damping=0.4,
                     gravity=(0, 0,
                              gravity))  ## here we use the 'gravity' parameter
]
O.bodies.append([
    utils.box([0, 50, 0], extents=[1, 50, 1], fixed=True, color=[1, 0, 0]),
    utils.sphere([0, 0, 10], 1, color=[0, 1, 0])
])

O.bodies[1].state.vel = (0, initialSpeed, 0)  ## assign initial velocity

O.dt = .8 * utils.PWaveTimeStep()


## o.saveTmp('initial')
def myAddPlotData():
    s = O.bodies[1]
    plot.addData({
        't': O.time,
        'y_sph': s.state.pos[1],
        'z_sph': s.state.pos[2]
Example #6
0
             label='walls'))

## create walls around the packing
wallOversizeFactor = 1.001
thickness = 0.00001
#bottom box
center = ((lowerCornerW[0] + upperCornerW[0]) / 2,
          lowerCornerW[1] - thickness / 2.0,
          (lowerCornerW[2] + upperCornerW[2]) / 2)
halfSize = (wallOversizeFactor * fabs(lowerCornerW[0] - upperCornerW[0]) / 2 +
            thickness, thickness / 2.0,
            wallOversizeFactor * fabs(lowerCornerW[2] - upperCornerW[2]) / 2 +
            thickness)
b1 = utils.box(center=[center[0], center[1], center[2]],
               extents=[halfSize[0], halfSize[1], halfSize[2]],
               color=[0, 1, 0],
               fixed=True,
               wire=True,
               material='walls')
O.bodies.append(b1)
#--
#Top box
center = ((lowerCornerW[0] + upperCornerW[0]) / 2,
          upperCornerW[1] + thickness / 2.0,
          (lowerCornerW[2] + upperCornerW[2]) / 2)
halfSize = (wallOversizeFactor * fabs(lowerCornerW[0] - upperCornerW[0]) / 2 +
            thickness, thickness / 2.0,
            wallOversizeFactor * fabs(lowerCornerW[2] - upperCornerW[2]) / 2 +
            thickness)
b2 = utils.box(center=[center[0], center[1], center[2]],
               extents=[halfSize[0], halfSize[1], halfSize[2]],
               color=[0, 1, 0],
O.trackEnergy=True
O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom6D()],	
		[Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
		[law]
	),
	GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=50),
	NewtonIntegrator(damping=damping,kinSplit=True,gravity=(0,0,-g)),
	PyRunner(iterPeriod=20,command='myAddPlotData()')
]

from yade import utils
O.bodies.append(utils.box(center=[0,0,0],extents=[.5,.5,.5],fixed=True,color=[1,0,0],material='granular_material'))
O.bodies.append(utils.sphere([0,0,2],1,color=[0,1,0],material='granular_material'))
if(two_spheres):
	O.bodies.append(utils.sphere([0,0,4],1,color=[0,1,0],material='granular_material'))
O.dt=.002*utils.PWaveTimeStep()
O.bodies[1].state.angVel[1]=angVel
if(rotate_in_two_directions):
	O.bodies[1].state.angVel[2]=angVel

############################################
##### now the part pertaining to plots #####
############################################

from math import *
from yade import plot
## we will have 2 plots:
Example #8
0
# Geometry sphere and box
r2=1e-2 # radii [m]
p2=[r2,0,0] # center positions [m]
center=[-r2/2.,0,0] # center [m]
extents=[r2/2.,3*r2,3*r2] # half edge lenght [m]

#__________________________________________________________________
# Material
young=600.0e6 # [N/m^2]
poisson=0.6 
density=2.60e3 # [kg/m^3]
frictionAngle=26 # [°]

# Append geometry and material
O.materials.append(FrictMat(young=young,poisson=poisson,density=density,frictionAngle=frictionAngle))
O.bodies.append(utils.box(center=center,extents=extents,fixed=True,wire=True)) # body id=0
O.bodies.append(utils.sphere(p2,r2,fixed=True,wire=True)) # body id=1
m_sphere=O.bodies[1].state.mass
O.bodies[0].state.mass=m_sphere # set the mass of the box the same as the mass of the sphere
O.bodies[1].state.blockedDOFs='XYZ' # block particles rotations

#__________________________________________________________________
# list of engines
O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_MindlinPhys(label='damping')],
		[Law2_ScGeom_MindlinPhys_Mindlin(label='contactLaw')]
	),
Example #9
0
O.materials.append(FrictMat(young=30e9,density=density,poisson=.3)) ## use the 'density' parameter here

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb(),]),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys(),],
		[Law2_ScGeom_FrictPhys_CundallStrack(),]
	),
	PyRunner(iterPeriod=100,command='myAddPlotData()',label='plotDataCollector'),
	NewtonIntegrator(damping=0.4,gravity=(0,0,gravity))## here we use the 'gravity' parameter
]
O.bodies.append([
	utils.box([0,50,0],extents=[1,50,1],fixed=True,color=[1,0,0]),
	utils.sphere([0,0,10],1,color=[0,1,0])
])

O.bodies[1].state.vel=(0,initialSpeed,0) ## assign initial velocity

O.dt=.8*utils.PWaveTimeStep()
## o.saveTmp('initial')
def myAddPlotData():
	s=O.bodies[1]
	plot.addData({'t':O.time,'y_sph':s.state.pos[1],'z_sph':s.state.pos[2]})
plot.plots={'y_sph':('z_sph',)}

# run 30000 iterations
O.run(20000,True)
Example #10
0
# Test script for OpenGL from python (and from other threads in general)
# With GL locking, 1 view seems to work reliably, not two views, though.
#
# Some drivers (nvidia) raise XBadAccess if there is an attempt to access
#  OpenGL context concurrently from different threads.
# Other drivers (intel, at least on my laptop) freeze the videocard completely
#  if that is the case.
#
# You can enable the "if False:" part (say "if True:" instead) to see what
# it does in your case.
#

from yade import qt
from yade import utils

O.bodies.append(utils.box([0,0,0],[1,1,1],color=[1,0,0]))
O.bodies.append(utils.sphere([0,2,0],1,color=[0,1,0]))

print('Begin here.')
qt.View(); print('Created view')
glv0=qt.GLViewer(); print('view #0') # get GLViewer instance for the primary view
glv0.grid=True,True,False; print('grid x,y')
glv0.axes=True; print('axes shown')
glv0.screenSize=200,200; print('screen size set to 200x200')
glv0.center(True); print('median center') # median center - will fallback since there are only 2 bodies

##
## !!! If you enable this, you may crash your machine !!!
##
if False: 
	glv1=qt.View(); print('Created 2nd view') # create new view
Example #11
0
    ForceResetter(),
    InsertionSortCollider([Bo1_Sphere_Aabb(),
                           Bo1_Box_Aabb()]),
    InteractionLoop([Ig2_Sphere_Sphere_ScGeom6D(),
                     Ig2_Box_Sphere_ScGeom6D()],
                    [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()], [law]),
    GlobalStiffnessTimeStepper(active=1, timeStepUpdateInterval=50),
    NewtonIntegrator(damping=damping, kinSplit=True, gravity=(0, 0, -g)),
    PyRunner(iterPeriod=20, command='myAddPlotData()')
]

from yade import utils
O.bodies.append(
    utils.box(center=[0, 0, 0],
              extents=[.5, .5, .5],
              fixed=True,
              color=[1, 0, 0],
              material='granular_material'))
O.bodies.append(
    utils.sphere([0, 0, 2], 1, color=[0, 1, 0], material='granular_material'))
if (two_spheres):
    O.bodies.append(
        utils.sphere([0, 0, 4],
                     1,
                     color=[0, 1, 0],
                     material='granular_material'))
O.dt = .002 * utils.PWaveTimeStep()
O.bodies[1].state.angVel[1] = angVel
if (rotate_in_two_directions):
    O.bodies[1].state.angVel[2] = angVel