Extracting Collision Data Between Specific Particles and Geometry using EDEMpy

Jack11111
Jack11111 Altair Community Member

Dear EDEM Developers and Users,

I am currently working with EDEMpy to extract collision data between a specific type of particle and a particular imported CAD geometry. I am able to achieve this using the EDEM Windows interface, but I am having trouble replicating the same results using EDEMpy.

Current Process in EDEM Windows Interface:


In the EDEM Windows interface (as shown in the first figure below), I can extract collisions between particles of type 1 (e.g., "d=40cm") and geometry type 2 (e.g., "Excavation bucket") by selecting the relevant types in the collision settings. This successfully generates a .csv file with collision data, where, at time = 10s, no collisions are recorded (as shown in the second figure).

Issue in EDEMpy:

I am attempting to extract the same collision data programmatically using EDEMpy, but the result does not match what I see in the Windows interface. Below is the code I am using:

collisions = deck.timestep[step_at_10s].collision.surfGeom # Get collisions between particles and geometry
collisions_ids1 = collisions.getFirstIds() # Particle IDs in collision
collisions_ids2 = collisions.getSecondIds() # Geometry IDs in collision

At time = 10s, the collisions_ids1 and collisions_ids2 variables both contain 232 rows, indicating that multiple geometry collisions are being captured, not just the specific geometry I am interested in.


I suspect that this issue arises because the geometry ID is not specified, leading to collisions being exported between particles and multiple geometries rather than just the specific geometry (e.g., "Excavation bucket").

Request for Guidance:

How can I filter the collisions to only show those between the particles of type 1 and the specific geometry ("Excavation bucket") using EDEMpy?

Tagged:

Answers

  • Renan
    Renan
    Altair Employee

    Hi Jack,

    Please use the following code to find all collisions between particle 1 and a specified geometry.

    from edempy import Deck
    import numpy as np
    
    deck_name = "input.dem"
    deck = Deck(deck_name)
    
    tstep = 1
    particle1_name = "New Particle 1"
    geometry_name = "New Section 2"
    
    # Get particle ids
    particle1_ids = deck.timestep[tstep].particle[particle1_name].getIds()
    
    # Get the ids of the triangles in the geometry
    geometry_tri_ids = deck.timestep[tstep].geometry[geometry_name].getTriangleIds()
    
    # Get collision data
    collisions = deck.timestep[tstep].collision.surfGeom
    
    # Get the ids of the elements involved in the collisions
    collisions_ids1 = collisions.getFirstIds() 
    collisions_ids2 = collisions.getSecondIds() 
    
    # For particle-geometry collisions, the particle is always the first element
    # and the geometry is always the second element
    
    # Find all collisions where New Particle 1 is involved
    flag1 = np.isin(collisions_ids1, particle1_ids)
    
    # Find all collisions where New Section 2 is involved
    flag2 = np.isin(collisions_ids2, geometry_tri_ids)
    
    # Find all collisions where New Particle 1 and New Section 2 both are involved
    collision_indices = np.where(flag1 & flag2)[0]
    

    Best regards,

    Renan

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.