usage of label

Asked by JIPEIQI

I wonder the usage of lagel, it works fine for my previous simulation, but suddenly gets error and I can't figure out why. Here is a simple test script:

Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=5.,smoothJoint=True,recordCracks=False,momentsFileExist=False,cracksFileExist=False,label='jcf',neverErase=True)
print jcf

#################### or
O.materials.append(JCFpmMat(type=1,young=64e9,poisson=1.0,frictionAngle=radians(0),density=3000,tensileStrength=0,cohesion=0,label='walls'))

print walls

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
Last query:
Last reply:
Revision history for this message
JIPEIQI (jpq-learning) said :
#1

A more confusing situation would be :

dd='2'
radmult=1
savepath='s'
#Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=5.,smoothJoint=True,recordCracks=False,momentsFileExist=False,cracksFileExist=False,label='jcf',neverErase=True)
#print jcf
dd='2'
radmult=1
savepath='s'
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=radmult),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=radmult),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=2.,smoothJoint=True,recordCracks=True,recordMoments=True,momentsFileExist=False,cracksFileExist=False,label='jcf',Key=dd,neverErase=True)]
 ),
 #GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.8),
 newton,
 #VTKRecorder(fileName="%suniax"%(savepath),recorders=['all','cracks','jcfpm','moments'],label='vvtk',iterPeriod=5000,Key=dd),
]
print jcf
triax = ThreeDTriaxialEngine( thickness=0, stressControl_1=False,stressControl_2=True, stressControl_3=False, goal1=0, goal2=-123, goal3=0., max_vel=0.1, internalCompaction=False,)
O.run(1)# This this line is commented, then everything works fine

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=radmult),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=radmult),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=2.,smoothJoint=True,recordCracks=True,recordMoments=True,momentsFileExist=False,cracksFileExist=False,label='jcf2',Key=dd,neverErase=True)]
 ),
 #GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.8),
 #triax,
 newton,
 VTKRecorder(fileName="%suniax"%(savepath),recorders=['all','cracks','jcfpm','moments'],label='vvtk',iterPeriod=5000,Key=dd),
 PyRunner(command='addPlotData()',iterPeriod=100),
 PyRunner(command='stopIt()',iterPeriod=1000),
 PyRunner(command='saveplot()',iterPeriod=1000),
]
print jcf2

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

Hello,

>but suddenly gets error

Will you please be a bit more specific? What is the error? Please review [1] and provide the necessary information to receive assistance.

Cheers,

Robert

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

Revision history for this message
JIPEIQI (jpq-learning) said :
#3

Soory, I forgot the error message.

The error is :" Global name "jcf" is not defined."

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

When you redefine your engine list, you no longer have an engine labeled “jfc”.

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

I could not reproduce the problem. On Ubuntu 18.04, Yade 2018.02b, both print jcf and print jcf2 prints <Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM instance at 0x...>
cheers
Jan

Revision history for this message
JIPEIQI (jpq-learning) said :
#6

Hi Jan. Sorry about the inaccurate script above. The script indeed goes fine. But if you add anything to the last line, then it just goes wrong! Like this :

dd='2'
radmult=1
savepath='s'
#Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=5.,smoothJoint=True,recordCracks=False,momentsFileExist=False,cracksFileExist=False,label='jcf',neverErase=True)
#print jcf
dd='2'
radmult=1
savepath='s'
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=radmult),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=radmult),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=2.,smoothJoint=True,recordCracks=True,recordMoments=True,momentsFileExist=False,cracksFileExist=False,label='jcf',Key=dd,neverErase=True)]
 ),
 #GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.8),
 newton,
 #VTKRecorder(fileName="%suniax"%(savepath),recorders=['all','cracks','jcfpm','moments'],label='vvtk',iterPeriod=5000,Key=dd),
]
print jcf
triax = ThreeDTriaxialEngine( thickness=0, stressControl_1=False,stressControl_2=True, stressControl_3=False, goal1=0, goal2=-123, goal3=0., max_vel=0.1, internalCompaction=False,)
O.run(1)# This this line is commented, then everything works fine

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=radmult),Bo1_Facet_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=radmult),Ig2_Facet_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(momentRadiusFactor=2.,smoothJoint=True,recordCracks=True,recordMoments=True,momentsFileExist=False,cracksFileExist=False,label='jcf2',Key=dd,neverErase=True)]
 ),
 #GlobalStiffnessTimeStepper(timestepSafetyCoefficient=0.8),
 #triax,
 newton,
 VTKRecorder(fileName="%suniax"%(savepath),recorders=['all','cracks','jcfpm','moments'],label='vvtk',iterPeriod=5000,Key=dd),
 PyRunner(command='addPlotData()',iterPeriod=100),
 PyRunner(command='stopIt()',iterPeriod=1000),
 PyRunner(command='saveplot()',iterPeriod=1000),
]
print jcf2
33# do anthing

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

> But if you add anything to the last line, then it just goes wrong!
> 33# do anthing

Sorry, please be as specific as possible and prodive a MWE [1] reproducing your problem.
For example, I added
print 1+1
which normally printed 2 as the expected result..

> O.run(1)# This this line is commented, then everything works fine

O.run(N) and writing other code is not a good idea as the behavior is undefined (running Yade and executing the other python code run alongside in separate threads).
Use either O.step() or O.run(1,True)

cheers
Jan

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

Revision history for this message
JIPEIQI (jpq-learning) said :
#8

Thanks Jan Stránský, that solved my question.