increasing the applied stress every 5000 iteration

Asked by Yor1

Hello,

I realise a triaxial compression test.
I want to increase the major stress every 5000 iterations
For example
0<= i < 5000 : sigma1=2MPa
5000 <= i <10000 : sigma1 = 3MPa
10000 <= i <15000 : sigma1 = 4 MPa etc...

The problem is that my code increase the major stress once and the major stress becomes constant.
Best regards
Jabrane

This is my code:

from yade import ymport, utils , plot
import math

PACKING='X10Y20Z10_5k'
OUT=PACKING+'_compressionTest_5MPa_r002_frictWall'

l
DAMP=0.4
saveData=100
iterMax=2000000
saveVTK=10000

confinement=-2e6
uniaxial_stress=-3e6
delta_stress=-1e6
stress_max=-20e6

intR=1.47618
DENS=4000
YOUNG=65e9
FRICT=10
ALPHA=0.4
TENS=8e6
COH=160e6

def sphereMat(): return JCFpmMat(type=1,density=DENS,young=YOUNG,poisson = ALPHA,frictionAngle=radians(FRICT),tensileStrength=TENS,cohesion=COH)
def wallMat(): return JCFpmMat(type=0,density=DENS,young=YOUNG,frictionAngle=radians(0))

O.bodies.append(ymport.text(PACKING+'.spheres',scale=1.,shift=Vector3(0,0,0),material=sphereMat))

dim=utils.aabbExtrema()
xinf=dim[0][0]
xsup=dim[1][0]
X=xsup-xinf
yinf=dim[0][1]
ysup=dim[1][1]
Y=ysup-yinf
zinf=dim[0][2]
zsup=dim[1][2]
Z=zsup-zinf

R=0
Rmax=0
numSpheres=0.
for o in O.bodies:
 if isinstance(o.shape,Sphere):
   numSpheres+=1
   R+=o.shape.radius
   if o.shape.radius>Rmax:
     Rmax=o.shape.radius
Rmean=R/numSpheres

O.reset()

mn,mx=Vector3(xinf+0.1*Rmean,yinf+0.1*Rmean,zinf+0.1*Rmean),Vector3(xsup-0.1*Rmean,ysup-0.1*Rmean,zsup-0.1*Rmean)
walls=utils.aabbWalls(oversizeFactor=1.5,extrema=(mn,mx),thickness=min(X,Y,Z)/100.,material=wallMat)
wallIds=O.bodies.append(walls)

O.bodies.append(ymport.text(PACKING+'.spheres',scale=1.,shift=Vector3(0,0,0),material=sphereMat))

for o in O.bodies:
 if isinstance(o.shape,Sphere):
   o.shape.color=(0.7,0.5,0.3)

O.engines=[
        ForceResetter(),
        InsertionSortCollider([Bo1_Box_Aabb(),Bo1_Sphere_Aabb(aabbEnlargeFactor=intR,label='Saabb')]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=intR,label='SSgeom'),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(cohesiveTresholdIteration=1,label='interactionPhys')],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=True,Key=OUT,label='interactionLaw')]
 ),
        TriaxialStressController(internalCompaction=False,label='triax',externalWork=0),
        GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.4, defaultDt=0.1*utils.PWaveTimeStep()),
        NewtonIntegrator(damping=DAMP,label="newton"),
        PyRunner(iterPeriod=int(saveData),initRun=True,command='recorder()',label='data'),
        VTKRecorder(iterPeriod=int(saveVTK),initRun=True,fileName=OUT+'-',recorders=['spheres','jcfpm','cracks'],Key=OUT,label='vtk')
]

tensCks=shearCks=cks=cks0=0
e10=e20=e30=0
def recorder():
    global tensCks, shearCks, e10,e20,e30
    tensCks=0
    shearCks=0
    for o in O.bodies:
 tensCks+=o.state.tensBreak
 shearCks+=o.state.shearBreak
    yade.plot.addData( t=O.time
   ,i=O.iter
   ,e1=triax.strain[0]-e10
   ,e2=triax.strain[1]-e20
   ,e3=triax.strain[2]-e30
   ,s1=triax.stress(triax.wall_right_id)[0]
   ,s2=triax.stress(triax.wall_top_id)[1]
   ,s3=triax.stress(triax.wall_front_id)[2]
   ,tc=0.5*tensCks,sc=0.5*shearCks,unbF=utils.unbalancedForce()
    )
    plot.saveDataTxt(OUT)

plot.plots={'i':('s1','s2','s3')}
plot.plot()

O.step();

SSgeom.interactionDetectionFactor=-1.
Saabb.aabbEnlargeFactor=-1.

numSSlinks=0
numCohesivelinks=0
numFrictionalLinks=0
for i in O.interactions:
    if not i.isReal : continue
    if isinstance(O.bodies[i.id1].shape,Sphere) and isinstance(O.bodies[i.id2].shape,Sphere):
     numSSlinks+=1
     if i.phys.isCohesive :
      numCohesivelinks+=1
     else :
      numFrictionalLinks+=1

print "nbSpheres=", numSpheres," | coordination number =", 2.0*numCohesivelinks/numSpheres

triax.stressMask=7
triax.goal1=confinement
triax.goal2=confinement
triax.goal3=confinement
triax.max_vel=0.001

while 1:
  if confinement==0:
    O.run(1000,True)
    break
  O.run(100,True)
  unb=unbalancedForce()
  meanS=abs(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
  if unb<0.005 and abs(meanS-abs(confinement))/abs(confinement)<0.001:
    O.run(1000,True) # to stabilize the system
    e10=triax.strain[0]
    e20=triax.strain[1]
    e30=triax.strain[2]
    break

O.bodies[wallIds[2]].mat.frictionAngle=radians(30)
O.bodies[wallIds[3]].mat.frictionAngle=radians(30)

triax.stressMask=7
triax.goal1=confinement
triax.goal3=confinement
triax.goal2=uniaxial_stress

while 1:
 O.run(5000,True)
 triax.goal2+=delta_stress
 print 'stress', triax.goal2
 break

O.run(iterMax)

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

This question was reopened

  • by Yor1
Revision history for this message
Jérôme Duriez (jduriez) said :
#1

Hi,

I'd say it's because of the "break" in your while loop with O.run(5000,True) triax.goal2+=delta_stress.... (Such commands will then be executed only once...)

In addition to this Python remark, please try your best next time to more shorten your script code.
Anything linked with variable recording (your recorder() function, VTK Recorder engine..) is not related with your problem and only reduces your chances getting an answer (as it reduces the chances people will give a close look to lengthy codes)

Revision history for this message
Yor1 (jabrane-hamdi) said :
#2

Hello,

Thank you for the answer.
You are right, i deleted "break" and the code run very well.
I will try to shorten my script in the next times.

Jabrane.

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#3

Side remark: increasing triax.goal2 by frequent small steps (e.g. every ten iterations) is better that large steps every 5000 iterations, as it avoids shock waves.

Revision history for this message
Yor1 (jabrane-hamdi) said :
#4

Thank you for the remark.
In fact i try to realise a compression test on the sample and after that i will apply the compression on a pillar.
By the way, i have a

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

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