TW=TesselationWrapper()

Asked by nobody on 2019-09-20

hi all,

I am using the supercomputer to do some simulations. I want to get the microstrain field, so I did as the document said. which means including this TW=TesselationWrapper(), but I got an error.

Traceback (most recent call last):
  File "/packages/7x/yade/2018.02b/bin/yade-2018.02b", line 182, in runScript
    execfile(script,globals())
  File "microscale.py", line 149, in <module>
    TW=TesselationWrapper()
NameError: name 'TesselationWrapper' is not defined
 unbalanced force: 6.45473797305e-06 mean stress: -99999.9975958
porosity= 0.429910437487
unbalanced force: 7.80668882803e-06 mean stress: -100000.028644
### Compacted state saved ###
porosity= 0.429910437332

######################
here is part of the code related to the TessalationWrapper command.
####################################
############################
### DEFINING PARAMETERS ###
############################
from yade import pack, plot
from yade import export
from yade import utils
nRead=readParamsFromTable(
 num_spheres=5288,
 compFricDegree=45.0,
 key='_triax_base_'+'100',
 goal_confining_pressure=-100000,
 unknownOK=True
)
from yade.params import table
num_spheres=table.num_spheres
key=table.key
targetPorosity=0.43
compFricDegree=table.compFricDegree
finalFricDegree=19.5
rate=-15
damp=0.7
target_strain = 0.15
stabilityThreshold=0.001
young=4e8
mn,mx=Vector3(0,0,0),Vector3(4e-3,8e-3,4e-3)
O.materials.append(CohFrictMat(young=young,poisson=0.3,frictionAngle=radians(compFricDegree),isCohesive=False,alphaKr=0.2,alphaKtw=0,etaRoll=0.5,momentRotationLaw=True,density=2648,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=0.3,frictionAngle=0,density=0,label='walls'))
walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)
sp=pack.SpherePack()
psdSizes=[0.12e-3,0.14e-3,0.16e-3,0.18e-3,0.19e-3,0.20e-3,0.22e-3,0.24e-3,0.29e-3,0.38e-3]
psdCumm=[0,11.1,22.2,33.3,44.4,55.5,66.6,77.7,88.8,100]
sp.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,num=2000,distributeMass=1,seed=1)
sp.toSimulation(material='spheres')
print "num_spheres= ", len(O.bodies)
O.dt=.5*PWaveTimeStep()
print "num_spheres= ", len(O.bodies)
############################
### DEFINING ENGINES ###
############################
triax=TriaxialStressController(
 maxMultiplier=1.0+2e5/young,
 finalMaxMultiplier=1.0+2e4/young,
 thickness=0,
 stressMask=7,
 internalCompaction=False
)
newton=NewtonIntegrator(damping=damp)
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
   [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
 triax,
 #VTKRecorder(fileName='george-triaxial-',recorders=['all'],iterPeriod=1000),
 #TriaxialStateRecorder(iterPeriod=2000,file='WallStresses-george'+table.key),
 newton,
 #PyRunner(command='history()',iterPeriod=10000),
 #PyRunner(command='stop_loading()',iterPeriod=10000),
]
#Gl1_Sphere.stripes=0
#if nRead==0: yade.qt.Controller(),yade.qt.View()
########################################
#### APPLYING CONFINING PRESSURE ###
########################################
triax.goal1=triax.goal2=triax.goal3=-100000
while 1:
 O.run(3000,True)
 unb=unbalancedForce()
 print 'unbalanced force: ',unb,'mean stress: ',triax.meanStress
 if unb<stabilityThreshold and abs(-100000-triax.meanStress)/-100000<0.001:
  break
####################################################
#### REACHING A SPECIFIED POROSITY PRECISELY ###
####################################################
while triax.porosity>targetPorosity:
 compFricDegree = 0.95*compFricDegree
 setContactFriction(radians(compFricDegree))
 print "\r Friction: ",compFricDegree," porosity:",triax.porosity,
 sys.stdout.flush()
 O.run(500,1)
triax.wall_bottom_activated=True
triax.wall_top_activated=True
triax.wall_left_activated=True
triax.wall_right_activated=True
triax.wall_back_activated=True
triax.wall_front_activated=True
setContactFriction(radians(finalFricDegree))
while 1:
 O.run(3000,True)
 unb=unbalancedForce()
 print 'unbalanced force: ',unb,'mean stress: ',triax.meanStress
 if unb<stabilityThreshold and abs(-100000-triax.meanStress)/-100000<0.001:
  break
print "porosity= ",triax.porosity
triax.goal1=triax.goal2=triax.goal3=-100000
while 1:
    O.run(1000, True)
    unb=unbalancedForce()
    print 'unbalanced force:',unb,' mean stress: ',triax.meanStress
    if unb<stabilityThreshold and abs(-100000-triax.meanStress)/-100000<0.001:
        break
#O.save('compactedState'+key+'.yade.gz')
print "### Compacted state saved ###"
print "porosity= ",triax.porosity
re11=-triax.strain[0]
re22=-triax.strain[1]
re33=-triax.strain[2]
################################
##### DEVIATORIC LOADING ###
################################
triax.stressMask = 5
newton=NewtonIntegrator(damping=0.0)
#now goal2 is the target strain rate
triax.goal2=rate
# we define the lateral stresses during the test, here the same 10kPa as for the initial confinement.
triax.goal1=-100000
triax.goal3=-100000
triax.strainRate2=15
triax.strainRate1=triax.strainRate3=1000.0
######################################################

def history():
   plot.addData(e11=-triax.strain[0]-re11, e22=-triax.strain[1]-re22, e33=-triax.strain[2]-re33,
        ev=-triax.strain[0]-re11-triax.strain[1]-re22-triax.strain[2]-re33,
      s11=-triax.stress(triax.wall_right_id)[0],
      s22=-triax.stress(triax.wall_top_id)[1],
      s33=-triax.stress(triax.wall_front_id)[2],
      CN=avgNumInteractions(cutoff=0.0, skipFree=False, considerClumps=False),
   FT1=utils.fabricTensor(cutoff=0.0,splitTensor=True)[0],
   FT2=utils.fabricTensor(cutoff=0.0,splitTensor=True)[1],
             i=O.iter)
 plot.saveDataTxt('calibration-george.txt')
#### loading condition####
def stop_loading():
 if -triax.strain[1]-re22> target_strain:
  O.pause()

#### export the displacement filed ####
vtk = export.VTKExporter("displacement-needed")
def doExport():
 #vtk.exportSpheres(what=dict(dist='b.state.pos.norm()'))
 vtk.exportSpheres(ids='all',what=[('disp','b.state.displ()')],useRef=True)
##### export the strain field ####
TW=TesselationWrapper() ###### this is line 149
TW.triangulate()
TW.computeVolumes()
TW.setState(0)
O.run(100,True)
TW.setState(1)
def strain_export():
 TW.setState(1)
 TW.defToVtk("strain.vtk")
###### export the sress field ####
TW=TesselationWrapper()
TW.setState()
TW.computeVolumes()
s=bodyStressTensors()
for b in O.bodies:
 if isinstance(b.shape,Sphere):
  b.mystress = s[b.id]*4.*pi/3.*b.shape.radius**3/TW.volume(b.id)
vtk = export.VTKExporter("stress-needed")
def stress_export():
 vtk.exportSpheres(ids='all',what=[('stress','b.mystress')],useRef=True)

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
   [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
 triax,
 #VTKRecorder(fileName='george-triaxial-',recorders=['all'],iterPeriod=1000),
 #TriaxialStateRecorder(iterPeriod=2000,file='WallStresses-george'+table.key),
 newton,
 PyRunner(command='history()',iterPeriod=10000),
 PyRunner(command='stop_loading()',iterPeriod=10000),
 PyRunner(command='doExport()',iterPeriod=10000),
 PyRunner(command='strain_export()',iterPeriod=10000),
 PyRunner(command='stress_export()',iterPeriod=10000),
]
O.run(5000000,True)
####################################################
#plot.plots={'e22':('s22',None,('ev','r--'))}
#plot.plot()

####################################
I found a similar question, they said the reason may be the older version. But the version of Yade in the supercomputer is:

TCP python prompt on localhost:9000, auth cookie `udseck'
Welcome to Yade 2018.02b
XMLRPC info provider on http://localhost:21000
Running script microscale.py

Is there anyone can give me some suggestions. thanks in advance.

Yong

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
2019-09-24
Last query:
2019-09-24
Last reply:
2019-09-24
Robert Caulk (rcaulk) said : #1

>I found a similar question, they said the reason may be the older version.

Perhaps a link to the question would help us understand and explain context?

>but I got an error.

I ran your code with yade-2018.02b and did not encounter any errors. The script successfully creates many .vtk files using TesselationWrapper. You might consider creating an MWE. MWE's are scripts that are designed by removing all unnecessary functionality (e.g. do these stress and porosity while loops have an effect on your error? Test it!) while maintaining the error. In fact, you might consider starting with the TesselationWrapper example script [1] and building on top of it. Does your code fail with JUST the example script? Maybe you see how this process is helpful for you and for us :-)?

Cheers,

Robert

[1]https://gitlab.com/yade-dev/trunk/blob/master/examples/tesselationwrapper/tesselationWrapper.py

nobody (nobody01) said : #2

Hi Robert,

just a quick reply.

Just now I run the example on the cluster. I got the same error.

TCP python prompt on localhost:9000, auth cookie `uydsek'
Welcome to Yade 2018.02b
XMLRPC info provider on http://localhost:21000
Running script microscale.py
Traceback (most recent call last):
  File "/packages/7x/yade/2018.02b/bin/yade-2018.02b", line 182, in runScript
    execfile(script,globals())
  File "microscale.py", line 12, in <module>
    TW=TesselationWrapper()
NameError: name 'TesselationWrapper' is not defined

best,
yong

nobody (nobody01) said : #3

Hi Robert,

Here is the link for this similar question.

https://answers.launchpad.net/yade/+question/204632

best,
Yong

Robert Caulk (rcaulk) said : #4

>Just now I run the example on the cluster. I got the same error.

What is the linux distro of the cluster? What was the installation method?

BTW my responses so far have guided you through [1] for future considerations.

-rc

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

nobody (nobody01) said : #5

>What is the Linux distro of the cluster? What was the installation method?

Hi Robert,
Yade on the cluster was installed by the IT from our university, so right now I do not know about this, but I will email them and reply to you tomorrow.

Here is an MWE.

######################
from yade import pack, plot
from yade import export
from yade import utils
compFricDegree=45.0
finalFricDegree=19.5
rate=-15
damp=0.7
target_strain = 0.15
stabilityThreshold=0.001
young=4e8
mn,mx=Vector3(0,0,0),Vector3(4e-3,8e-3,4e-3)
O.materials.append(CohFrictMat(young=young,poisson=0.3,frictionAngle=radians(compFricDegree),isCohesive=False,alphaKr=0.2,alphaKtw=0,etaRoll=0.5,momentRotationLaw=True,density=2648,label='spheres'))
O.materials.append(FrictMat(young=young,poisson=0.3,frictionAngle=0,density=0,label='walls'))
walls=aabbWalls([mn,mx],thickness=0,material='walls')
wallIds=O.bodies.append(walls)
sp=pack.SpherePack()
psdSizes=[0.12e-3,0.14e-3,0.16e-3,0.18e-3,0.19e-3,0.20e-3,0.22e-3,0.24e-3,0.29e-3,0.38e-3]
psdCumm=[0,11.1,22.2,33.3,44.4,55.5,66.6,77.7,88.8,100]
sp.makeCloud(mn,mx,psdSizes=psdSizes,psdCumm=psdCumm,num=2000,distributeMass=1,seed=1)
sp.toSimulation(material='spheres')
O.dt=.5*PWaveTimeStep()
triax=TriaxialStressController(
 maxMultiplier=1.0+2e5/young,
 finalMaxMultiplier=1.0+2e4/young,
 thickness=0,
 stressMask=7,
 internalCompaction=False
)
newton=NewtonIntegrator(damping=damp)
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
   [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
 triax,
 newton,
]
triax.goal1=triax.goal2=triax.goal3=-100000
while 1:
 O.run(3000,True)
 unb=unbalancedForce()
 print 'unbalanced force: ',unb,'mean stress: ',triax.meanStress
 if unb<stabilityThreshold and abs(-100000-triax.meanStress)/-100000<0.001:
  break
triax.wall_bottom_activated=True
triax.wall_top_activated=True
triax.wall_left_activated=True
triax.wall_right_activated=True
triax.wall_back_activated=True
triax.wall_front_activated=True
setContactFriction(radians(finalFricDegree))
re11=-triax.strain[0]
re22=-triax.strain[1]
re33=-triax.strain[2]
triax.stressMask = 5
newton=NewtonIntegrator(damping=0.0)
triax.goal2=rate
triax.strainRate2=15
triax.strainRate1=triax.strainRate3=1000.0
def stop_loading():
 if -triax.strain[1]-re22> target_strain:
  O.pause()
#TW=TesselationWrapper() ###### this line
#TW.triangulate()
#TW.computeVolumes()
#TW.setState(0)
#O.run(100,True)
#TW.setState(1)
#def strain_export():
 #TW.setState(1)
 #TW.defToVtk("strain.vtk")
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
   [Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Box_Sphere_ScGeom()],
   [Ip2_FrictMat_FrictMat_FrictPhys(),Ip2_CohFrictMat_CohFrictMat_CohFrictPhys()],
   [Law2_ScGeom_FrictPhys_CundallStrack(),Law2_ScGeom6D_CohFrictPhys_CohesionMoment(useIncrementalForm=True,always_use_moment_law=True,label='cohesiveLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=10,timestepSafetyCoefficient=0.8),
 triax,
 newton,
 PyRunner(command='stop_loading()',iterPeriod=10000),
 #PyRunner(command='strain_export()',iterPeriod=10000),
]
O.run(5000000,True)

IF I comment out this: TW=TW=TesselationWrapper(), as you can see from the code. This script works fine. But when I include these few lines. the error comes out.

TCP python prompt on localhost:9000, auth cookie `csudsy'
Welcome to Yade 2018.02b
XMLRPC info provider on http://localhost:21000
Running script microscale.py
Traceback (most recent call last):
  File "/packages/7x/yade/2018.02b/bin/yade-2018.02b", line 182, in runScript
    execfile(script,globals())
  File "microscale.py", line 67, in <module>
    TW=TesselationWrapper()
NameError: name 'TesselationWrapper' is not defined

I hope this message can help me to present my problem more clearly.

best,
Yong

> NameError: name 'TesselationWrapper' is not defined

I would say yade was compiled without CGAL support.
B

nobody (nobody01) said : #7

Thanks Bruno Chareyre, that solved my question.