← Back to team overview

yade-users team mailing list archive

[Question #680725]: How to solve the issue 'a float is required' when using the mathfunction log

 

New question #680725 on Yade:
https://answers.launchpad.net/yade/+question/680725

Hello,I'm going to use yade to simulate biaxial drained compression experiment. But when it runs to script 46,strainy = -100.*math.log(O.cell.trsf[1]), the runner will report an error, a float is required.I'm very confused on the function log I use.
Could you please help me solve the error?
Thank you.

Here are my scripts and I use python 2.7.15.
from yade import pack,plot
import math

O.materials.append(FrictMat(young=6.e8,poisson=.8,frictionAngle=.0))

sp = pack.SpherePack()
size = .24
sp.makeCloud(minCorner=(0,0,.05),maxCorner=(size,size,.05),rMean=.005,rRelFuzz=.4,num=400,periodic=True,seed=1)
sp.toSimulation()
O.cell.hSize = Matrix3(size,0,0, 0,size,0, 0,0,.1)
print len(O.bodies)
for p in O.bodies:
   p.state.blockedDOFs = 'zXY'
   p.state.mass = 2650 * 0.1 * pi * p.shape.radius**2 # 0.1 = thickness of cylindrical particle
   inertia = 0.5 * p.state.mass * p.shape.radius**2
   p.state.inertia = (.5*inertia,.5*inertia,inertia)

O.dt = utils.PWaveTimeStep()
print O.dt

O.engines = [
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   PeriTriaxController(
      dynCell=True,
      goal=(-1.e5,-1.e5,0),
      stressMask=3,
      relStressTol=.001,
      maxUnbalanced=.001,
      maxStrainRate=(.5,.5,.0),
      doneHook='shear()',
      label='biax'
   ),
   NewtonIntegrator(damping=0.1),
   PyRunner(command='saveAddData()',iterPeriod=200)
]

def saveAddData():
   stress = utils.getStress()
   plot.addData( 
      strainy = -100.*math.log(O.cell.trsf[1]),
      stressy = -0.001*stress[1],
      p = -0.0005*(stress[0]+stress[1]),
      q = 0.0005*(stress[0]-stress[1])
   )
   plot.saveDataTxt('drained.txt',vars=('strainy','stressy','p','q'))

def shear():
   print getStress()
   print O.cell.hSize
   setContactFriction(0.5)
   O.cell.trsf=Matrix3.Identity
   biax.goal=(-1.e5,-1.e-1,0)
   biax.stressMask=1
   biax.relStressTol=0.01
   biax.maxUnbalanced=0.01
   biax.maxStrainRate=(0.01,0.01,0)
   O.engines=O.engines+[PyRunner(command='saveAddData()',iterPeriod=200)]
   O.pause()
   
O.run();O.wait()


The error it reports is as follows.
/usr/bin/yadedaily in <module>()

/usr/bin/yadedaily in saveAddData()
     44    stress = utils.getStress()
     45    plot.addData( 
---> 46       strainy = -100.*math.log(O.cell.trsf[1]),
     47       stressy = -0.001*stress[1],
     48       p = -0.0005*(stress[0]+stress[1]),

TypeError: a float is required

 

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.