change blockedDOFs of utils.box

Asked by Christian Jakob

I want to change state.blockedDOFs from 'xyzXYZ' to 'zXYZ'.
When I do this se3 and vel and some aabb entries changed to NaN in simulation inspection. When running the script error message occurs:

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)

/home/me/YADE/YADEgit20120420/lib/yade-2012-04-17.git-2847a08/py/yade/__init__.pyc in refreshEvent(self)
    190 def zxySlot(self): self.setViewAxes((0,-1,0),(1,0,0))
    191 def refreshEvent(self):
--> 192 self.refreshValues()
    193 self.activateControls()
    194 def deactivateControls(self):

/home/me/YADE/YADEgit20120420/lib/yade-2012-04-17.git-2847a08/py/yade/__init__.pyc in refreshValues(self)
    263 self.iterLabel.setText('#%ld / %ld, %.1f/s %s'%(O.iter,stopAtIter,self.iterPerSec,subStepInfo))
    264 if t!=float('inf'):
--> 265 s=int(t); ms=int(t*1000)%1000; us=int(t*1000000)%1000; ns=int(t*1000000000)%1000
    266 self.virtTimeLabel.setText(u'%03ds%03dm%03dμ%03dn'%(s,ms,us,ns))
    267 else: self.virtTimeLabel.setText(u'[ ∞ ] ?!')

ValueError: cannot convert float NaN to integer

How can I solve this problem?

Regards,

Christian

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
Bruno Chareyre
Solved:
Last query:
Last reply:
Revision history for this message
Anton Gladky (gladky-anton) said :
#1

Hi Christisan,

please, provide a working test-script.

Thanks.

Anton

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#2

#!/usr/bin/python
# -*- coding: utf-8 -*-

shear_modulus = 1e7
poisson_ratio = 0.15
young_modulus = 2*shear_modulus*(1+poisson_ratio)
friction_coeff = 2
angle = math.atan(friction_coeff)
rho_p = 2650 #density of particles

id_WallMat=O.materials.append(FrictMat(young=young_modulus,poisson=poisson_ratio,frictionAngle=angle))
id_SphereMat=O.materials.append(FrictMat(young=young_modulus,poisson=poisson_ratio,density=rho_p,frictionAngle=angle))

WallMat=O.materials[id_WallMat]
SphereMat=O.materials[id_SphereMat]

## create bodies:
O.bodies.append(utils.sphere([0,0,0], material=SphereMat, radius=.4))
id_box = O.bodies.append(utils.box((0,0,0),(1,1,0),material=WallMat))

# DEFINE MATERIALS AND ENGINES :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
  [Ip2_FrictMat_FrictMat_MindlinCapillaryPhys(label='ContactModel')],
  [Law2_ScGeom_MindlinPhys_Mindlin(neverErase=True,label='Mindlin')]
  ),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=1,timestepSafetyCoefficient=0.8, defaultDt=0.3*utils.PWaveTimeStep()),
 NewtonIntegrator(damping=0.7,label='integrator')
]

# END DEFINE MATERIALS AND ENGINES :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
O.run(1,True)

O.bodies[id_box].blockDOFs='zXYZ'

O.run(1,True)

Revision history for this message
Anton Gladky (gladky-anton) said :
#3

Your box is not actually a box, but square:

> id_box = O.bodies.append(utils.box((0,0,0),(1,1,0),material=WallMat))

I do not know, whether it is legal.

The second thing is that the center of your sphere is the in the
center of the square:

> O.bodies.append(utils.sphere([0,0,0], material=SphereMat, radius=.4))

It can cause problems.

I am not sure, whether blockDOFs works correctly with boxes.

Anton

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#4

>Your box is not actually a box, but square:
>> id_box = O.bodies.append(utils.box((0,0,0),(1,1,0),material=WallMat))

I know, thats why the problem occurs, the mass of the box is zero, so velocity and positions get NaN.

>> O.bodies.append(utils.sphere([0,0,0], material=SphereMat, radius=.4))

That doesnt matter, you can try with [10,10,10] if you want, result will be the same.

>I am not sure, whether blockDOFs works correctly with boxes.

It works only, when boxes have a mass. There should be a warning if mass = 0.0 and fixed = False ...

Revision history for this message
Best Bruno Chareyre (bruno-chareyre) said :
#5

>There should be a warning if mass = 0.0 and fixed = False ...

Mmmmh.. well... I'm more for a global warning in the documentation: "computing mass-less mass-spring systems will most probably fail".

There is nothing specificaly related to boxes.
Note that you can assign a mass to the box even if it's volume is zero.
box.state.mass=1

Revision history for this message
Bruno Chareyre (bruno-chareyre) said :
#6

More seriously: the problem with testing such trivial thing is that it would be tested for all bodies at each iteration. It would clearly represent a waste of cpu time.
Asserts are good for that, you could add one (if it's not already there). Then you have to run the debug mode to get the tests and warnings. In optimized build there are disabled, hence no waste of cpu.

Revision history for this message
Christian Jakob (jakob-ifgt) said :
#7

Thanks Chareyre, that solved my question.