yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #09871
Re: [Question #251510]: Loop - array -->Find out the strength needed to move each particle
Question #251510 on Yade changed:
https://answers.launchpad.net/yade/+question/251510
rayolau posted a new comment:
Hi Jan, thanks for the above replies. I managed to apply the force on
the corresponding Clump Id.
The code I've written does not give any error, but I can not determine
the force needed to move each of the selected stones strength. I made a
loop, which establish that the position was compared on the x axis
before applying the force (b.state.pos [0]) and after applying the force
position (g.state.pos [0])
It does not work well, they are always the same ... I think it's because
the new position is not updated after applying increasing force
fx=fx+0.01
Any idea to achieve my goal?
Thank you very much,
Laura.
The code:
from yade import pack, qt, plot, export
import numpy as np
##****************************************************************************************************
####### MATERIAL
##****************************************************************************************************
Mat2=O.materials.append(FrictMat(
young=27e9,poisson=0.30,density=4400,
frictionAngle=0.7))
##****************************************************************************************************
####### LOAD GRANULAR BED
##****************************************************************************************************
O.load('/home/.../...yade')
##****************************************************************************************************
####### ENGINES
##****************************************************************************************************
O.engines=[
ForceResetter(),
InsertionSortCollider(
[Bo1_Sphere_Aabb(),
Bo1_Facet_Aabb(),
Bo1_Box_Aabb(),
Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),
Ig2_Facet_Sphere_ScGeom(),
Ig2_Wall_Sphere_ScGeom(),
Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
PyRunner(command='DetermineForceRequired()',
iterPeriod=1 ,initRun=True,label='checker'),
NewtonIntegrator(damping=0.5,gravity=(0,-9.81,0),label='newton')
]
O.dt=utils.PWaveTimeStep()
##****************************************************************************************************
####### DETERMINATION OF THE FORCE NEEDED TO MOVE EACH CLUMP
##****************************************************************************************************
def DetermineForceRequired():
xmax=0.9
xmin=0.1
zmax=1.335
zmin=0.1
yPOSITION=0.25
clumpsIds=[] #array to store the identity of certain Clumps
volumen=[]
density=2700
ArrayALLclumps=[]
ArrayRiddle=[]
arrayFORCE=[]
arrayRESULTS=[]
for i in range(0,len(O.bodies)):
if O.bodies[i].isClump==True and xmin<O.bodies[i].state.pos[0]<xmax and zmin<O.bodies[i].state.pos[2]<zmax:
clumpsIds.append(O.bodies[i].clumpId)
for ii in clumpsIds:
b=O.bodies[ii]
if b.state.pos[1]>yPOSITION:
#...
#Code to get the area of the clumps
#...
peso=b.state.mass
vol=b.state.mass/density
volumen.append([vol])
id_ball=ii
AREA=areaP/areaM
Diameter=vol/areaM
ArrayALLclumps.append([areaP,ii,peso,Diameter,AREA,areaM,b.state.pos[0]])
np.savetxt('ALL_CLUMPS.out',ArrayALLclumps,delimiter=',')
if AREA>0.5:
ArrayRiddle.append([ii,AREA,areaP,peso,Diameter,b.state.pos[0]])
np.savetxt('Riddle.out',ArrayRiddle,delimiter=',')
for ll in range(0,len(ArrayRiddle)):
g=O.bodies[ArrayRiddle[ll][0]]
for mm in g.shape.members.keys():
CHANGEcolor=O.bodies[mm]
CHANGEcolor.shape.color=Vector3(ArrayRiddle[ll][2],0,1)
fx=0.01
fy=0
fz=0
O.forces.addF(ArrayRiddle[ll][0],(fx,fy,fz))
arrayFORCE.append([ArrayRiddle[ll][0],fx,g.state.pos[0]])
np.savetxt('arrayFORCE.out',arrayFORCE,delimiter=',')
while b.state.pos[0]==g.state.pos[0]: #How I can update the new position to exit the loop?
fx=fx+0.01
fy=0
fz=0
O.forces.addF(ArrayRiddle[ll][0],(fx,fy,fz))
number=fx/Diameter
arrayRESULTS.append([ArrayRiddle[ll][0],number,fx,g.state.pos[0]])
np.savetxt('RESULTS.out',arrayRESULTS,delimiter=',')
######--> Set value to zero before proceeding to the next clump
areaM=0
areaP=0
fx=0
number=0
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.