← Back to team overview

yade-users team mailing list archive

[Question #267162]: store data

 

New question #267162 on Yade:
https://answers.launchpad.net/yade/+question/267162

Hi, 

 I have written a very simple script, However;
I do not know what is wrong with my script. when I run it the force-history graph is plotted but no- data save in the txt file (m.txt) 
I am sure I made a mistake bu where?i do not know!!!!
would you please help me in this issue?
 this is a script:


utils.readParamsFromTable(maxLoad=1e6,minLoad=10)
from yade.params.table import *
from yade import pack, plot

###### Define the material for your facet here
O.bodies.append(utils.geom.facetBox((0.5,0.5,0.5),(0.5,0.5,0.5),wallMask=31))


O.materials.append(FrictMat(young=1e10,poisson=0.2, frictionAngle = radians(30) , label='ballmat'))
##### Define the material for your spheres here




O.bodies.append([utils.sphere((.2,.1,.1),.1),utils.sphere((.4,.1,.1),.1),utils.sphere((.6,.1,.1),.1),utils.sphere((.8,.1,.1),.1),utils.sphere((.2,.1,.35),.1),utils.sphere((.4,.1,.35),.1),utils.sphere((.6,.1,.35),.1),utils.sphere((.8,.1,.35),.1),utils.sphere((.2,.1,.6),.1),utils.sphere((.4,.1,.6),.1),utils.sphere((.6,.1,.6),.1),utils.sphere((.8,.1,.6),.1),utils.sphere((.2,.1,.85),.1),utils.sphere((.4,.1,.85),.1),utils.sphere((.6,.1,.85),.1),utils.sphere((.8,.1,.85),.1),utils.sphere((.2,.35,.1),.1),utils.sphere((.2,.6,.1),.1),utils.sphere((.2,.85,.1),.1),utils.sphere((.4,.35,.1),.1),utils.sphere((.4,.6,.1),.1),utils.sphere((.4,.85,.1),.1),utils.sphere((.6,.35,.1),.1),utils.sphere((.6,.6,.1),.1),utils.sphere((.6,.85,.1),.1),utils.sphere((.8,.35,.1),.1),utils.sphere((.8,.6,.1),.1),utils.sphere((.8,.85,.1),.1),
utils.sphere((.2,.35,.35),.1),utils.sphere((.2,.6,.35),.1),utils.sphere((.2,.85,.35),.1),utils.sphere((.4,.35,.35),.1),utils.sphere((.4,.6,.35),.1),utils.sphere((.4,.85,.35),.1),utils.sphere((.6,.35,.35),.1),utils.sphere((.6,.6,.35),.1),utils.sphere((.6,.85,.35),.1),utils.sphere((.8,.35,.35),.1),utils.sphere((.8,.6,.35),.1),utils.sphere((.8,.85,.35),.1),
utils.sphere((.2,.35,.6),.1),utils.sphere((.2,.6,.6),.1),utils.sphere((.2,.85,.6),.1),utils.sphere((.4,.35,.6),.1),utils.sphere((.4,.6,.6),.1),utils.sphere((.4,.85,.6),.1),utils.sphere((.6,.35,.6),.1),utils.sphere((.6,.6,.6),.1),utils.sphere((.6,.85,.6),.1),utils.sphere((.8,.35,.6),.1),utils.sphere((.8,.6,.6),.1),utils.sphere((.8,.85,.6),.1),
utils.sphere((.2,.35,.85),.1),utils.sphere((.2,.6,.85),.1),utils.sphere((.2,.85,.85),.1),utils.sphere((.4,.35,.85),.1),utils.sphere((.4,.6,.85),.1),utils.sphere((.4,.85,.85),.1),utils.sphere((.6,.35,.85),.1),utils.sphere((.6,.6,.85),.1),utils.sphere((.6,.85,.85),.1),utils.sphere((.8,.35,.85),.1),utils.sphere((.8,.6,.85),.1),utils.sphere((.8,.85,.85),.1),])





##### add the sphere pack to the simulation


O.materials.append(FrictMat(young=1e10,poisson=0.1, frictionAngle = radians(30) , label='wallmat'))
wallmat = O.materials[-1]

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
		 InteractionLoop([Ig2_Sphere_Sphere_L3Geom(),Ig2_Facet_Sphere_L3Geom(),Ig2_Wall_Sphere_L3Geom()],
			[Ip2_FrictMat_FrictMat_FrictPhys()],
			[Law2_L3Geom_FrictPhys_ElPerfPl()]
		 ),
	NewtonIntegrator(damping=0.4,gravity=(0,0,-9.81)),
	PyRunner(command='checkUnbalanced()',realPeriod=2,label='checker'), 
	PyRunner(command='addPlotData()',iterPeriod=100)
	]

O.dt=.5*utils.PWaveTimeStep()
O.trackEnergy=True

def checkUnbalanced():
	
	global Forcewall 
	if O.iter<5000: return
	if utils.unbalancedForce()>.1: return
	
	plot.saveDataTxt('m.txt.bz2')
	
	
	O.bodies.append(utils.wall((0.5,0.5,1.0),2,sense = -1, material = 'wallmat')) 
	Forcewall = O.bodies[-1]
	
	
	Forcewall.state.vel = (0,0,-0.01) ### applying the velocity to the wall (0,0,-1)=(u,v,w)
	
	O.engines=O.engines+[PyRunner(command='addPlotData()',iterPeriod=200)]

        #plot.saveDataTxt(O.tags['d.id']+'.txt')
  
	checker.command='unloadPlate()' 
def unloadPlate():
   # if the force on Forcewall exceeds maximum load, start unloading
   if abs(O.forces.f(Forcewall.id)[2])>maxLoad:
      ##Forcewall.state.vel = (0,0,0) 
      Forcewall.state.vel = (0,0,0)

      checker.command='stopUnloading()'

def stopUnloading():
   if abs(O.forces.f(Forcewall.id)[2])<minLoad:
      # O.tags can be used to retrieve unique identifiers of the simulation
      # if running in batch, subsequent simulation would overwrite each other's output files otherwise
      # d (or description) is simulation description (composed of parameter values)
      # while the id is composed of time and process number
       plot.saveDataTxt(O.tags['d.id']+'.txt')
       
       

def addPlotData():
    if not isinstance(O.bodies[-1].shape,Wall): 
       plot.addData(); return     
    Fz=O.forces.f(Forcewall.id)[2]
    plot.addData(Fz=Fz,w=Forcewall.state.pos[2]-Forcewall.state.refPos[2],unbalanced=utils.unbalancedForce(),i=O.iter)


plot.plots={'i':('unbalanced',),'w':('Fz',)}
plot.plot()
 

O.run()
#utils.waitIfBatch()

Cheers


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


Follow ups