About ValueError: cannot convert float NaN to integer

Asked by Ziyu Wang

Hello,
I have encountered a problem similar to that in [1], but my script is different from it. I have read the relevant answers in [1].

My question Description:
My script is about fluid-solid coupling triaxial compression,relevant research is carried out by changing confining pressure and osmotic pressure.I have successfully run some scripts (under the condition of confining pressure of 20, 40 and 60MPa respectively, the osmotic pressure is 10, 20, 30, 40 and 50MPa respectively).
However, when the confining pressure is 80MPa, the script can run normally when the osmotic pressure is 10 and 20MPa. When it increases to 30 and 40MPa, an error prompt as described in the title appears.

Some problems related to locking some degrees of freedom and walls are mentioned in [1],In my script, I did turn off the movement of the wall in the X and Y directions (the script is shown below).I have tried to set the thickness of the wall to a positive value, the error does not appear, but the result is completely different from the law obtained from my previous work (the peak strength and peak strain of the sample become larger)

I'm confused and don't know how to solve this problem. In other words, if it's because of the wall thickness problem, why can the previous scripts run normally?

Thanks for kindly help!!!(Maybe my problem description is too long..sorry)

---------------------------------------------script-----------------------------------------
from yade import pack, ymport, plot, utils, export, timing
from builtins import range

Sy=40e6
Wy=-80e6
rate=-0.2
damp=0.4
stabilityThreshold=0.001
key='_triax_base_'
young=3000e9
name='JCFPM_triax'
compFricDegree=30
poisson=0.4
OUT=str(Wy)+'_HM-coupling'

mn,mx=Vector3(0,0,0),Vector3(0.05,0.05,0.05)
O.materials.append(JCFpmMat(type=1,density=2640,young=young,poisson=poisson,tensileStrength=160e6,cohesion=1600e6,frictionAngle=radians(10),label='sphere'))
O.materials.append(JCFpmMat(type=1,frictionAngle=0,density=0,label='wall'))

walls=aabbWalls([mn,mx],thickness=0,material='wall')
wallIds=O.bodies.append(walls)

O.bodies.append(ymport.text('packing-JCFPM.spheres',scale=1,shift=Vector3(0,0,0),material='sphere',color=(0.6,0.5,0.15)))

triax=TriaxialStressController(
 maxMultiplier=1.+4e8/young,
 finalMaxMultiplier=1.+4e7/young,
 thickness = 0,
 stressMask = 7,
 internalCompaction=True,
)
newton=NewtonIntegrator(damping=damp)

def recorder():
 yade.plot.addData(
 i=O.iter,
 e11=-triax.strain[0],#e22=-triax.strain[1],
 e33=-triax.strain[2],
 s11=-triax.stress(triax.wall_right_id)[0],#0+边界id为right
 #s22=-triax.stress(triax.wall_top_id)[1],#1+边界id为top
 s33=-triax.stress(triax.wall_front_id)[2],#2+边界id为front
 numberTc=interactionLaw.nbTensCracks,
 numberSc=interactionLaw.nbShearCracks,
 unb=unbalancedForce(),
 flux1=flow.getBoundaryFlux(4),
 flux2=flow.getBoundaryFlux(5),
 timestep=O.dt
)
 plot.saveDataTxt(OUT)

def stop_condition():
 extremum=max(abs(s) for s in plot.data['s33'])
 s=abs(plot.data['s33'][-1])
 e=abs(plot.data['e33'][-1])
 if e < 0.001:
  return
 if abs(s)/abs(extremum) < 0.9 and abs(s)>abs(Wy) :
  print('Max stress and strain:',extremum,e)
  presentcohesive_count = 0
  for i in O.interactions:
          if hasattr(i.phys, 'isCohesive'):
               if i.phys.isCohesive == True:
                   presentcohesive_count+=1
  print('the number of cohesive bond now is:',presentcohesive_count)
  O.wait()

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.5,label='is2aabb'),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(interactionDetectionFactor=1.5,label='ss2sc'),Ig2_Box_Sphere_ScGeom()],
  [Ip2_JCFpmMat_JCFpmMat_JCFpmPhys()],
  [Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=True,Key=OUT+'_Crack',label='interactionLaw')]
 ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8),
 triax,
 FlowEngine(dead=1,label='flow'),
 PyRunner(iterPeriod=int(1000),initRun=True,command='recorder()',label='data',dead=0),
 PyRunner(iterPeriod=1000,command='stop_condition()',dead=0),
 VTKRecorder(iterPeriod=500,initRun=True,fileName='triax/JFFPM-',recorders=['spheres','jcfpm','cracks'],Key='triax',label='vtk',dead=1),
 newton,
]

O.step()
ss2sc.interactionDetectionFactor=-1
is2aabb.aabbEnlargeFactor=-1

cohesiveCount = 0
for i in O.interactions:
 if hasattr(i.phys, 'isCohesive'):
              if i.phys.isCohesive == True:
                     cohesiveCount+=1
print('the origin total number of cohesive bond is:',cohesiveCount)

triax.goal1=triax.goal2=triax.goal3=Wy
while 1:
 O.run(1000,1)
 unb=unbalancedForce()
 print('unbalanced force:',unb,'mean stres:',triax.meanStress)
 if unb<stabilityThreshold and abs(Wy-triax.meanStress)/abs(Wy)<0.001:
  break
cohesiveCount = 0
for i in O.interactions:
 if hasattr(i.phys, 'isCohesive'):
              if i.phys.isCohesive == True:
                     cohesiveCount+=1
print('the first total number of cohesive bond is:',cohesiveCount)

yade.timing.reset()
flow.dead=0
flow.debug=False
flow.fluidBulkModulus=2.2e9
flow.permeabilityFactor=10
flow.decoupleForces = False
flow.meshUpdateInterval=1000
flow.useSolver=4
flow.viscosity=0.001
flow.bndCondIsPressure=[0,0,0,0,1,1]
flow.bndCondValue=[0,0,0,0,0,Sy]

triax.internalCompaction=False
flow.emulateAction()
triax.stressMask=3
triax.wall_left_activated=False
triax.wall_right_activated=False
triax.wall_bottom_activated=False
triax.wall_top_activated=False
triax.goal1=Wy
triax.goal2=Wy
triax.goal3=rate

plot.plots={'e33':(('s33','g'),None,('unb','b')),'i':(('numberTc','b'),('numberSc','r'),None,('s33','y'))}
plot.plot(subPlots=False)
O.run()
-----------------------------------------------------------------------------

[1]https://answers.launchpad.net/yade/+question/693071

Question information

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

Hello,

> an error prompt as described in the title appears.

please provide complete error (which also includes the problematic line and error stack).

> I have tried to set the thickness of the wall to a positive value, the error does not appear, but the result is completely different from the law obtained from my previous work (the peak strength and peak strain of the sample become larger)

if you change thickness, try also to shift the walls, such that the actual wall remains unchanged.

> Maybe my problem description is too long..sorry

IMO it is better then the opposite way

Cheers
Jan

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#2

Hello,Jan.
I have made some attempts according to your suggestion, but the problem has not been solved, as described below:

>please provide complete error (which also includes the problematic line and error stack).

The complete error prompt command line is as follows (completely copied from Yade):
--------------------------------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/usr/lib/x86_64-linux-gnu/yadedaily/py/yade/__init__.py in refreshEvent(self)
    201 def zxySlot(self): self.setViewAxes((0,-1,0),(1,0,0))
    202 def refreshEvent(self):
--> 203 self.refreshValues()
    204 self.activateControls()
    205 def deactivateControls(self):

/usr/lib/x86_64-linux-gnu/yadedaily/py/yade/__init__.py in refreshValues(self)
    273 self.iterLabel.setText('#%ld / %ld, %.1f/s %s'%(O.iter,stopAtIter,self.iterPerSec,subStepInfo))
    274 if t!=float('inf'):
--> 275 s=int(t); ms=int(t*1000)%1000; us=int(t*1000000)%1000; ns=int(t*1000000000)%1000
    276 self.virtTimeLabel.setText(u'%03ds%03dm%03dμ%03dn'%(s,ms,us,ns))
    277 else: self.virtTimeLabel.setText(u'[ ∞ ] ?!')

ValueError: cannot convert float NaN to integer
---------------------------------------------------------------------------------------------

>if you change thickness, try also to shift the walls, such that the actual wall remains unchanged.

Is your suggestion to make the wall movable? I try to set the thickness of the wall to 0.01, and then set the following four degrees of freedom to true(Previously set as non removable (false), which is the same as in my original script)
triax.wall_left_activated=True
triax.wall_right_activated=True
triax.wall_bottom_activated=True
triax.wall_top_activated=True
I made these two changes (wall thickness and degrees of freedom) and rerun the script.However, there is a problem I mentioned in [1], that is, the wall is deviation, and the particles fly out and disappear.I think the problem in [1] is related to excessive confining pressure and osmotic pressure, so I set the degree of freedom of the wall to false.

Thanks for help!

[1]https://answers.launchpad.net/yade/+question/701042

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

> The complete error prompt command line is as follows (completely copied from Yade):

thanks.
What is your yadedaily version? What it writes when you start it?

> Is your suggestion to make the wall movable?

no, sorry, I mean just to change the position of the walls.
If you have zero-thickness wall and then you change the thickness, but preserve position, the actual boundary is different in each case.
I meant something like (not tested):
###
t = ... # thickness
dPos = Vector3.Ones * 0.5 * t # shift from original position
walls=aabbWalls([mn-(dPos,mx+dPos],thickness=t,...)
###

Cheers
Jan

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#4

Hello,
Due to my personal reasons, I can't feed back the problem in time. I'm sorry.

>What is your yadedaily version? What it writes when you start it?

As described below:
Welcome to Yade 20220415-6437~b9e47eb~bionic1
Using python version: 3.6.9 (default, Mar 15 2022, 13:55:28)
[GCC 8.4.0]
TCP python prompt on localhost:9001, auth cookie `csedak'
XMLRPC info provider on http://localhost:21001
[[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]]

>no, sorry, I mean just to change the position of the walls.....

Yes,according to your suggestion, I have made the following modifications to the wall part:

t=0.01
dPos=Vector3.Ones*0.5*t
mn,mx=Vector3(0,0,0),Vector3(0.05,0.05,0.05)
walls=aabbWalls([(mn-dPos),(mx+dPos)],thickness=t,material='wall')
wallIds=O.bodies.append(walls)

The other parts are exactly the same as the code I provided before.Although there are no previous problems, new problems have emerged.
In previous simulations, the axial strain when the failure condition is reached is very small (0.03 or less),but this time, when the axial strain reaches 0.15 or more, it still does not reach my failure condition (the axial stress does not decrease)..

What should I do? Is the wall thickness set too large?

Thanks for help.

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#5

Hello,
I tried to set thickness to 0.0001 and 0.001. When it is set to 0.0001, an error is reported. When it is set to 0.001, the operation is successful, but the peak stress and strain are larger than expected...
What should I do to solve this problem..

Thanks for help!

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

Try to run without GUI:
yade -n script.py
Cheers
Jan

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#7

Hello,Jan
I tried using yadedaily - n script.py to run,but the result is as problematic as before.

In my previous simulation, I didn't set the wall thickness, that is to say, thickness is set to 0. With the increase of confining pressure and osmotic pressure, an error occurs, so you suggest that I set the wall thickness not to 0.
I guess if the larger peak stress and strain values I obtained are related to the setting of wall thickness?

Thanks again.

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

> the result is as problematic as before

please be more specific.
Is the problem "ValueError: cannot convert float NaN to integer" or the results dependency on wall thickness?

> I guess if the larger peak stress and strain values I obtained are related to the setting of wall thickness?

if wall thickness is the only change and the results change, then results and wall thickness are related :-)
But, intuitively, it should not be like that..

Cheers
Jan

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#9

Hi,Jan.
>please be more specific.

The problem "ValueError: cannot convert float NaN to integer" did not appear.I mean, the stress and strain values obtained are still too large.

>But, intuitively, it should not be like that..
Moreover, I found that the results I got have a certain relationship with the wall thickness. When the wall is set to 0.01 and 0.0005, the results are very different(For example, the peak strain values are about 0.15 and 0.03 respectively)...

I wonder if I move the wall the right way as follows:
####
t=0.0005
dPos=Vector3.Ones*0.5*t
walls=aabbWalls([(mn-dPos),(mx+dPos)],thickness=t,material='wall')
####

Thanks!

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

> The problem "ValueError: cannot convert float NaN to integer" did not appear

OK, then it would be better to emphasize it (e.g. my comment with running without GUI was for the error) and to open a new question for a new problem [1].

> I wonder if I move the wall the right way as follows:
> ####
> t=0.0005
> dPos=Vector3.Ones*0.5*t
> walls=aabbWalls([(mn-dPos),(mx+dPos)],thickness=t,material='wall')
> ####

sorry, the code takes thickness into account, so just use
###
walls=aabbWalls([(mn),(mx)],thickness=t,material='wall')
###
without any dPos

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask (currently down, but should be ok soon)

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#11

Hi,Jan
>sorry, the code takes thickness into account, so just use...

Yes.At first, I only changed the wall thickness, but the result is inconsistent with the previous rule. In #1 and #3, your suggestion is to change the wall position at the same time,If dPos is not used, the wall position has not changed...
I tried again to change thickness without moving the wall, but the results were the same as #0 described (larger stress and strain values)..
What should I do..

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

> What should I do..

I have no idea :-) depending on your needs.
If different results for different wall thicknesses bother you, try to investigate the results and what makes them different.
Start with careful comparison if really everything is the same for both cases and the only difference is wall thickness.
Then compare the results, final particle positions, energies etc.
You can try to investigate one-sphere-one-wall contact for various thicknesses if there is some influence.
...

Cheers
Jan

Revision history for this message
Ziyu Wang (ziyuwang1) said :
#13

I will try my best to solve this problem.
Thanks Jan again!