← Back to team overview

yade-users team mailing list archive

Re: [Question #223165]: How to save data into a file?

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
Hello Alam,


> 1. The code saves the initial position of the particle in the file. Is
> there any way I can save the position of particle at each iteration.
>
>
Yes :-) it depends on what you want:
- for each iteration to have separate file:

def savePos():


> 2. The number of interactions are not saved in the file and is there a
> way I can save contact point of particle{70} interaction, normal etc?
>
> The code is given below. (I am jointly working on this project with
> Mohamad so you might have seen this code before) :-
>
> O.bodies.append(utils.geom.facetCylinder((.5,.5,.5),radius=0.5,height=1,segmentsNumber=30,
> wallMask=4))
>
> cylIds=O.bodies.append(utils.geom.facetCylinder((.5,.5,.5),radius=0.6,height=0,wallMask=1))
> sp=pack.SpherePack()
> O.materials.append(FrictMat(density = 1000,
> frictionAngle=90,young=1e9,poisson=.11))
> sp.makeCloud((0.3,0.3,-0.5),(0.75,0.75,-0.75),rMean=.02,rRelFuzz=0, num=20)
> b1 = utils.sphere(center=(0.35,0.35,-0.1),radius=.10,fixed=False)
> O.bodies.append(b1)
> sp.toSimulation()
>
> O.engines=[
>    ForceResetter(),
>    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
>    InteractionLoop(
>       [Ig2_Sphere_Sphere_L3Geom(),Ig2_Facet_Sphere_L3Geom()],
>       [Ip2_FrictMat_FrictMat_FrictPhys()],
>       [Law2_L3Geom_FrictPhys_ElPerfPl()]
>
>    ),
>    GravityEngine(gravity=(0,0,9.81)),
>    NewtonIntegrator(damping=0.4),
>
>  RotationEngine(rotateAroundZero=True,zeroPoint=(0.5,0.5,0.5),rotationAxis=(0,0,1),angularVelocity=1000*(2*pi/60),ids=cylIds),
>    PyRunner(iterPeriod = 10, command="plotAddData()")
>
> ]
> O.dt=.5*utils.PWaveTimeStep()
>
> def plotAddData():
>   pos = b1.state.pos
>   nIntrs = len( b1.intrs() )
>   #nIntrs = numIntrsOfEachBody()
>   #plot.addData( i=O.iter, x=pos[0], y=pos[1], z=pos[2] ) # choose only
> one plot.addData function you want
>   plot.addData( i=O.iter, x=pos[0], y=pos[1], z=pos[2] ,nIntrs=nIntrs )
>
> f = open("file","w")
> pos = b1.state.pos
> intrs = b1.intrs()
> f.write("%s \n"%str(pos))
> for i in intrs:
>   f.write("%s \n"%i.phys.normalForce) # depends on what you mean by
> "savethe data of interactions"
> f.close()
> O.step()
>
> --
> You received this question notification because you are a member of
> yade-users, which is an answer contact for Yade.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to     : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help   : https://help.launchpad.net/ListHelp
>

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