yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #09317
Re: [Question #247021]: Question about i.phys.normalForce()
Question #247021 on Yade changed:
https://answers.launchpad.net/yade/+question/247021
Jan Stránský proposed the following answer:
Hi Henry,
in your example, it is really veeeeery strange, that
F0 = i.phys.normalForce[0]
works without ok, but
F1 = i.phys.normalForce[1]
gives this error..
So a little investigation :-)
- is this the first error you get during the running of the program?
- could you please create a minimal working example (deleting all
unnecessary code not related to your problem) and send it to us?
cheers
Jan
2014-04-15 10:31 GMT+02:00 Henry <question247021@xxxxxxxxxxxxxxxxxxxxx>:
> 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.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-users
> Post to : yade-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-users
> More help : https://help.launchpad.net/ListHelp
>
--
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.