Error in using TriaxialStressController

Asked by ehsan benabbas

Hello all,

I am trying to code a simple Triaxial problem in the way that at the first stage, isotropic stress is applied on the specimen, and at the second stage, a deviatoric stress in z direction is applied. The result I want to get is the stress and strain curve as those we see on soil mechanics books.

I am using Ubuntu 18.04, and Yade 2019-08-08.git-775ae74

I coded this problem with TriaxialCompressionEngine while it was working limited and Yade suggested to use TriaxialStressController. Now, the code gives the following WARNINGS and does not work:

ehsan@ehsan:~/Desktop/mycodes/3axtst$ /home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74 3axtst.py
Welcome to Yade 2019-08-08.git-775ae74
Using python version: 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0]
TCP python prompt on localhost:9000, auth cookie `sdseua'
XMLRPC info provider on http://localhost:21000
Running script 3axtst.py
<WARNING> SpherePack:242 long int SpherePack::makeCloud(Vector3r, Vector3r, Real, Real, int, bool, Real, const std::vector<double>&, const std::vector<double>&, bool, int, Matrix3r): Exceeded 1000 tries to insert non-overlapping sphere to packing. Only 658 spheres were added, although you requested 2000. Trying again with porosity 0.46. The size distribution is being scaled down
<WARNING> SpherePack:242 long int SpherePack::makeCloud(Vector3r, Vector3r, Real, Real, int, bool, Real, const std::vector<double>&, const std::vector<double>&, bool, int, Matrix3r): Exceeded 1000 tries to insert non-overlapping sphere to packing. Only 689 spheres were added, although you requested 2000. Trying again with porosity 0.514. The size distribution is being scaled down
<WARNING> SpherePack:242 long int SpherePack::makeCloud(Vector3r, Vector3r, Real, Real, int, bool, Real, const std::vector<double>&, const std::vector<double>&, bool, int, Matrix3r): Exceeded 1000 tries to insert non-overlapping sphere to packing. Only 872 spheres were added, although you requested 2000. Trying again with porosity 0.5626. The size distribution is being scaled down
<WARNING> SpherePack:242 long int SpherePack::makeCloud(Vector3r, Vector3r, Real, Real, int, bool, Real, const std::vector<double>&, const std::vector<double>&, bool, int, Matrix3r): Exceeded 1000 tries to insert non-overlapping sphere to packing. Only 1056 spheres were added, although you requested 2000. Trying again with porosity 0.60634. The size distribution is being scaled down
<WARNING> SpherePack:242 long int SpherePack::makeCloud(Vector3r, Vector3r, Real, Real, int, bool, Real, const std::vector<double>&, const std::vector<double>&, bool, int, Matrix3r): Exceeded 1000 tries to insert non-overlapping sphere to packing. Only 1258 spheres were added, although you requested 2000. Trying again with porosity 0.645706. The size distribution is being scaled down
<WARNING> SpherePack:242 long int SpherePack::makeCloud(Vector3r, Vector3r, Real, Real, int, bool, Real, const std::vector<double>&, const std::vector<double>&, bool, int, Matrix3r): Exceeded 1000 tries to insert non-overlapping sphere to packing. Only 1705 spheres were added, although you requested 2000. Trying again with porosity 0.681135. The size distribution is being scaled down
Traceback (most recent call last):
  File "/home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74", line 336, in runScript
    execfile(script,globals())
  File "/usr/lib/python3/dist-packages/past/builtins/misc.py", line 82, in execfile
    exec_(code, myglobals, mylocals)
  File "3axtst.py", line 20, in <module>
    maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth)
NameError: name 'young' is not defined
[[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]]

In [1]:

*********************************************
my code is:

import numpy as np
import math
from yade import pack, plot, qt, export, utils
from datetime import datetime

sp=pack.SpherePack()
mn, mx=Vector3(0,0,0), Vector3(10,10,10)
sp.makeCloud(minCorner=mn,maxCorner=mx,rRelFuzz=0.2,num=2000,porosity=0.4)

O.materials.append(FrictMat(young=15e6,poisson=0.4,frictionAngle=radians(30),density=2600,label='spheres'))
O.materials.append(FrictMat(young=15e6,poisson=0.4,frictionAngle=0,density=0,label='frictionless'))

O.bodies.append([sphere(center,rad,material='spheres') for center, rad in sp])

walls=aabbWalls(thickness=1e-10,material='frictionless')
wallIds=O.bodies.append(walls)

triax=TriaxialStressController(
 maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth)
 finalMaxMultiplier=1.+2e3/young, # spheres growing factor (slow growth)
 thickness = 0,
 stressMask = 7,
 internalCompaction=False,
)

#***** APPLYING CONFINING PRESSURE *****#

triax.stressMask = 7
triax.goal1=triax.goal2=triax.goal3=-50e3

#***** DEVIATORIC LOADING *****#

triax.stressMask = 3
triax.goal1=triax.goal2 =-50e3
triax.goal3 = -0.2
newton.damping=0.1

#triax=TriaxialCompressionEngine(
# wall_bottom_id=wallIds[2],
# wall_top_id=wallIds[3],
# wall_left_id=wallIds[0],
# wall_right_id=wallIds[1],
# wall_back_id=wallIds[4],
# wall_front_id=wallIds[5],
# internalCompaction=False,
# sigmaIsoCompaction=-50e3,
# sigmaLateralConfinement=-50e3,
# max_vel=10,
# strainRate=0.01,
# label="triax",
#)

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=100,timestepSafetyCoefficient=0.8),
 triax,
 NewtonIntegrator(damping=0.4)
]

O.engines=O.engines[0:5]+[PyRunner(iterPeriod=20,command='history()',label='recorder')]+O.engines[5:7]
#O.engines=O.engines[0:5]+[PyRunner(command='checkUnbalanced()',realPeriod=2)]+O.engines[5:7]
#O.engines=O.engines[0:5]+[VTKRecorder(fileName='3d-vtk-',recorders=['all'],iterPeriod=1000)]+O.engines[5:7]
#O.engines=O.engines[0:5]+[qt.SnapshotEngine(fileBase='3d-',iterPeriod=200,label='snapshot')]+O.engines[5:7]
#O.engines=O.engines[0:5]+[PyRunner(command='finish()',iterPeriod=20000)]+O.engines[5:7]

O.dt=.5*PWaveTimeStep()

qt.View()

def finish():
 makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
 O.pause()

#rr=yade.qt.Renderer()
#rr.shape=False
#rr.intrPhys=True

def history():
 plot.addData(unbalanced=unbalancedForce(),i=O.iter,**O.energy,
  e11=-triax.strain[0], e22=-triax.strain[1], e33=-triax.strain[2],
  s11=-triax.stress(0)[0], s22=-triax.stress(2)[1], s33=-triax.stress(4)[2],
  Etot=O.energy.total())

#O.trackEnergy=True

def checkUnbalanced():
 if unbalancedForce()<.05:
  O.pause()
  plot.saveDataTxt('bbb.txt.bz2')

for i in O.interactions:
   id1,id2 = i.id1,i.id2
   fn = i.phys.normalForce
   fs = i.phys.shearForce

#plot.plots={'i':('unbalanced'),'i':('s11','s22','s33'),'i':('e11','e22','e33'),'i':(O.energy.keys,None,'Etot')}
plot.plots={'i':('unbalanced'),'i ':('s11','s22','s33'),' i':('e11','e22','e33'),'e22':('s22')}
plot.labels={'unbalanced':'$F_{UB}$' , 's11':'$\sigma_{11}$' , 's22':'$\sigma_{22}$' , 's33':'$\sigma_{33}$' , 'e11':'$\epsilon_{11}$' , 'e22':'$\epsilon_{22}$' , 'e33':'$\epsilon_{33}$'}
#plot.saveGnuplot()

Gl1_Sphere.stripes=True

plot.plot()

O.saveTmp()

O.run(5000,True)
plot.saveDataTxt('results')

#print 'stress difference:', (triax.stress[2]-triax.stress[1])
#print 'mean stress:',(triax.stress[2]+triax.stress[1]+triax.stress[0])/3
#print 'porosity:', porosity()

*********************************

Thank you very much for your help.
Ehsan

Question information

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

How does your script differ from the example script [1]?

[1]https://gitlab.com/yade-dev/trunk/blob/master/examples/triax-tutorial/script-session1.py

Revision history for this message
Robert Caulk (rcaulk) said :
#2

After telling us how your script is changed from the example, make sure it is free of syntax errors and undefined variables:

"NameError: name 'young' is not defined"

Revision history for this message
ehsan benabbas (ehsanben) said :
#3

I read the wiki to learn about functions in yade and some of the examples. So made a code based on those and now want to change it in a way I want, the last code (for recording video) in based on "TriaxialCompressionEngine". It wokrs but the porblem is it gives me an error to change the engine to "TriaxialStressController". I tried by my self but got the aforementioned errors. In the first version code I made, the young was not a syntaxt error. so, is it like it changes if we wanna use "TriaxialStressController"?

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

Hello,

> NameError: name 'young' is not defined
>
> triax=TriaxialStressController(
> maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth)
> finalMaxMultiplier=1.+2e3/young,

you use divide something by 'young' in TriaxialStressController, but you did not say to Yade what 'young' is (by 'young = someValue' assignment)

cheers
Jan

Revision history for this message
ehsan benabbas (ehsanben) said :
#5

Hi Jan

Thank you for your answers. I determined young and even changed the porosity to avoid getting overlap warnings for packing, now my code is as below with no warning or error in output except "AttributeError: No such attribute:", and no graph or data shows up.

**********************************
Output:

ehsan@ehsan:~/Desktop/mycodes/3axtst$ /home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74 3axtst.py
Welcome to Yade 2019-08-08.git-775ae74
Using python version: 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0]
TCP python prompt on localhost:9000, auth cookie `csasde'
XMLRPC info provider on http://localhost:21000
Running script 3axtst.py
Traceback (most recent call last):
  File "/home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74", line 336, in runScript
    execfile(script,globals())
  File "/usr/lib/python3/dist-packages/past/builtins/misc.py", line 82, in execfile
    exec_(code, myglobals, mylocals)
  File "3axtst.py", line 32, in <module>
    internalCompaction=False,
AttributeError: No such attribute: goal.
[[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]]

In [1]:
**********************************

My code:

import numpy as np
import math
from yade import pack, plot, qt, export, utils
from datetime import datetime

young=15e6
poisson=0.4
sigmaIso=-50e3

sp=pack.SpherePack()
mn, mx=Vector3(0,0,0), Vector3(10,10,10)
sp.makeCloud(minCorner=mn,maxCorner=mx,rRelFuzz=0.2,num=2000,porosity=0.7)

O.materials.append(FrictMat(young=15e6,poisson=0.4,frictionAngle=radians(30),density=2600,label='spheres'))
O.materials.append(FrictMat(young=15e6,poisson=0.4,frictionAngle=0,density=0,label='frictionless'))

O.bodies.append([sphere(center,rad,material='spheres') for center, rad in sp])

walls=aabbWalls(thickness=1e-10,material='frictionless')
wallIds=O.bodies.append(walls)

#################################################
######### Triaxial Test #########

triax=TriaxialStressController(
 maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth)
 finalMaxMultiplier=1.+2e3/young, # spheres growing factor (slow growth)
 thickness = 0,
 goal=(sigmaIso,sigmaIso,sigmaIso),stressMask=7,
 internalCompaction=False,
)

######################################################
######### DEVIATORIC LOADING #########

triax.stressMask = 3
triax.goal1 = sigmaIso
triax.goal2 = sigmaIso
triax.goal3 = -0.2
newton.damping=0.4

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=100,timestepSafetyCoefficient=0.8),
 triax,
 NewtonIntegrator(damping=0.4),
 PyRunner(iterPeriod=20,command='history()',label='recorder'),
 PyRunner(command='checkUnbalanced()',realPeriod=2)
]

O.dt=.5*PWaveTimeStep()

qt.View()

def history():
 plot.addData(unbalanced=unbalancedForce(),i=O.iter,**O.energy,
  e11=-triax.strain[0], e22=-triax.strain[1], e33=-triax.strain[2],
  s11=-triax.stress(0)[0], s22=-triax.stress(2)[1], s33=-triax.stress(4)[2],
  Etot=O.energy.total())

def checkUnbalanced():
 if unbalancedForce()<.05:
  O.pause()
  plot.saveDataTxt('bbb.txt.bz2')

plot.plots={'i':('unbalanced'),'i ':('s11','s22','s33'),' i':('e11','e22','e33'),'e22':('s22')}
plot.labels={'unbalanced':'$F_{UB}$' , 's11':'$\sigma_{11}$' , 's22':'$\sigma_{22}$' , 's33':'$\sigma_{33}$' , 'e11':'$\epsilon_{11}$' , 'e22':'$\epsilon_{22}$' , 'e33':'$\epsilon_{33}$'}

Gl1_Sphere.stripes=True

plot.plot()

O.saveTmp()

O.run(5000,True)
plot.saveDataTxt('results')

*************************************

Thank you for your help.

Revision history for this message
Best Robert Caulk (rcaulk) said :
#6

 "File "3axtst.py", line 32, in <module>
    internalCompaction=False,
AttributeError: No such attribute: goal."

Is telling you that at Line 32, it is encountering an attribute called "goal", but there is no corresponding attribute in TriaxialStressController.

I guess you are looking for goal1, goal2, and goal3 [1]

[1]https://yade-dev.gitlab.io/trunk/yade.wrapper.html#yade.wrapper.TriaxialStressController

Revision history for this message
ehsan benabbas (ehsanben) said :
#7

Thanks Robert Caulk, that solved my question.