Apply force on sphere particles

Asked by Son Tung Dang

Hello,
I would like to apply a force on particles. I tried with this following code:

#!/usr/bin/python
# -*- coding: utf-8 -*-
from yade import pack,ymport,export,geom,bodiesHandling,qt
import array as arr
import numpy
import math

import os
import errno

rad,gap=.15,.02

#Add material
O.materials.append(FrictMat(young=10e9,poisson=.25,frictionAngle=0.5,density=1e3,label='Par'))

#Parameters, which will be passed into facets creators
kwMeshes={'color':[1,1,0],'wire':True,'dynamic':False,'material':0}
oriBody = Quaternion(Vector3(1,0,0),(pi/2.0))
# Cylinder
O.bodies.append(geom.facetCylinder((0.0,0.0,0.0),radius=2.0,height=20.0,orientation=oriBody,segmentsNumber=10,wallMask=4,**kwMeshes))
# Sphere Particles
s1=utils.sphere([0,1.7,1.0],.5,color=(1,0,1),material='Par')
s1.state.blockedDOFs='y'
s1.state.vel=(0,0.0,0)
O.bodies.append(s1)

s2=utils.sphere([1.2,3.7,0.8],.35,color=(0,1,1),material='Par')
s2.state.blockedDOFs='y'
s2.state.vel=(0,0.0,0)
O.bodies.append(s2)

O.bodies.append(wall((0,0,-10),axis=2))

def LorrentzForce():
 # define the force applied on particles caused by magnetic fields
 for b in O.bodies:
  if isinstance(b.shape,Sphere):
   ftest=(0,20000.0,0)
   O.forces.addF(b.id,ftest)
   print(O.forces.f(b.id))

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()],label='collider'),
 InteractionLoop(
 [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
 [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
 [Law2_ScGeom_ViscElPhys_Basic()]
 ,label = 'interactionLoop'),
 PyRunner(command='LorrentzForce()',iterPeriod=1,label='ApplyForce'),
 NewtonIntegrator(damping=.1,exactAsphericalRot=True,gravity=(0.0,0.0,0.0)),

O.dt=PWaveTimeStep()
O.run(1,True)

But particles didn't move at all.
Could you please explain what i have done wrong?
Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Son Tung Dang
Solved:
Last query:
Last reply:
Revision history for this message
mohsen (agha-mohsena) said :
#1

Hi Son
You blocked the transition in y direction:
s1.state.blockedDOFs='y'

just delete this line and the the spheres would move

Regards

Revision history for this message
mohsen (agha-mohsena) said :
#2

The other one:

you should close the O.engines list by inserting ]; i.e.:

....
  NewtonIntegrator(damping=.1,exactAsphericalRot=True,gravity=(0.0,0.0,0.0)),
]

Revision history for this message
Son Tung Dang (sontd1090) said :
#3

It worked. Thanks a lot!