← Back to team overview

yade-users team mailing list archive

Re: [Question #267162]: store data

 

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

Seti gave more information on the question:
utils.readParamsFromTable(maxLoad=1e9,minLoad=10)
from yade.params.table import *
from yade import pack, plot

###### Define the material for facet 
O.bodies.append(utils.geom.facetBox((0.5,0.5,0.5),(0.5,0.5,0.5),wallMa sk=31))


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



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('m.txt.bz2')
        #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): 
       return  #plot.addData();    
    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()

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


Follow ups