yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #21109
[Question #685331]: NameError Traceback (most recent call last)
New question #685331 on Yade:
https://answers.launchpad.net/yade/+question/685331
Hello,
I am using Ubuntu 18.04, and Yade 2019-08-08.git-775ae74
I have read the wiki and tutorials, struggle with codes as a beginner in yade and asked some questions. Finally, I slightly changed https://.../script-session1.py. I got some errors such as syntax ones and fixed the, but I get the following error repeatedly as follows now:
ehsan@ehsan:~/Desktop$ /home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74 Q.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 `yksdca'
XMLRPC info provider on http://localhost:21000
Running script Q.py
The constructor with a shareWidget is deprecated, use the regular contructor instead.
Number of elements: 2006
Box Volume: 5.3940427e-317
Box Volume calculated: 1000.0
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/yade/install/bin/yade-2019-08-08.git-775ae74 in <module>
NameError: name 'history' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/yade/install/bin/yade-2019-08-08.git-775ae74 in <module>
NameError: name 'history' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/yade/install/bin/yade-2019-08-08.git-775ae74 in <module>
NameError: name 'history' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
~/yade/install/bin/yade-2019-08-08.git-775ae74 in <module>
.
.
.
Since I have defined "history()", I don't know what is the problem. Unfortunately couldn't find the answer by googling it.
*****************************************************************************
This is my code:
############################################################################################################################
######### TRIAXIAL PROBLEM, Y IS THE VERTICAL AXIS, X IS THE RIGHT AXIS, Z IS THE FRONT AXIS #########
############################################################################################################################
import numpy as np
import math
from yade import pack, plot, qt, export, utils
from datetime import datetime
######################################################
######### DEFINING VARIABLES #########
nRead=readParamsFromTable(
num_spheres=2000,
compFricDegree = 30,
key='_triax_base_',
unknownOk=True
)
from yade.params import table
num_spheres=table.num_spheres
key=table.key
targetPorosity = 0.43
compFricDegree = table.compFricDegree
finalFricDegree = 30
rate=-0.02
damp=0.2
stabilityThreshold=0.01
young=15e6
poisson=0.4
mn,mx=Vector3(0,0,0),Vector3(10,10,10)
sigmaIso=-50e3
######################################################
######### DEFINING MATERIALS #########
O.materials.append(FrictMat(young=young,poisson=poisson,frictionAngle=radians(compFricDegree),density=2600,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=poisson,frictionAngle=0,density=0,label='frictionlesswalls'))
####################################################
######### DEFINING PACKING #########
walls=aabbWalls([mn,mx],thickness=0,material='frictionlesswalls')
wallIds=O.bodies.append(walls)
sp=pack.SpherePack()
volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2])
mean_rad = pow(0.09*volume/num_spheres,0.3333)
clumps=False
if clumps:
volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2])
mean_rad = pow(0.09*volume/num_spheres,0.3333)
c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)])
sp.makeClumpCloud(mn,mx,[c1],periodic=False)
sp.toSimulation(material='spheres')
O.bodies.updateClumpProperties()
else:
sp.makeCloud(mn,mx,-1,0.3333,num_spheres,False, 0.95,seed=1)
O.bodies.append([sphere(center,rad,material='spheres') for center,rad in sp])
##########################################################
######### DEFINING TRIAXIAL TEST #########
triax=TriaxialStressController(
maxMultiplier=1.+2e4/young,
finalMaxMultiplier=1.+2e3/young,
thickness = 0,
stressMask = 7,
internalCompaction=False
)
####################################################
######### DEFINING ENGINES #########
newton=NewtonIntegrator(damping=damp)
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,
TriaxialStateRecorder(iterPeriod=100,file='WallStresses'+table.key),
newton,
PyRunner(iterPeriod=20,command='history()',label='recorder'),
PyRunner(command='checkUnbalanced()',realPeriod=2)
]
Gl1_Sphere.stripes=True
if nRead==0: yade.qt.Controller(), yade.qt.View()
print ('Number of elements: ', len(O.bodies))
print ('Box Volume: ', triax.boxVolume)
print ('Box Volume calculated: ', volume)
###############################################################
######### APPLYING CONFINING PRESSURE #########
triax.internalCompaction=False
setContactFriction=radians(compFricDegree)
triax.stressmask=7
triax.goal1=sigmaIso
triax.goal2=sigmaIso
triax.goal3=sigmaIso
while 1:
O.run(1000, True)
unb=unbalancedForce()
meanS=(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 engine: ',triax.meanStress,' mean stress (Calculated): ',meanS)
print ('porosity=',triax.porosity)
print ('void ratio=',triax.porosity/(1-triax.porosity))
print ('-----Phase_01: Isotropic compression 50kPa--(^_^)---')
if unb<stabilityThreshold and abs(sigmaIso-triax.meanStress)/sigmaIso<0.001:
break
O.save('confinedPhase'+key+'.xml')
print ('### Isotropic phase saved ###')
######################################################
######### DEVIATORIC LOADING #########
triax.internalCompaction=False
setContactFriction=radians(compFricDegree)
triax.stressMask = 5
triax.goal2=rate
triax.goal1=sigmaIso
triax.goal3=sigmaIso
while 1:
O.run(1000, True)
unb=unbalancedForce()
axialS=triax.stress(triax.wall_top_id)[1]
print ('step=', O.iter, 'unbalanced force:',unb,' sigma2: ',axialS, 'q=', axialS-sigmaIso)
print ('axial deformation (%)', (triax.strain[1]-e22Check)*100)
if abs((triax.strain[1]-e22Check)-0.01)<=0.001:
O.save('firstpoint.xml')
if abs((triax.strain[1]-e22Check)-0.02)<=0.001:
O.save('secondpoint.xml')
if abs((triax.strain[1]-e22Check)-0.03)<=0.001:
O.save('thirdpoint.xml')
if abs((triax.strain[1]-e22Check)-0.05)<=0.001:
O.save('fourthpoint.xml')
if triax.strain[1]-e22Check>=0.3 :
break
O.save('final.xml')
########################################################
######### RECORD AND PLOT DATA #########
qt.View()
def checkUnbalanced():
if unbalancedForce()<.05:
O.pause()
plot.saveDataTxt('bbb.txt.bz2')
def history():
plot.addData(e11=-triax.strain[0], e22=-triax.strain[1], e33=-triax.strain[2],
ev=-triax.strain[0]-triax.strain[1]-triax.strain[2],
s11=-triax.stress(triax.wall_right_id)[0],
s22=-triax.stress(triax.wall_top_id)[1],
s33=-triax.stress(triax.wall_front_id)[2],
i=O.iter,unbalanced=unbalancedForce()
)
O.run(5000,True)
plot.plots={'e22':('s11','s22','s33'),'e22':('ev')}
plot.labels={'s11':'$\sigma_{11}$' , 's22':'$\sigma_{22}$' , 's33':'$\sigma_{33}$' , 'e11':'$\epsilon_{11}$' , 'e22':'$\epsilon_{22}$' , 'e33':'$\epsilon_{33}$' , 'ev':'$\epsilon_{V}$'}
plot.plot()
plot.saveDataTxt('results'+key)
plot.saveGnuplot('plotScript'+key)
********************************************************
And also before the error, I get 1 notice as "The constructor with a shareWidget is deprecated, use the regular contructor instead.". I don't know if this affects my code or not.
Could you please let me know if there is any other mistake in this code?
Thank you very much for your help.
--
You received this question notification because your team yade-users is
an answer contact for Yade.