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

    Status: Answered => Open

Fu zuoguang is still having a problem:
Dear Christian Jakob:
     Thanks a lot for your perfect suggestions last time. I have done some test 
following your 3 steps working and of course there are some questions in this 
in this process, which can be described as that:
    (1).Firstly, I wanna employ the "Pseudo Random Generation Method"(can be 
called PRGM here) to define the coordinates of the balance points of the clumps 
and the workflow is like this:
     1. Do mesh for the generation area. The generation area is set up as a 
rectangle and can be averagely divided into N copies on the X direction as well 
as N copies on the Y direction. So the number of all points in this generation 
area which can be picked out as the balance points of clumps is N*N.
     2. Determination of this points' coordinations. As you know, the 
generation area in YADE can be defined as 
"mn,mx=Vector3(,,),Vector3(,,)"(Z-direction can be assigned as the same value 
in my 2D simulation) and the balance points' coordinations can only sucessfully 
determined by this algorithm "(mx-mn)/N*random.randint(0,N)"
    (2).Secondly, generate only spheres with this points only for testing the 
feasibility of this method. All need to do is just only to input the number of 
shperes desired and,then make a "O.bodies.append". All the scripts for these 
first two steps working are as follow:

import random

i=int(input("i="))  # mesh numbers in one direction
N=int(input("N="))  # sphere numbers desired 

for i in range (1,i):
    mn,mx=Vector3(0,0,0),Vector3(0.07,0.07,0)
    p=(mx[0]-mn[0])/N*random.randint(0,N)
    q=(mx[1]-mn[1])/N*random.randint(0,N)
    O.bodies.append(sphere((p,q,0),radius=0.001))
      
    (3).There may be of course some overlaps occuring between the generated 
spheres and the next step working for me is nothing but detecting and removing 
the overlaps. But lack of experience in Python makes me only use the commands 
below:
    
    for b in O.bodies:
        if isinstance(b.shape,Sphere):
            if (abs(b.state.pos[0] - p) > radius):
                O.bodies.append(sphere((p,q,0),radius=radius))
            else:
                continue 

There must be some errors in this scripts for that YADE's core dumped without 
any error noticed.
What is wrong with it and how to correct it? Seeking your help!(all the scripts 
are that)

import random

i=int(input("i="))  # mesh numbers in one direction
N=int(input("N="))  # sphere numbers desired 
radius=0.001

for i in range (1,i):
    mn,mx=Vector3(0,0,0),Vector3(0.07,0.07,0)
    p=(mx[0]-mn[0])/N*random.randint(0,N)
    q=(mx[1]-mn[1])/N*random.randint(0,N)
    O.bodies.append(sphere((p,q,0),radius=radius))
    for b in O.bodies:
        if isinstance(b.shape,Sphere):
            if (abs(b.state.pos[0] - p) > radius):
                O.bodies.append(sphere((p,q,0),radius=radius))
            else:
                continue

-- 
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     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to