← Back to team overview

yade-users team mailing list archive

[Question #685885]: Problem with the combined engine

 

New question #685885 on Yade:
https://answers.launchpad.net/yade/+question/685885

Hi,

I'm new with Yade, and I have problem with combined engine. I want to change the translationAxis and the velocity after a few iterations but I still have an issue about the global variables.
Could you help me?

#!/usr/bin/python
# -*- coding: utf-8 -*-

from __future__ import print_function
from builtins import range
import random
from yade import ymport
from yade import pack, qt

## PhysicalParameters 

## Import geometry 
rod = O.bodies.append(ymport.stl('tool.stl',wire=False,color=[0.31,0.47,0.47]))

# Plate dimension
thickness = 1.0 # cm
width = 5.0 # cm
length = 11.0 # cm
boxMax = (2,2.5,0)

# Spheres
sphereRadius = 0.05 # cm
ndiv_x = length/(2*sphereRadius)
ndiv_y = width/(2*sphereRadius)
ndiv_z = thickness/(2*sphereRadius)
#nbSpheres = (ndiv_x,ndiv_y,ndiv_z)
nbSpheres = (40,40,10)#(110,50,10)
print("Creating %d spheres..."%(nbSpheres[0]*nbSpheres[1]*nbSpheres[2]), end=' ')
for i in range(nbSpheres[0]):
	for j in range(nbSpheres[1]):
		for k in range(nbSpheres[2]):
			x = boxMax[0]-2.0*sphereRadius*(i)
			y = boxMax[1]-2.0*sphereRadius*(j)
			z = boxMax[2]-2.0*sphereRadius*(k)
			r = random.uniform(sphereRadius,sphereRadius)
			fixed = False
			color=[0.21,0.22,0.1]
			if (i==0 or i==nbSpheres[0]-1 or k==nbSpheres[2]-1 or j==0 or j==nbSpheres[1]-1):
				fixed = True
				color=[0.21,0.22,0.3]
			O.bodies.append(sphere([x,y,z],r,color=color,fixed=fixed))
print("done\n")

## Estimate time step
#O.dt=PWaveTimeStep()
O.dt=0.0001

def updateParameters():
	aTime = (O.iter*O.dt)
	if   aTime>0.005: # fist part
		velVec = Vector3(-1,0,0)
		tranVel = 1.0
	transEngine.translationAxis = velVec
	transEngine.velocity = tranVel

## Engines 
O.engines=[
	ForceResetter(), # 0
	InsertionSortCollider([ # 1
		Bo1_Sphere_Aabb(),
		Bo1_Facet_Aabb(),
	]),
	InteractionLoop( # 2
		[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()]
	),
	CombinedKinematicEngine(ids=rod,label='combEngine') + TranslationEngine(translationAxis=(0,0,-1),velocity=0.6) + RotationEngine(rotationAxis=(0,0,-1), angularVelocity=20, rotateAroundZero=True, zeroPoint=(0,0,0)),
	NewtonIntegrator(damping=2.0,gravity=[0,0,-9.81]), # 3
	PyRunner(iterPeriod=1, command='updateParameters()'),
	# save data from Yade's own 3d view
	#qt.SnapshotEngine(fileBase='3d-',iterPeriod=1,label='snapshot'),
	#PyRunner(command='finish()',iterPeriod=10)
]

import sys,time

print("Start simulation: ")
nbIter=60


from yade import qt
v=qt.View()
v.eyePosition=(6,2,2); v.upVector=(-.4,-.4,.8); v.viewDir=(-.9,-.25,-.3); v.axes=False; v.sceneRadius=20

O.stopAtIter=nbIter
O.run()

# this function is called when the simulation is finished
def finish():
	# snapshot is label of qt.SnapshotEngine
	# the 'snapshots' attribute contains list of all saved files
	makeVideo(snapshot.snapshots,'3d.mpeg',fps=1,bps=10)
	O.pause()

#for t in xrange(2):
#	start=time.time();O.run(nbIter);O.wait();finish=time.time() 
#	speed=nbIter/(finish-start); print '%g iter/sec\n'%speed
#print "FINISH"
#quit()

BR
Przemek 

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.