from yade import pack
# Data definition
nRead=utils.readParamsFromTable(
num_spheres=3000,# number of spheres
compFricDegree = 10, # contact friction during the confining phase
unknownOk=True,
isoForce=100000
)
from yade.params import table
num_spheres=table.num_spheres# number of spheres
targetPorosity = 0.387 #the porosity we want for the packing
compFricDegree = table.compFricDegree
finalFricDegree = 35 # contact friction during the deviatoric loading
rate=0.002 # loading rate (strain rate)
damp=0.2 # damping coefficient
stabilityThreshold=0.1 # 0.01
key='_triax_draine_e618_100_psd' # put you simulation's name here
young=356e6 # contact stiffness
mn,mx=Vector3(-0.1,-0.1,-0.1),Vector3(0.1,0.1,0.1) # corners of the initial packing
thick = 0.01 # thickness of the plates
## create materials for spheres and plates
O.materials.append(FrictMat(young=young,poisson=0.42,frictionAngle=radians(compFricDegree),density=3000,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=0.5,frictionAngle=0,density=0,label='walls'))
## create walls around the packing
walls=utils.aabbWalls([mn,mx],thickness=thick,oversizeFactor=1.5,material='walls')
wallIds=O.bodies.append(walls)
## use a SpherePack object to generate a random loose particles packing
sp=pack.SpherePack()
psdSizes=[0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.0095] # (sizes or radii of the grains vary from 2mm to 9.5mm)
psdCumm=[0.01,0.09,0.25,0.50,0.69,0.90,0.95,1.00] # for the code do not use percentage
sp.makeCloud(mn,mx,-1,0,num_spheres,False, 0.95,psdSizes,psdCumm,False,seed=1) #"seed" make the "random" generation always the same
sp.toSimulation(material='spheres')
# engine
triax=TriaxialStressController(
maxMultiplier=1.001, # spheres growing factor (fast growth)
finalMaxMultiplier=1.01, # spheres growing factor (slow growth)
thickness = thick,
stressMask = 7,
#the value of confining stress for the intitial (growth) phase
goal1=table.isoForce,
goal2=table.isoForce,
goal3=table.isoForce,
max_vel=0.05,
internalCompaction=True, # If true the confining pressure is generated by growing particles
# Key=key # passed to the engine so that the output file will have the correct name
)
newton=NewtonIntegrator(damping=damp)
O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),
GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=25,timestepSafetyCoefficient=0.8),
triax,
TriaxialStateRecorder(iterPeriod=50,file='WallStresses'+key),
newton
]
# compaction
while 1:
O.run(1000, True)
unb=unbalancedForce()
meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
print 'unbalanced force:',unb,' mean stress: ',meanS, 'void ratio=', triax.porosity/(1-triax.porosity), 'porosity=', triax.porosity
if unb<stabilityThreshold and abs(meanS-table.isoForce)/table.isoForce<0.01: #0.001
break
O.save('confinedState'+key+'.yade.gz')
print "### Isotropic state saved ###"
print 'current porosity=',triax.porosity
print 'current void ratio=',triax.porosity/(1-triax.porosity)
# porosity satisfy
import sys
while triax.porosity>targetPorosity:
compFricDegree = 0.95*compFricDegree
setContactFriction(radians(compFricDegree))
print "\r Friction: ",compFricDegree," porosity:",triax.porosity,
sys.stdout.flush()
O.run(500,1)
O.save('compactedState'+key+'.yade.gz')
print "### Compacted state saved ###"
print 'current porosity=',triax.porosity
print 'current void ratio=',triax.porosity/(1-triax.porosity)
# applying load
triax.goal1=triaxgoal2=triax.goal3=100000
triax.internalCompaction=False
setContactFriction(radians(35))
triax.stressMask = 5
#strain rate
triax.goal2=-rate
#confinement stress
triax.goal1=100000
triax.goal3=100000
newton.damping=0.1
##Save temporary state in live memory. This state will be reloaded from the interface with the "reload" button.
O.saveTmp()
# PSD Plotter
#import matplotlib; matplotlib.rc('axes',grid=True)
#from yade import pack
#import pylab
#pylab.plot(psdSizes,psdCumm,label='precribed mass PSD')
#sp0=pack.SpherePack();
#sp0.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True)
#sp1=pack.SpherePack();
#sp1.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True,num=10000)
#sp2=pack.SpherePack();
#sp2.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True,num=20000)
#pylab.semilogx(*sp0.psd(bins=30,mass=True),label='Mass PSD of (free) %d random spheres'%len(sp0))
#pylab.semilogx(*sp1.psd(bins=30,mass=True),label='Mass PSD of (imposed) %d random spheres'%len(sp1))
#pylab.semilogx(*sp2.psd(bins=30,mass=True),label='Mass PSD of (imposed) %d random spheres (scaled down)'%len(sp2))
#pylab.legend()
## uniform distribution of size (sp3) and of mass (sp4)
#sp3=pack.SpherePack(); sp3.makeCloud(mn,mx,rMean=0.005635,rRelFuzz=0,distributeMass=False);
#sp4=pack.SpherePack(); sp4.makeCloud(mn,mx,rMean=0.005635,rRelFuzz=0,distributeMass=True);
#pylab.figure()
#pylab.plot(*(sp3.psd(mass=True)+('g',)+sp4.psd(mass=True)+('r',)))
#pylab.legend(['Mass PSD of size-uniform distribution','Mass PSD of mass-uniform distribution'])
#pylab.figure()
#pylab.plot(*(sp3.psd(mass=False)+('g',)+sp4.psd(mass=False)+('r',)))
#pylab.legend(['Size PSD of size-uniform distribution','Size PSD of mass-uniform distribution'])
#pylab.show()
#pylab.show()
# Plot
from yade import plot
## a function saving variables
def history():
plot.addData(e11=triax.strain[0], e22=triax.strain[1], e33=triax.strain[2],
ev=-triax.strain[0]-triax.strain[1]-triax.strain[2],
s11=triax.stress(triax.wall_right_id)[0],
s22=triax.stress(triax.wall_top_id)[1],
s33=triax.stress(triax.wall_front_id)[2],
p=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3000,
q=(triax.stress(triax.wall_top_id)[1]-triax.stress(triax.wall_front_id)[2])/1000,
i=O.iter)
if 1:
# include a periodic engine calling that function in the simulation loop
O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
O.engines.insert(4,PyRunner(iterPeriod=20,command='history()',label='recorder'))
else:
# With the line above, we are recording some variables twice. We could in fact replace the previous
# TriaxialRecorder
# by our periodic engine. Uncomment the following line:
O.engines[4]=PyRunner(iterPeriod=20,command='history()',label='recorder')
O.run(100,True)
### declare what is to plot. "None" is for separating y and y2 axis
#plot.plots={'i':('e11','e22','e33',None,'s11','s22','s33')}
### the traditional triaxial curves would be more like this:
plot.plots={'e22':('q')}
## display on the screen (doesn't work on VMware image it seems)
plot.plot()
##or even generate a script for gnuplot. Open another terminal and type "gnuplot plotScriptKEY.gnuplot:
plot.saveGnuplot('plotScript'+key)
Comments