Segmentation Fault - PFV2

Asked by Luis Barbosa

Dear all,

I am facing an error of segmentation fault with this script.
Not sure if it is hardware limitation or if it is related to tessellation issue, since this packing is very peculiar.

I have checked similar questions but couldn't find a way out.

Do you have an idea of size ration between particle diameter and aggregate diameter.

Cheers,

# encoding: utf-8
# This script demonstrates a simple case of drainage simulation using the "2PFV" two-phase model implemented in UnsaturatedEngine.
# The script was used to generate the result and supplementary material (video) of [1]. The only difference is the problem size (40k particles in the paper vs. 1k (default) in this version)
# [1] Yuan, C., & Chareyre, B. (2017). A pore-scale method for hydromechanical coupling in deformable granular media. Computer Methods in Applied Mechanics and Engineering, 318, 1066-1079. (http://www.sciencedirect.com/science/article/pii/S0045782516307216)
from yade import plot
from yade import ymport
from yade import bodiesHandling
from yade import export
from yade import utils

import matplotlib; matplotlib.rc('axes',grid=True)
from yade import pack
import pylab
from numpy import *

utils.readParamsFromTable(seed=1,compFricDegree = 10.0)
from yade.params import table

seed=table.seed
#num_spheres=table.num_spheres# number of spheres
compFricDegree = table.compFricDegree # initial contact friction during the confining phase (will be decreased during the REFD compaction process),num_spheres=1000
confiningS=-1e6

## creat a packing with a specific particle side distribution (PSD)
#psdSizes,psdCumm=[.599,0.6,0.849,0.85,1.0,1.40],[0.,0.35,0.35,0.70,.70,1.] psdSizes=psdSizes,psdCumm=psdCumm,distributeMass=True,
sp=pack.SpherePack()
sp1=pack.SpherePack()
mn,mx=Vector3(0,0,0),Vector3(0.004,0.0005,0.004)
mnn,mxx=Vector3(0,0,0),Vector3(0.006,0.006,0.006)
mnc,mxc=Vector3(0,0,0),Vector3(0.006,0.006,0.006)
#Coating
sp.makeCloud(minCorner=mn,maxCorner=mx,rMean=0.00005,seed=seed)
#Matrix
sp1.makeCloud(minCorner=mnn,maxCorner=mxx,rMean=0.0004,seed=seed)

O.materials.append(JCFpmMat(type=1,young=70e6,poisson=0.3,frictionAngle=radians(compFricDegree),density=2600,tensileStrength=100e6,cohesion=100e6,jointNormalStiffness=0,jointShearStiffness=0,jointCohesion=100e6,jointFrictionAngle=radians(0),jointDilationAngle=0.0,label='coating'))
O.materials.append(JCFpmMat(type=1,young=50e5,poisson=0.3,frictionAngle=radians(compFricDegree),density=2600,tensileStrength=100e5,cohesion=100e5,jointNormalStiffness=0,jointShearStiffness=0,jointCohesion=100e5,jointFrictionAngle=radians(0),jointDilationAngle=0.0,label='matrix'))
O.materials.append(JCFpmMat(type=1,young=50e5,poisson=0.3,frictionAngle=radians(0),density=2600,tensileStrength=0,cohesion=0,jointNormalStiffness=0,jointShearStiffness=0,jointCohesion=0,jointFrictionAngle=radians(0),jointDilationAngle=0.0,label='frictionless'))

## create walls around the packing
walls=aabbWalls((mnc,mxc),thickness=0,material='frictionless')
wallIds=O.bodies.append(walls)

#O.bodies.append([utils.sphere(center,rad,material='coating') for center,rad in sp])
#for center,rad in sp:
# print (center,rad)
#O.bodies.append([utils.sphere(center,rad,material='matrix') for center,rad in sp1])
#O.bodies.append([utils.sphere(center,rad,material='spheres') for center,rad in sp2])

for p in sp1:
 a=p[0]
# print (a)
 f1=O.bodies.append(ymport.textExt("aggcoating.txt", format='x_y_z_r', shift=a-Vector3(0,0,0.0004), scale=1.0,material='matrix',color=(0,1,1)))

triax=TriaxialStressController(
# wall_back_activated=True,
# wall_bottom_activated=True,
# wall_front_activated=True,
# wall_left_activated=True,
# wall_right_activated=True,
# wall_top_activated=True,
 internalCompaction=True,
 goal1=confiningS,
 goal2=confiningS,
 goal3=confiningS,
 max_vel=5,
 label="triax"
)

newton=NewtonIntegrator(damping=0.4)

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=-1)],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(smoothJoint=False)]
# [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
# [Ip2_FrictMat_FrictMat_FrictPhys()],
# [Law2_ScGeom_FrictPhys_CundallStrack()]
 ),
# GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
 triax,
# VTKRecorder(iterPeriod=2000,recorders=['all','cracks'],fileName="/home/user/Área de Trabalho/Paper_Biopore/SandBox_Laser/Video/Videotest"),
 newton
]

O.dt=0.08*PWaveTimeStep()
O.dynDt=False

while 1:
  O.run(1000,True)
  unb=unbalancedForce()
# print(triax.meanStress)
  if unb<0.01 and abs(triax.goal1-triax.meanStress)/abs(triax.goal1)<0.01:
    break

#############################
## REACH NEW EQU. STATE ###
#############################
finalFricDegree = 30 # contact friction during the deviatoric loading

#We move to deviatoric loading, let us turn internal compaction off to keep particles sizes constant
triax.internalCompaction=False
# Change contact friction (remember that decreasing it would generate instantaneous instabilities)
setContactFriction(radians(finalFricDegree))

while 1:
  O.run(1000,True)
  unb=unbalancedForce()
  if unb<0.01 and abs(triax.goal1-triax.meanStress)/abs(triax.goal1)<0.01:
    break

triax.depth0=triax.depth
triax.height0=triax.height
triax.width0=triax.width
O.save('1kPacking.yade') #save the packing, which can be reloaded later.

O.run(1000,True)
ei0=-triax.strain[0];ei1=-triax.strain[1];ei2=-triax.strain[2]
si0=-triax.stress(0)[0];si1=-triax.stress(2)[1];si2=-triax.stress(4)[2]

from yade import plot
O.engines=O.engines+[PyRunner(iterPeriod=100,command='history()',dead=1,label='recorder')]

def history():
 plot.addData(e11=-triax.strain[0]-ei0, e22=-triax.strain[1]-ei1, e33=-triax.strain[2]-ei2,
  s11=-triax.stress(0)[0]-si0,
  s22=-triax.stress(2)[1]-si1,
  s33=-triax.stress(4)[2]-si2,
  pc=-unsat.bndCondValue[2],
  sw=unsat.getSaturation(False),
  i=O.iter
  )

plot.plots={'pc':('sw',None,'e22')}
plot.plot()

#######################################################
## Drainage Test under oedometer conditions ###
#######################################################
##oedometer conditions
triax.stressMask=2
triax.goal1=triax.goal3=0
goalTop=triax.stress(3)[1]
#print(goalTop)
triax.goal2=goalTop
triax.wall_bottom_activated=0
recorder.dead=0

##Instantiate a two-phase engine
unsat=TwoPhaseFlowEngine()
meanDiameter=(O.bodies[-1].shape.radius + O.bodies[6].shape.radius) / 2.

##set boundary conditions, the drainage is controlled by decreasing W-phase pressure and keeping NW-phase pressure constant
unsat.bndCondIsPressure=[0,0,1,1,0,0]
unsat.bndCondValue=[0,0,-1e8,0,0,0]
unsat.isPhaseTrapped=True #the W-phase can be disconnected from its reservoir
unsat.initialization()
unsat.surfaceTension = 0.0728

#start invasion, the data of normalized pc-sw-strain will be written into pcSwStrain.txt
f1=open('Cells1.txt',"w")
f2=open('Cells2.txt',"w")
f3=open('Cells3.txt',"w")
f4=open('Cells4.txt',"w")
f5=open('SwPc.txt',"w")
for pg in arange(1.0e-5,2.5,0.1):
  #increase gaz pressure at the top boundary
  unsat.bndCondValue=[0,0,(-1.0)*pg*unsat.surfaceTension/meanDiameter,0,0,0]
  #compute the evolution of interfaces
  unsat.invasion()
  #save the phases distribution in vtk format, to be displayed by paraview
# unsat.savePhaseVtk("/home/user/Área de Trabalho/Paper_Biopore/SandBox_Laser/Video/Pressurefield")
  #compute and apply the capillary forces on each particle
  unsat.computeCapillaryForce()
  for b in O.bodies:
    O.forces.setPermF(b.id, unsat.fluidForce(b.id))

  if pg==0.60001:
    cels=unsat.nCells()
    celsW1 = [0.0]*cels
    celsV1 = [0.0]*cels
    celsBar1 = [0.0]*cels
    for ii in range(cels):
      celsW1=unsat.getCellIsWRes(ii)
      celsV1=unsat.getCellVolume(ii)
# celsBar1=unsat.getCellBarycenter(ii)
      celsBar1=unsat.getCellCenter(ii)
      f1.write(str(celsW1)+" "+str(celsV1)+" "+str(celsBar1)+"\n")
    f1.close()

  if pg==2.30001:
    cels2=unsat.nCells()
    celsW2 = [0.0]*cels2
    celsV2 = [0.0]*cels2
    celsBar2 = [0.0]*cels2
    for jj in range(cels2):
      celsW2=unsat.getCellIsWRes(jj)
      celsV2=unsat.getCellVolume(jj)
      celsBar2=unsat.getCellCenter(jj)
      f2.write(str(celsW2)+" "+str(celsV2)+" "+str(celsBar2)+"\n")
    f2.close()

  if pg==3.10001:
    cels3=unsat.nCells()
    celsW3 = [0.0]*cels3
    celsV3 = [0.0]*cels3
    celsBar3 = [0.0]*cels3
    for gg in range(cels3):
      celsW3=unsat.getCellIsWRes(gg)
      celsV3=unsat.getCellVolume(gg)
      celsBar3=unsat.getCellCenter(gg)
      f3.write(str(celsW3)+" "+str(celsV3)+" "+str(celsBar3)+"\n")
    f3.close()

  if pg==9.90001:
    cels4=unsat.nCells()
    celsW4 = [0.0]*cels4
    celsV4 = [0.0]*cels4
    celsBar4 = [0.0]*cels4
    for hh in range(cels4):
      celsW4=unsat.getCellIsWRes(hh)
      celsV4=unsat.getCellVolume(hh)
      celsBar4=unsat.getCellCenter(hh)
      f4.write(str(celsW4)+" "+str(celsV4)+" "+str(celsBar4)+"\n")
    f4.close()

  #reac
  while 1:
    O.run(1000,True)
    unb=unbalancedForce()
    if unb<0.001:
      break
  f5.write(str(pg)+" "+str(unsat.getSaturation(False))+" "+str(triax.strain[1]-ei1)+"\n")
f5.close()

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Luis Barbosa (luis-pires-b) said :
#1

Here is the aggregate:

#!/usr/bin/python
# -*- coding: utf-8 -*-

#Forca normal lei de contato coesao e atrito
from yade import plot
from yade import pack
from yade import utils
from yade import bodiesHandling
from yade import export
#from add import addBodyToAggreg
import math
import random
# Spheres

#O.materials.append(JCFpmMat(type=1,young=20e7,poisson=0.3,frictionAngle=radians(30),density=1600,tensileStrength=100e7,cohesion=100e7,jointNormalStiffness=1e5,jointShearStiffness=1e5,jointCohesion=100e7,jointFrictionAngle=radians(30),jointDilationAngle=0.0,label='spheres'))
O.materials.append(JCFpmMat(type=1,young=70e6,poisson=0.3,frictionAngle=radians(30),density=2000,tensileStrength=100e6,cohesion=100e6,jointNormalStiffness=0,jointShearStiffness=0,jointCohesion=100e6,jointFrictionAngle=radians(0),jointDilationAngle=0.0,label='spheres'))

#particledensity=1600

O.materials.append(JCFpmMat(type=1,young=20e7,poisson=0.3,frictionAngle=radians(10),density=1000,tensileStrength=0,cohesion=0,jointNormalStiffness=0,jointShearStiffness=0,jointCohesion=0,jointFrictionAngle=radians(0),jointDilationAngle=0.0,label='plates'))
#O.materials.append(CohFrictMat(young=200e9,poisson=0.3,density=900,frictionAngle=radians(80),isCohesive=True,normalCohesion=1e30,shearCohesion=1e30,momentRotationLaw=True,etaRoll=0.1,label='spheres'))
##################################Radius by Class##########################################
size=3
if size==1:
 rag=0.05 #aumento de 12.61 x 0.00238

if size==2:
 rag=0.075

if size==3:
 rag=0.0004

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rad,gap= 0.000065,0#0.003783,0
r=rag
print ("diametro agregado", rag*2)
# Spheres
ag=O.bodies.append(
# pack.regularHexa(
 pack.randomDensePack(
  (pack.inSphere((0,0,r),r)),radius=rad,color=(0,1,0),rRelFuzz=0,material='spheres') # head

# pred1=pack.inAlignedBox((0,0,0),(0.010,0.010,0.010))
# pack.randomDensePack((pack.inAlignedBox((0,0,0),(0.010,0.010,0.010))),radius=0.0009,material='spheres')

)

alfa = random.uniform(0,pi/2)
x = random.randint(0,1)
y = random.randint(0,1)
z = random.randint(0,1)
#print x,y,z
ori = Quaternion(Vector3(x,y,z),(alfa))
#AGREGADO MANIPULADO++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
agr=O.bodies.append(bodiesHandling.spheresModify(ag,mask=-1,shift=(0.0,0.0,0.0),scale=1.0,orientation=ori,copy=True))
a = len(agr)
print ("numero de particulas", a)

######################################Planes#################################################
#p1=O.bodies.append(utils.geom.facetBox((0,0,0),(0.07,-0.07,0),wallMask=1,material='plates'))
#p2=O.bodies.append(utils.geom.facetBox((0,0,r),(0.07,-0.07,r),wallMask=32,material='plates'))# os r's se somam
########################################Interactions#########################################
#SIMULACAO 1

if size==1:
 n = 0#60 #number of spheres to exclude randomically
if size==2:
 n = 0 #number of spheres to exclude randomically
if size==3:
 n = 0 #number of spheres to exclude randomically

#SELECIONA PARTICULAS++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rem=random.sample(agr,n)
#print rem
#REMOVE PARTICULAS SELECIONADAS++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
for i in rem:
 O.bodies.erase(i)
#REMOVE AGREGADO BASE+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
for b in ag:
 O.bodies.erase(b)
#STATUS DO AGREGADO++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
nrp=a-n
#print "total de particulas", a
#print "numero de esferas removidas", n
#print "raio do agregado em m", r
######################################Planes#################################################
O.engines=[
  ForceResetter(),

 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Facet_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1)],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(smoothJoint=False, Key="Wei", recordCracks=True)]
 ),

# TranslationEngine(ids=p2,translationAxis=[0,0,-1],velocity=0.01),
  GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=500,timestepSafetyCoefficient=0.5),
  NewtonIntegrator(damping=0.1,gravity=[0,0,-9.81]),
# VTKRecorder(iterPeriod=100,recorders=['all'],fileName='/tmp/weibull')
# ForceRecorder(ids=p2,file='forca.txt',iterPeriod=500),
# PyRunner(command='AutoData()',iterPeriod=100,initRun=True),
# PyRunner(command='Data()',iterPeriod=100,initRun=True),
# PyRunner(command='addBodyToAggreg()',iterPeriod=100,initRun=True),
# PyRunner(command='aggregs()',iterPeriod=100,initRun=True),

]

##################

from yade import qt
qt.View()
qt.Controller()

#print "### agg1 state saved ###"
export.textExp("aggcoating.txt", 'x_y_z_r')

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.