← Back to team overview

yade-users team mailing list archive

Re: [Question #690079]: local coordination number

 

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

    Status: Open => Answered

Jan Stránský proposed the following answer:
> sorry for my bad python programming skills.

no problem, everybody begins somehow :-)

> why the YADE didn't develop the class that can calculate the local
variables, for instance, local coordination number, local fabric tensor,
just like the measurement sphere function in PFC.

simply: nobody did need it / find it useful enough to make it a library
function

There are some, e.g. utils.bodyStressTensors..

Filtering "local" bodies can be done easily using predicates:
###
predicate = pack.inAlignedBox(...) # or other instance or combination of several predicates
localBodies = [b for b in O.bodies if predicate(b.state.pos,b.shape.radius)]
###

The same for interactions (e.g. based on their contactPoint):
###
predicate = pack.inAlignedBox(...)
localIntrs = [i for i in O.interactions if predicate(i.geom.contactPoint)]
###

Computing coordination number, fabric tensor and other quantities (for
each local body of from local interactions) is a few lines of code.

Averaging is just sum/amount..

So IMO the power of Python and already existing Yade functionality is
the reason why Yade does not have these functions "builtin"..

> recently, I'm working on this, but my programming skill is poor.

it this is meant that you would like to add those functions to Yade, of
course feel free. The fact that they are not present currently does not
mean they would not be useful currently or in the future.

As an example, subbox "pythonized" (e.g. not to lost in the for loops).
###
def subbox():
   ball_list1 = [b for b in O.bodies if 0< b.state.pos[2]<= 1 and isinstance(b.shape,Sphere)]
   bintrs = [b.intrs() for b in ball_list1]
   intrs = sum(len(ii) for ii in bintrs) # (?!?!?!?)
   zero_contact_p = len([ii for ii in bintrs if len(intrs) == 0])
   one_contact_p = len([ii for ii in bintrs if len(intrs) == 1])
   particle_number = len(ball_list1)
   mechanical_average_coord = ...
###

Have a look at the interaction computation. For each body, you count
some interactions twice (if both interaction bodies are contained in
ball_list1), but some not (those "from local to outside").

cheers
Jan

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