1
################################################################################
3
# Triaxial test. Axial strain rate is prescribed and transverse prestress.
4
# Test is possible on prism or cylinder
5
# An independent c++ engine may be created from this script in the future.
7
################################################################################
8
from yade import pack, plot
11
# default parameters or from table
12
readParamsFromTable(noTableOk=True,
13
# type of test ['cyl','cube']
30
rParticle = .075e-3, #
39
# output specifications
45
from yade.params.table import *
46
assert testType in ['cyl','cube']
49
concMat = O.materials.append(CpmMat(
50
young=young,frictionAngle=frictionAngle,poisson=poisson,sigmaT=sigmaT,
51
epsCrackOnset=epsCrackOnset,relDuctility=relDuctility
53
frictMat = O.materials.append(FrictMat(
54
young=young,poisson=poisson,frictionAngle=frictionAngle
58
pred = pack.inCylinder((0,0,0),(0,0,height),.5*width) if testType=='cyl' else pack.inAlignedBox((-.5*width,-.5*width,0),(.5*width,.5*width,height)) if testType=='cube' else None
60
sp = pack.randomDensePack(pred,spheresInCell=2000,radius=rParticle,memoizeDb='/tmp/triaxTestOnCylinder.sqlite',material=concMat,returnSpherePack=True)
61
spheres=sp.toSimulation(color=(0,1,1))
62
# bottom and top of specimen. Will have prescribed velocity
63
bot = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]<rParticle*bcCoeff]
64
top = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]>height-rParticle*bcCoeff]
65
vel = strainRate*(height-rParticle*2*bcCoeff)
67
s.shape.color = (1,0,0)
68
s.state.blockedDOFs = 'xyzXYZ'
69
s.state.vel = (0,0,-vel)
71
s.shape.color = Vector3(0,1,0)
72
s.state.blockedDOFs = 'xyzXYZ'
73
s.state.vel = (0,0,vel)
78
rCyl2 = .5*width / cos(pi/float(nw))
81
v1 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+0)/float(nh) )
82
v2 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+0)/float(nh) )
83
v3 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+1)/float(nh) )
84
v4 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+1)/float(nh) )
85
f1 = facet((v1,v2,v3),color=(0,0,1),material=frictMat)
86
f2 = facet((v1,v3,v4),color=(0,0,1),material=frictMat)
87
facets.extend((f1,f2))
88
elif testType == 'cube':
92
v11 = Vector3( -.5*width + (r+0)*width/nw2, -.5*width, height*(h+0)/float(nh) )
93
v12 = Vector3( -.5*width + (r+1)*width/nw2, -.5*width, height*(h+0)/float(nh) )
94
v13 = Vector3( -.5*width + (r+1)*width/nw2, -.5*width, height*(h+1)/float(nh) )
95
v14 = Vector3( -.5*width + (r+0)*width/nw2, -.5*width, height*(h+1)/float(nh) )
96
f11 = facet((v11,v12,v13),color=(0,0,1),material=frictMat)
97
f12 = facet((v11,v13,v14),color=(0,0,1),material=frictMat)
98
v21 = Vector3( +.5*width, -.5*width + (r+0)*width/nw2, height*(h+0)/float(nh) )
99
v22 = Vector3( +.5*width, -.5*width + (r+1)*width/nw2, height*(h+0)/float(nh) )
100
v23 = Vector3( +.5*width, -.5*width + (r+1)*width/nw2, height*(h+1)/float(nh) )
101
v24 = Vector3( +.5*width, -.5*width + (r+0)*width/nw2, height*(h+1)/float(nh) )
102
f21 = facet((v21,v22,v23),color=(0,0,1),material=frictMat)
103
f22 = facet((v21,v23,v24),color=(0,0,1),material=frictMat)
104
v31 = Vector3( +.5*width - (r+0)*width/nw2, +.5*width, height*(h+0)/float(nh) )
105
v32 = Vector3( +.5*width - (r+1)*width/nw2, +.5*width, height*(h+0)/float(nh) )
106
v33 = Vector3( +.5*width - (r+1)*width/nw2, +.5*width, height*(h+1)/float(nh) )
107
v34 = Vector3( +.5*width - (r+0)*width/nw2, +.5*width, height*(h+1)/float(nh) )
108
f31 = facet((v31,v32,v33),color=(0,0,1),material=frictMat)
109
f32 = facet((v31,v33,v34),color=(0,0,1),material=frictMat)
110
v41 = Vector3( -.5*width, +.5*width - (r+0)*width/nw2, height*(h+0)/float(nh) )
111
v42 = Vector3( -.5*width, +.5*width - (r+1)*width/nw2, height*(h+0)/float(nh) )
112
v43 = Vector3( -.5*width, +.5*width - (r+1)*width/nw2, height*(h+1)/float(nh) )
113
v44 = Vector3( -.5*width, +.5*width - (r+0)*width/nw2, height*(h+1)/float(nh) )
114
f41 = facet((v41,v42,v43),color=(0,0,1),material=frictMat)
115
f42 = facet((v41,v43,v44),color=(0,0,1),material=frictMat)
116
facets.extend((f11,f12,f21,f22,f31,f32,f41,f42))
117
O.bodies.append(facets)
118
mass = O.bodies[0].state.mass
121
f.state.blockedDOFs = 'XYZz'
124
plot.plots = { 'e':('s',), }
126
f1 = sum(O.forces.f(b.id)[2] for b in top)
127
f2 = sum(O.forces.f(b.id)[2] for b in bot)
129
s = f/(pi*.25*width*width) if testType=='cyl' else f/(width*width) if testType=='cube' else None
130
e = (top[0].state.displ()[2] - bot[0].state.displ()[2]) / (height-rParticle*2*bcCoeff)
137
# apply prestress to facets
142
O.forces.addF(f.id,preStress*a*n)
144
# stop condition and exit of the simulation
145
def stopIfDamaged(maxEps=5e-3):
146
extremum = max(abs(s) for s in plot.data['s'])
147
s = abs(plot.data['s'][-1])
148
e = abs(plot.data['e'][-1])
149
if O.iter < 1000 or s > .5*extremum and e < maxEps:
151
f = os.path.join(exportDir,fileName)
152
print 'gnuplot',plot.saveGnuplot(f,term='png')
156
subprocess.Popen(['gnuplot',f+'.gnuplot']).wait()
157
print 'Simulation finished'
159
#sys.exit(0) # results in some threading exception
161
O.dt=.5*utils.PWaveTimeStep()
165
InsertionSortCollider([
166
Bo1_Sphere_Aabb(aabbEnlargeFactor=enlargeFactor,label='bo1s'),
171
Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=enlargeFactor,label='ss2d3dg'),
172
Ig2_Facet_Sphere_ScGeom(),
175
Ip2_CpmMat_CpmMat_CpmPhys(cohesiveThresholdIter=O.iter+5),
176
Ip2_FrictMat_CpmMat_FrictPhys(),
177
Ip2_FrictMat_FrictMat_FrictPhys(),
180
Law2_ScGeom_CpmPhys_Cpm(),
181
Law2_ScGeom_FrictPhys_CundallStrack(),
184
PyRunner(iterPeriod=1,command="addForces()"),
185
NewtonIntegrator(damping=.3),
186
CpmStateUpdater(iterPeriod=50,label='cpmStateUpdater'),
187
PyRunner(command='plotAddData()',iterPeriod=10),
188
PyRunner(iterPeriod=50,command='stopIfDamaged()'),
194
# reset interaction detection enlargement
195
bo1s.aabbEnlargeFactor=ss2d3dg.interactionDetectionFactor=1.0
197
# initialize auto-updated plot
202
renderer=qt.Renderer()
203
# uncomment following line to exagerate displacement
204
#renderer.dispScale=(100,100,100)