← Back to team overview

yade-users team mailing list archive

Re: [Question #224128]: How to learn and start a 2D simulation in YADE

 

Question #224128 on Yade changed:
https://answers.launchpad.net/yade/+question/224128

Fu zuoguang gave more information on the question:
Dear Jan Stránsky :
     Thanks for helping me last time, now my work goes ahead and has some other prombles of course, which are as follow:
(1). I can successfully use the order "O.run(),O.wait()" for a correct inheriting.
(2). I can successfully use the orders you suggested me last time for getting the results of particles after the simulation is over, which can show as follows:

f = open("-txt",'w')
for b in O.bodies:
  pos = b.state.pos   
  dspl = b.state.displ() 
  r = b.shape.radius 
  f.write('%d %g %g %g %g %g %g %g'%(b.id,pos[0],pos[1],pos[2],r,dspl[0],dspl[1],dspl[2]))
f.close()

But it is not appropriate for me to borrow them directly for the reason that I should do this operation only for particles in Bodies which may include three types of classes-sphere, wall, box.
So,I need to pick all spheres out from bodies before using the orders above. For this purpose, I have created a simple script for testing it, which is as follow:

O.bodies.append([
        utils.sphere(center=(0,0,0),radius=.5,fixed=True,color=[0,1,0]),
        utils.sphere((0,0,2),.5,color=[0,1,0])
        ])
O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_L3Geom()],      
      [Ip2_FrictMat_FrictMat_FrictPhys()], 
      [Law2_L3Geom_FrictPhys_ElPerfPl()]  
   ),
   GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.1)
]
O.dt=.5e-3*utils.PWaveTimeStep()
O.saveTmp()
O.run(20000,True)
f = open('result.txt','w')
for b in O.bodies:
    if isinstance(b.state,Sphere):
       pos = b.state.pos
       dspl = b.state.displ()
       f.write('%d %g %g %g %g %g %g'%(b.id,pos[0],pos[1],pos[2],dspl[0],dspl[1],dspl[2]))
f.close() 

The 'result.txt' can record nothing without being warned any error after
the simulation is finished and I modify this script as that(deleting the
command 'if isinstance(b.state,Sphere):'):

O.bodies.append([
        utils.sphere(center=(0,0,0),radius=.5,fixed=True,color=[0,1,0]),
        utils.sphere((0,0,2),.5,color=[0,1,0])
        ])
O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_L3Geom()],      
      [Ip2_FrictMat_FrictMat_FrictPhys()], 
      [Law2_L3Geom_FrictPhys_ElPerfPl()]  
   ),
   GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.1)
]
O.dt=.5e-3*utils.PWaveTimeStep()
O.saveTmp()
O.run(20000,True)
f = open('result.txt','w')
for b in O.bodies:
    pos = b.state.pos
    dspl = b.state.displ()
    f.write('%d %g %g %g %g %g %g'%(b.id,pos[0],pos[1],pos[2],dspl[0],dspl[1],dspl[2]))
f.close() 

I get a correct running. I don not understand why?

SEEKING YOUR HELP!

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.