🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

How to get information of particles from the grid bin in edempy?

User: "Fatemeh Hosseini_22198"
Altair Community Member
Updated by Fatemeh Hosseini_22198

I use edempy for post processing. Until now, I used cylinder bin(Geometry bin) and get the position and Id of particle inside the bin.by this code:

Bin = CylinderBin([0,0.1, 0], [0, 0.2, 0], 0.01)
pIds = my_simulation_deck.timestep[t].particle[0].getIds()
pPos = my_simulation_deck.timestep[t].particle[0].getPositions()
ids_inside = Bin.getBinnedObjects(pIds,pPos)

But due to the huge number of particles, the process is too time-consuming. (I calculate the distance between all the particles) I think if I can define grid bins and do the calculation inside each grid  It will be more logical in CPU time.( I mean it is more logical to calculate the distance between particles and only their neighbors) 
I want to ask you, just like an above code, is there any way to get information in each grid?

Regards,
Fatemeh

Find more posts tagged with

Sort by:
1 - 4 of 41
    User: "RWood"
    Altair Employee
    Updated by RWood

    Hi,

    I'm not sure I totally understand. Once you have the ids_inside, what's stopping you from doing your calculation with only those values?

    Or do you mean that the initial populating of pIds and pPos is what is taking the time?

    Richard

    User: "Fatemeh Hosseini_22198"
    Altair Community Member
    OP
    Updated by Fatemeh Hosseini_22198

    Hi,

    I'm not sure I totally understand. Once you have the ids_inside, what's stopping you from doing your calculation with only those values?

    Or do you mean that the initial populating of pIds and pPos is what is taking the time?

    Richard

    Thanks for your answer Richard.
    Actually, I want to calculate distance between particles to detect agglomeration. My Geometry is a tube (L=20 cm, D=1cm). When I define a cylinder bin (L=1cm)there are a lot particles inside a bin. (almost 5000).
    It will be too time consuming to calculate the distance of one particle with 4999 other particles and it is not necessary. because I just need to calculate particle distance with its neighbors. 
    So I need  particles ID and position inside a small grid and calculate distance of particle inside this small grid (In this way I have almost 50 particles in each grid and calculating distance of one particle with 49 other particles is too fast) in this way, I save a lot of time. 

    Regards,
    Fatemeh

    User: "RWood"
    Altair Employee
    Updated by RWood

    Thanks for your answer Richard.
    Actually, I want to calculate distance between particles to detect agglomeration. My Geometry is a tube (L=20 cm, D=1cm). When I define a cylinder bin (L=1cm)there are a lot particles inside a bin. (almost 5000).
    It will be too time consuming to calculate the distance of one particle with 4999 other particles and it is not necessary. because I just need to calculate particle distance with its neighbors. 
    So I need  particles ID and position inside a small grid and calculate distance of particle inside this small grid (In this way I have almost 50 particles in each grid and calculating distance of one particle with 49 other particles is too fast) in this way, I save a lot of time. 

    Regards,
    Fatemeh

    In that case I'd create more bins, using each particle position as the centre. Something along the lines of:

    px = deck.timestep[123].particle[456].getXPositions(ids_inside[789])
    py = deck.timestep[123].particle[456].getYPositions(ids_inside[789])
    pz = deck.timestep[123].particle[456].getZPositions(ids_inside[789])

    Bin = Binning.BoxBin([px,py, pz], 987, 654, 321)

    where px,py,pz are the coords of the particle of interest.

    Richard

    User: "Renan"
    Altair Employee
    Updated by Renan

    Hi Fatemeh,

     

    You should check out the spatial algorithms and data structure from the scipy module. I think you'll find a lot of relevant information there. For your specific case I think you could use a kd tree structure but I'm not sure if it would make your calculations faster. An initial draft would look like this:

    from scipy import spatial  Bin = CylinderBin([0,0.1, 0], [0, 0.2, 0], 0.01) pIds = my_simulation_deck.timestep[t].particle[0].getIds() pPos = my_simulation_deck.timestep[t].particle[0].getPositions() pos_inside = Bin.getBinnedObjects(pPos,pPos)   tree = spatial.KDTree(pos_inside) #neighbor threshold: if distance is larger -> not neighbors neighbor_distance = 0.1    for pos in pos_inside:     neighbor_idx = tree.query_ball_point(pos, neighbor_distance)     neighbor_points = pos_inside[neighbor_idx]     complete_list = np.vstack((pos,neighbor_points))     distance_matrix = spatial.distance.cdist(complete_list,complete_list)     distance_to_particle = distance_matrix[0,1:]

    The distance_to_particle gives you a list of distances from each particle to its neighbors. From this point you can then decide for yourself what to do with list. Hope this helps you.

     

    Best regards,

    Renan