← Back to team overview

yade-users team mailing list archive

Re: [Question #249243]: Tracking variables

 

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

    Status: Open => Answered

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

there are several ways how to export the data. You can use plot module for
that

def myAddData():
   try:
      i=O.interactions[9,10]
      #print i.phys.normalForce
      plot.addData(f=i.phys.normalForce)
   except IndexError: # it is good to specify what exception you except if
it is reasonable
      pass
      #print "No interaction between"
O.run(whatever,True)
plot.saveDataTxt(fileName) # [1]


Or you can have your own list containing data

data = []
def myAddData():
   try:
      i=O.interactions[9,10]
      f = i.phys.normalForce
      data.append(f)
   except IndexError:
      pass
O.run(whatever,True)
# do whtever with data


or using files

ff = open(someFile,'w')
def myAddData():
   try:
      i=O.interactions[9,10]
      f = i.phys.normalForce
      ff.write('%g %g %g\n'%(f[0],f[1],f[2]))
   except IndexError:
      pass
O.run(whatever,True)
ff.close()


cheers
Jan

[1] https://yade-dem.org/doc/yade.plot.html#yade.plot.saveDataTxt



2014-06-17 22:21 GMT+02:00 Luis Barbosa <
question249243@xxxxxxxxxxxxxxxxxxxxx>:

> Question #249243 on Yade changed:
> https://answers.launchpad.net/yade/+question/249243
>
>     Status: Answered => Open
>
> Luis Barbosa is still having a problem:
> Hi Jan, this is my script, when there is interaction the value of force is
> printed and when not is printed 'no interaction...'
> If I'm able to export data could solve my problem for while.
>
> tks, Luis
>
>
> from yade import plot
>
>
> O.materials.append(FrictMat(young=15e6,poisson=.4,frictionAngle=radians(20),density=4000,))
> O.bodies.append(utils.geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
>
> O.materials.append(CohFrictMat(young=15e6,poisson=0.3,density=2600,frictionAngle=radians(30),isCohesive=True,normalCohesion=1e10,shearCohesion=1e10,momentRotationLaw=True,etaRoll=0.1,label='spheres'))
> O.bodies.append([utils.sphere(center=(0.5,0.5,0.5),radius=.07)])
> O.engines=[
>    ForceResetter(),
>    InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
> InteractionLoop(
> [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom()],
> [Ip2_FrictMat_FrictMat_MindlinPhys(en=0.1,es=0.1,label='damping'),
> Ip2_CohFrictMat_CohFrictMat_CohFrictPhys
> (setCohesionNow=True,label="cohesiveIp")],
>
> [Law2_ScGeom_MindlinPhys_Mindlin(label='contactLaw'),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,
> always_use_moment_law=True,label='cohesiveLaw')]
> ),
>
>    GravityEngine(gravity=(0,0,-9.81)),
>    NewtonIntegrator(damping=0.0),
>    PyRunner(command='myAddData()',iterPeriod=10),
>
> ]
> #______________________________________________________________________
> damping.useDamping=True
>
> O.dt=.5e-2*utils.PWaveTimeStep()
>
> def myAddData():
>         try:
>          i=O.interactions[9,10]
>          print i.phys.normalForce
>         except:
>                 print "No interaction between"
>
> O.saveTmp()
>
> --
> 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.