yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #23327
Re: [Question #691285]: Extract Normals and Shears/tangentials forces on a ballMill
Question #691285 on Yade changed:
https://answers.launchpad.net/yade/+question/691285
NGANDU KALALA Gauthier posted a new comment:
Hi Jan, and Jerome,
Thank'you for your advices. It's been very helpful. However, I followed
the recording method proposed by Jan, the program runs, but i can't get
my data recorded, and i get the following error, some times after
launching the simulation.
AttributeError Traceback (most recent call last)
/usr/bin/yade in <module>()
/usr/bin/yade in exportForces()
119 # add it to the data collection
120 d = dict(normalForce=fn,shearForce=fs,contactPoint=cp,penetrationDepth=pd,id1=i.id1,id2=i.id2)
--> 121 data.push(d)
122 # save
123 fName = "data{:06d}.json".format(O.iter)
AttributeError: 'list' object has no attribute 'push'
# this is the MWE i used:
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_MindlinPhys()],
[Law2_ScGeom_MindlinPhys_Mindlin()]
),
RotationEngine(ids=mill,rotationAxis=[0,1,0],rotateAroundZero=True,angularVelocity=omega),
NewtonIntegrator(damping=0,gravity=[0,0,-9.81]),
VTKRecorder(fileName=os.getcwd()+'/output/', recorders=['spheres','facets','velocity'],iterPeriod=int(math.ceil(tRec/O.dt))),
PyRunner(command='exportForces()',iterPeriod=int(math.ceil(tRec/O.dt))),
]
import json
def exportForces():
data = [] # list of data for each interaction
for i in O.interactions:
b1,b2 = [O.bodies[i] for i in (i.id1,i.id2)]
# skip interactions not containing facets
if not (isinstance(b1.shape,Facet) or isinstance(b2.shape,Facet)):
continue
# gather desired values
fn = i.phys.normalForce
fs = i.phys.shearForce
cp = i.geom.contactPoint
pd = i.geom.penetrationDepth
# add it to the data collection
d = dict(normalForce=fn,shearForce=fs,contactPoint=cp,penetrationDepth=pd,id1=i.id1,id2=i.id2)
data.push(d)
# save
fName = "data{:06d}.json".format(O.iter)
with open(fName,"w") as f:
json.dump(data,f,indent=2)
# The simulation is run until reaching its end time.
O.run(int(math.ceil(tEnd/O.dt))+1
--
You received this question notification because your team yade-users is
an answer contact for Yade.