← Back to team overview

yade-users team mailing list archive

Re: [Question #164424]: ForceRecorder

 

Question #164424 on Yade changed:
https://answers.launchpad.net/yade/+question/164424

    Status: Answered => Open

Daniela is still having a problem:
The spheres are defined here:

s=pack.SpherePack()
s.makeCloud((0,0,0),(6,6,3),rMean=.1)
s.toSimulation()

The body:

lFacets=ymport.gmsh('cylinder.mesh',shift=(0,3,4),scale=1.0,orientation=oriBody1,**kwMesh)
body1=O.bodies.append(lFacets)#generates facets from the mesh file    

And the engine:

O.engines=[
	ForceResetter(),
	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()],label='collider'),
	InteractionLoop(
		[Ig2_Sphere_Sphere_ScGeom6D(),Ig2_Facet_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],
		[Ip2_FrictMat_FrictMat_FrictPhys()],
		[Law2_ScGeom_FrictPhys_CundallStrack()],
	),
	GravityEngine(gravity=(0,0,-9.8)),
	NewtonIntegrator(damping=.1,label='newton'),    
       RotationEngine(ids=body1,angularVelocity=0,rotationAxis=[0,1,0],rotateAroundZero=1,zeroPoint=(0,3,3),label='rotEng'),
       ForceRecorder(ids=body1,totalForce=(0,0,0),label='fRec'),
      TorqueRecorder(ids=body1,label='tRec'),
      PyRunner(command='checkUnbalanced()',iterPeriod=3,label='checker'),
]

The functions:

def checkUnbalanced():
    if O.iter<500: return
    for b in O.bodies:
         if isinstance(b.shape,Sphere):b.shape.color=utils.scalarOnColorScale(b.state.vel.norm(),0,5)
    print utils.unbalancedForce()
    if utils.unbalancedForce()>0.1: return
    saveInitial()   

def saveInitial():
    rotEng.zeroPoint=(0,3,3)
    rotEng.angularVelocity=100   
    global idArray
    idArray=[]
    for b in O.bodies:
        if (b.id in body1): 
            idArray.append(b.id)
    checker.command='changeValues()'  
    checker.iterPeriod=1   

def changeValues(): 
    print O.iter
    for b_id in idArray:
        O.bodies[int(b_id)].state.pos += Vector3(0.1,0,0)               
        O.bodies[int(b_id)].state.vel = Vector3(0.,0,0)               
        O.bodies[int(b_id)].state.angVel = Vector3(0,0,0)                       
    checker.command='changeValues2()'  
    checker.realPeriod=0.001       

def changeValues2(): 
    for b_id in idArray:        
        O.bodies[int(b_id)].state.vel = Vector3(1,0,0)    
        print O.forces.f(int(b_id))
    rotEng.zeroPoint += (0.01,0,0)    
    print fRec.totalForce,tRec.totalTorque
    checker.command='changeValues()'          
    checker.realPeriod=0.009           

Thanks again.

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.