← Back to team overview

yade-users team mailing list archive

Re: [Question #662763]: How to save Data in a txt or Gnuplot file

 

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

    Status: Needs information => Open

Sophie gave more information on the question:
Hi Jan,

thank you for your fast reply. I'm sorry I forgot to comment out the
DeformControl() command. You can just ignore this command. It doesn't
effect the Penetration Depth or Stiffness.


The code again (without the wrong PyRunner(command='ExportPara()',iterPeriod=1000) command)


from yade import utils, plot, qt
o = Omega()

# Physical parameters
fr = 0.5;rho=2000
tc = 0.0001; 
en = 0.7; et = 0.4;
cn = 0.186; cs = 0.186
kn =1000; ks =0.849e-3
tc = 0.0001;
o.dt = 0.1*tc
Rad = 2.0e-3


# Add material
#mat1 = O.materials.append(ViscElMat(frictionAngle=fr,tc=tc,en=en,et=et,label='myMat'))
mat1 = O.materials.append(ViscElMat(frictionAngle=fr,cn=cn,cs=cs,kn=kn,ks=ks))
mat2 = O.materials.append(ViscElMat(frictionAngle=fr,cn=cn,cs=cs,kn=10*kn,ks=ks))

# Add spheres
id1 = O.bodies.append(sphere(center=[0,0,0],radius=Rad,material=mat1,fixed=True))
id2 = O.bodies.append(sphere(center=[0,0,2*Rad],radius=Rad,material=mat1,fixed=False))
bodyList = []
for b in O.bodies:
	bodyList.append(b.id)
id3 = O.bodies.append(sphere(center=[0,0.5*Rad,-1e-2+Rad],radius=Rad,material=mat2,fixed=True))
	
# Import box's geometry
O.bodies.append(geom.facetBox(center=(0,0,0), extents=(1e-2,1e-2,1e-2), wallMask=31, material=mat1))

# Add engines
O.engines = [
  ForceResetter(),
  InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb(),Bo1_Facet_Aabb()]),
  InteractionLoop(
    [Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom(), Ig2_Wall_Sphere_ScGeom()],
    [Ip2_ViscElMat_ViscElMat_ViscElPhys(label='myPhysics')],
    [Law2_ScGeom_ViscElPhys_Basic()],
  ),
  NewtonIntegrator(damping=0,gravity=[0,0,-9.81]),
  #DeformControl(),
  PyRunner(command='addPlotData()',iterPeriod=1),
  PyRunner(command='ChangeKn()', virtPeriod=0.1,dead=False,label='changeK'),
  PyRunner(command='CreateClumps()',iterPeriod=1000)
]

#Function change Kn
def ChangeKn():
  pairs = [(i.id1,i.id2) for i in O.interactions]
  for i in range(0,2,1):
    kn2 = O.bodies[i].material.kn * 0.9
    O.bodies[i].mat = ViscElMat(frictionAngle=fr,cn=cn,cs=cs,kn=kn2,ks=ks)
    if kn2 <= 0.3:
      changeK.dead = True
    
  O.interactions.clear()
  for id1,id2 in pairs: utils.createInteraction(id1,id2)
  
  
#Funtion create Clumps
def CreateClumps():
  kn2 = O.bodies[0].mat.kn
  if kn2 <= 0.3:
    if not O.bodies[0].isClumpMember:
      idClump = O.bodies.clump(bodyList)


# Function to add data to plot
def addPlotData(): 
  pos1 = (O.bodies[id2].state.pos[2]-O.bodies[id1].state.pos[2])-(Rad)
  PD=O.interactions[0,1].geom.penetrationDepth
  kn2 = O.bodies[0].mat.kn
  plot.addData(PD=PD, kn2=-kn2)
 

#plot.plots={'time':('PD')}; plot.plot()
plot.plots={'kn2':('PD')}; plot.plot()
plot.plot()

O.run(1)
qt.View()

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.