← Back to team overview

yade-users team mailing list archive

[Question #247021]: Question about i.phys.normalForce()

 

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

Dear all,
    I want to generate a sample with the average contact force lies in a range [Permit_Min_Force,Permit_Max_Force] throught the following code. However when I obtain the interaction force through "i.phys.normalForce()", some errors are listed during the calculations.
   Is the interaciton not update, after I change the radius of the spheres? if  so, how can I update the incteraction properties during the simulaiton?

Errors:

File "PackInPolygon_new.py", line 229, in Cal_Interface
    F1=i.phys.normalForce[1]
AttributeError: 'NoneType' object has no attribute 'normalForce'


The codes:

Permit_Min_Force=500.0
Permit_Max_Force=2.0*Permit_Min_Force

def Cal_Interface():
    Rf=0.0
    Contact_Num=0
    aa=dict(O.energy.items())
    for i in O.interactions:
            if not i.isReal:continue
            F0=i.phys.normalForce[0]
            F1=i.phys.normalForce[1]
            F2=i.phys.normalForce[1]
            f=sqrt(F0*F0+F1*F1+F2*F2)
          #  print('f:', f)
            Rf=Rf+f
            Contact_Num=Contact_Num+1
    return Rf, Contact_Num

while 1:
    Sign=0
    O.run(1000)   
    (Rf, Contact_Num)=Cal_Interface()
    print("Rf=", Rf,"Contact_Num=", Contact_Num)    
    if Contact_Num>0:
        Rf=Rf/Contact_Num
    else:
        Rf=0.0
    if Rf>Permit_Min_Force:
        Mult=0.99
    if Rf<Permit_Max_Force:
        Mult=1.01
    if Rf>Permit_Min_Force and Rf<Permit_Max_Force:
        Sign=1
        Mult=1
    for o in O.bodies: 
        if isinstance(o.shape,Sphere):
            R=o.shape.radius
            o.shape.radius=R*Mult
    print("Contact_Num=", Contact_Num,"Sign=", Sign)
    if Sign==1: 
        break

Thanks a lot!

Henry


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