facet disappear when modifying examples/concrete/triax.py

Asked by Ziyu Wang

Hi,everyone!

Due to the actual demand, the triaxial compression of rock I conducted was based on the cylinder shape and the simulation of triaxial compression under different confining pressures is successfully carried out.However,when I try to add flowengine to try fluid-solid coupling, an error occurs.(My code is attached at the end)

According to my purpose, I applied 30MPa confining pressure and 2MPa osmotic pressure. However, the stress-strain curve I obtained was close to the uniaxial compression result. When I opened the Show 3D interface, I found that the facet added in the script disappeared.(Maybe the cause of uniaxial compression results I guess?)

Thanks for help!

My code as follows:
######################
from yade import pack, ymport, plot, utils, export, timing
import numpy as np
import sys

young=66.2e9
name='JCFPM_triax'
compFricDegree=30
poisson=0.522
name='cylinder'
preStress=-30e6
strainRate = -0.1
OUT=str(preStress)+'_JCFPM_triax'
r1=0.005
r2=0.008

nw=24
nh=15
rParticle=0.000731723
bcCoeff = 5
width = 0.025
height = 0.05
allx,ally,allz,r=np.genfromtxt('packing-cylinder.spheres', unpack=True)
mnx=min(allx)*1.01
mny=min(ally)*1.01
mnz=min(allz)*0.99
mxx=max(allx)*1.01
mxy=max(ally)*1.01
mxz=max(allz)*1.01
Sy=2e6

O.materials.append(JCFpmMat(type=1,density=2640,young=young,poisson=poisson,tensileStrength=8e6,cohesion=40e6,frictionAngle=radians(25),label='sphere'))
O.materials.append(JCFpmMat(type=1,label='wall1',young=young,poisson=poisson,frictionAngle=radians(25)))
O.materials.append(JCFpmMat(type=1,frictionAngle=0,density=0,label='wall2'))

mn,mx=Vector3(mnx,mny,mnz),Vector3(mxx,mxy,mxz)
walls=aabbWalls([mn,mx],thickness=0,material='wall2')
wallIds=O.bodies.append(walls)

bottom,top=Vector3(0,0,0),Vector3(0,0,0.05)
radius=0.0125
sp=pack.SpherePack()
pred=pack.inCylinder(bottom,top,radius)
sp=pack.randomDensePack(pred,radius=0.0005,rRelFuzz=0,returnSpherePack=True,memoizeDb='/tmp/triax.sqlite')
spheres=sp.toSimulation(material='sphere',color=(0.9,0.8,0.6))

bot = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]<rParticle*bcCoeff]
top = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]>height-rParticle*bcCoeff]
vel = strainRate*(height-rParticle*2*bcCoeff)
for s in bot:
 s.shape.color = (1,0,0)
 s.state.blockedDOFs = 'xyzXYZ'
 s.state.vel = (0,0,-vel)
for s in top:
 s.shape.color = Vector3(0,1,0)
 s.state.blockedDOFs = 'xyzXYZ'
 s.state.vel = (0,0,vel)

facets = []
rCyl2 = .5*width / cos(pi/float(nw))
for r in range(nw):
 for h in range(nh):
  v1 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+0)/float(nh) )
  v2 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+0)/float(nh) )
  v3 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+1)/float(nh) )
  v4 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+1)/float(nh) )
  f1 = facet((v1,v2,v3),color=(0,0,1),material='wall1')
  f2 = facet((v1,v3,v4),color=(0,0,1),material='wall1')
  facets.extend((f1,f2))

O.bodies.append(facets)
mass = O.bodies[0].state.mass
for f in facets:
 f.state.mass = mass
 f.state.blockedDOFs = 'XYZz'

def lateral():
 elatTot=0.0
 nTot=0
 for b in O.bodies:
  x=b.state.refPos[0]
  y=b.state.refPos[1]
  d=sqrt(pow(x,2)+pow(y,2))
  if d > r1 and d < r2:
   b.shape.color=(0.6,0.5,0.15)
   xnew=b.state.pos[0]
   ynew=b.state.pos[1]
   dnew=sqrt(pow(xnew,2)+pow(ynew,2))
   elat=(dnew-d)/d
   elatTot+=elat
   nTot+=1
 elat_avg=elatTot/nTot
 return elat_avg

def addForces():
 for f in facets:
  n = f.shape.normal
  a = f.shape.area
  O.forces.addF(f.id,preStress*a*n)

def stopIfDamaged(maxEps=0.001):
 extremum = max(abs(s) for s in plot.data['s'])
 s = abs(plot.data['s'][-1])
 e = abs(plot.data['e'][-1])
 if O.iter < 1000 or e < maxEps:
  return
 if abs(s)/abs(extremum) < 0.5 :
  print('Simulation finished')
  presentcohesive_count = 0
  for i in O.interactions:
          if hasattr(i.phys, 'isCohesive'):
               if i.phys.isCohesive == True:
                   presentcohesive_count+=1
  print('the number of cohesive bond now is:',presentcohesive_count)
  print('Max stress and strain:',extremum,e)
  O.pause()

O.dt=.5*utils.PWaveTimeStep()
newton=NewtonIntegrator(damping=damp)

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.5,label='is2aabb'),Bo1_Facet_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=1.5,label='ss2sc'),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=True,Key=OUT+'_Crack',label='interactionLaw')]
 ),
 PyRunner(iterPeriod=1,command="addForces()"),
 FlowEngine(dead=1,label="flow",multithread=False),
 newton,
 PyRunner(command='plotAddData()',iterPeriod=10),
 PyRunner(iterPeriod=20,command='stopIfDamaged()'),
]

def plotAddData():
 elat_avg=lateral()
 f1 = sum(O.forces.f(b.id)[2] for b in top)
 f2 = sum(O.forces.f(b.id)[2] for b in bot)
 f = .5*(f2-f1)
 s = f/(pi*.25*width*width)
 e = (top[0].state.displ()[2] - bot[0].state.displ()[2]) / (height-rParticle*2*bcCoeff)
 plot.addData(
  elateral = elat_avg,
  i = O.iter,
  s = -s,
  e = -e,
  tc = interactionLaw.nbTensCracks,
  sc = interactionLaw.nbShearCracks,
  flux1=flow.getBoundaryFlux(4),
  flux2=flow.getBoundaryFlux(5),
 )
 plot.saveDataTxt(OUT)

O.step()
ss2sc.interactionDetectionFactor=-1
is2aabb.aabbEnlargeFactor=-1

flow.debug=False
flow.permeabilityMap = False
flow.meshUpdateInterval=-1
flow.fluidBulkModulus=2.2e9
flow.useSolver=4
flow.permeabilityFactor=1
flow.viscosity= 0.001
flow.decoupleForces = False
flow.boundaryUseMaxMin=[0,0,0,0,0,0]
flow.bndCondIsPressure=[1,1,1,1,1,1]
flow.bndCondValue=[0,0,0,0,0,Sy]
flow.bndCondIsTemperature=[0,0,0,0,0,0]
flow.thermalEngine=False
flow.thermalBndCondValue=[0,0,0,0,0,0]

flow.dead=0
flow.emulateAction()

plot.plots = { 'e':('s',), 'elateral':('s'),}
plot.plot()
O.run()
###############################

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Karol Brzezinski
Solved:
Last query:
Last reply:
Revision history for this message
Karol Brzezinski (kbrzezinski) said :
#1

Hi Ziyu,

please try to make it MWE (Minimum Working Example) [1]. Now it doesn't work due to the lack of the 'packing-cylinder.spheres' file. Nevertheless, the MWE should work without any external files. Also, you could try to reproduce this problem on simpler (minimum) example.

Cheers,
Karol

[1] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#2

Hi,Karol.
I have modified my code to MWE. Thank you for your help.

--------------------------------code----------------------------
from yade import pack, ymport, plot, utils, export, timing
young=66.2e9
poisson=0.522
name='cylinder'
preStress=-30e6
strainRate = -0.1
OUT=str(preStress)+'_JCFPM_triax'

nw=24
nh=15
rParticle=0.000731723
bcCoeff = 5
width = 0.025
height = 0.05
mnx=-0.011871843
mny=-0.0118675
mnz=0.00072483840000000003
mxx=0.011855783999999999
mxy=0.011865682000000001
mxz=0.049744924000000003
Sy=2e6

O.materials.append(JCFpmMat(type=1,density=2640,young=young,poisson=poisson,tensileStrength=8e6,cohesion=40e6,frictionAngle=radians(25),label='sphere'))
O.materials.append(JCFpmMat(type=1,label='wall1',young=young,poisson=poisson,frictionAngle=radians(25)))
O.materials.append(JCFpmMat(type=1,frictionAngle=0,density=0,label='wall2'))

mn,mx=Vector3(mnx,mny,mnz),Vector3(mxx,mxy,mxz)
walls=aabbWalls([mn,mx],thickness=0,material='wall2')
wallIds=O.bodies.append(walls)

bottom,top=Vector3(0,0,0),Vector3(0,0,0.05)
radius=0.0125
sp=pack.SpherePack()
pred=pack.inCylinder(bottom,top,radius)
sp=pack.randomDensePack(pred,radius=0.0005,rRelFuzz=0,returnSpherePack=True,memoizeDb='/tmp/triax.sqlite')
spheres=sp.toSimulation(material='sphere',color=(0.9,0.8,0.6))

bot = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]<rParticle*bcCoeff]
top = [O.bodies[s] for s in spheres if O.bodies[s].state.pos[2]>height-rParticle*bcCoeff]
vel = strainRate*(height-rParticle*2*bcCoeff)
for s in bot:
 s.shape.color = (1,0,0)
 s.state.blockedDOFs = 'xyzXYZ'
 s.state.vel = (0,0,-vel)
for s in top:
 s.shape.color = Vector3(0,1,0)
 s.state.blockedDOFs = 'xyzXYZ'
 s.state.vel = (0,0,vel)

facets = []
rCyl2 = .5*width / cos(pi/float(nw))
for r in range(nw):
 for h in range(nh):
  v1 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+0)/float(nh) )
  v2 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+0)/float(nh) )
  v3 = Vector3( rCyl2*cos(2*pi*(r+1)/float(nw)), rCyl2*sin(2*pi*(r+1)/float(nw)), height*(h+1)/float(nh) )
  v4 = Vector3( rCyl2*cos(2*pi*(r+0)/float(nw)), rCyl2*sin(2*pi*(r+0)/float(nw)), height*(h+1)/float(nh) )
  f1 = facet((v1,v2,v3),color=(0,0,1),material='wall1')
  f2 = facet((v1,v3,v4),color=(0,0,1),material='wall1')
  facets.extend((f1,f2))

O.bodies.append(facets)
mass = O.bodies[0].state.mass
for f in facets:
 f.state.mass = mass
 f.state.blockedDOFs = 'XYZz'

def addForces():
 for f in facets:
  n = f.shape.normal
  a = f.shape.area
  O.forces.addF(f.id,preStress*a*n)

def stopIfDamaged(maxEps=0.001):
 extremum = max(abs(s) for s in plot.data['s'])
 s = abs(plot.data['s'][-1])
 e = abs(plot.data['e'][-1])
 if O.iter < 1000 or e < maxEps:
  return
 if abs(s)/abs(extremum) < 0.5 :
  print('Simulation finished')
  print('Max stress and strain:',extremum,e)
  O.pause()

O.dt=.5*utils.PWaveTimeStep()
newton=NewtonIntegrator(damping=damp)

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.5,label='is2aabb'),Bo1_Facet_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=1.5,label='ss2sc'),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=True,Key=OUT+'_Crack',label='interactionLaw')]
 ),
 PyRunner(iterPeriod=1,command="addForces()"),
 FlowEngine(dead=1,label="flow",multithread=False),
 newton,
 PyRunner(command='plotAddData()',iterPeriod=10),
 PyRunner(iterPeriod=20,command='stopIfDamaged()'),
]

def plotAddData():
 f1 = sum(O.forces.f(b.id)[2] for b in top)
 f2 = sum(O.forces.f(b.id)[2] for b in bot)
 f = .5*(f2-f1)
 s = f/(pi*.25*width*width)
 e = (top[0].state.displ()[2] - bot[0].state.displ()[2]) / (height-rParticle*2*bcCoeff)
 plot.addData(
  i = O.iter,
  s = -s,
  e = -e,
 )
 plot.saveDataTxt(OUT)

O.step()
ss2sc.interactionDetectionFactor=-1
is2aabb.aabbEnlargeFactor=-1

flow.debug=False
flow.permeabilityMap = False
flow.meshUpdateInterval=-1
flow.fluidBulkModulus=2.2e9
flow.useSolver=4
flow.permeabilityFactor=1
flow.viscosity= 0.001
flow.decoupleForces = False
flow.boundaryUseMaxMin=[0,0,0,0,0,0]
flow.bndCondIsPressure=[1,1,1,1,1,1]
flow.bndCondValue=[0,0,0,0,0,Sy]
flow.bndCondIsTemperature=[0,0,0,0,0,0]
flow.thermalEngine=False
flow.thermalBndCondValue=[0,0,0,0,0,0]

flow.dead=0
flow.emulateAction()

O.run()
############################

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#3

A discovery about this problem:

I found that there seems to be no direct relationship with the flowengine. After deleting the flow part, I only ran a time step and found that the facet particles disappeared.I guess it may be related to the wall, so I consider setting the wall as follows, but it doesn't work...
-----------------------------
mn,mx=Vector3(mnx,mny,mnz),Vector3(mxx,mxy,mxz)
walls=aabbWalls([mn,mx],thickness=0,material='wall2')
wallIds=O.bodies.append(walls)
for i in range(6):
 O.bodies[i].state.vel=Vector3(0,0,0)
 O.bodies[i].state.blockedDOFs='xyzXYZ'
----------------------------

Revision history for this message
Jan Stránský (honzik) said :
#4

> After deleting the flow part

please provide the code without flow
Thanks
Jan

Revision history for this message
Best Karol Brzezinski (kbrzezinski) said :
#5

Hi,

your example still needs some patching before working at all ('damp' not defined etc.). However, the issue is that the facets have zero mass (any force divided by zero mass gives infinite acceleration). You try to prescribe some mass:
>mass = O.bodies[0].state.mass
but unfortunatelly O.bodies[0] is a wall that has no mass either.

Cheers,
Karol

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#6

Hi,Karol!

Your suggestion is helpful.I have solved the problem by change the mass of facet.It was my negligence.
Thanks again,that solved my problem!

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#7

Thanks Karol Brzezinski, that solved my question.