Skip to content

Python Toolkit

The scripts folder of exaDEM provides Python scripts for pre-processing and post-processing tasks: preparation of input data and analysis of simulation outputs.

Overview

The toolkit has two parts:

  • a core library (scripts/lib) with the generic functionalities: data structures (particles, interactions, geometries), input/output utilities and computational tools;
  • standalone scripts (scripts/pre_processing and scripts/post_processing) for specific use cases, such as configuration generation or result analysis, built on the library.

source scripts/setenv.sh sets the PYTHONPATH so that the library can be used without installation; the scripts can then be run from any location.

Pre-processing

tess2rockable.py

Converts a Neper .tess tessellation file into a complete Rockable input configuration:

  1. reads the Neper tessellation (.tess);
  2. extracts the vertices, faces, edges and polyhedra;
  3. computes the face normals, oriented toward the cell centers;
  4. erodes each cell (Minkowski erosion): each face plane is shifted by a distance gap, and the intersections of the shifted planes define the eroded polyhedron;
  5. computes the volume, the center of mass and the inertia tensor (Monte Carlo integration);
  6. writes the Rockable shape file (.shp) and configuration file (_sticked.conf).

Inputs: input.tess (Neper tessellation) and radius (float), the particle radius used for the erosion and the stick distance.

Outputs:

  • output.shp: Rockable geometry file (vertices, faces, edges, inertia, volume);
  • output_sticked.conf: full simulation configuration (particles, interaction laws, gravity and time step, stickVerticesInClusters parameter).
python tess2rockable.py input.tess 0.1 output.shp

Assumptions: cells are rigid polyhedra; the erosion avoids overlaps between particles; contacts follow Rockable's StickedLinks law; the stick distance is 4 × gap (with gap = 2 × radius).

Post-processing

compute_clusters_stresses_tensors.py

Computes, from time series of .xyz particle snapshots and interaction files:

  • the stress tensor of each cluster of particles;
  • the global wall forces;
  • the global deformation (strain) of the assembly.

For each step, it loads the snapshot and the interaction file, groups the particles by cluster, computes the stress tensor from the contact forces and positions (normalized by the cluster volume, or by the particle density), splits the contacts by position to sum the forces on the top/bottom/left/right boundaries, and computes the strain from the bounding box of the particles relative to the first step.

Inputs:

  • particle files *.xyz (position, velocity, cluster id, ...), written by:

    1
    2
    3
    4
    analyses:
    - timestep_file: "OutputRockableTestDir/ExaDEMAnalyses/dem_pos_vel_%09d.xyz"
    - write_xyz:
       fields: [ id, velocity, fx, fy, fz, vrot, arot, cluster, mass ]
    
  • interaction files InteractionOutputDir-*/InteractionOutputDir-*_0.txt, written with:

    global:
      analysis_interaction_dump_frequency: 500
    

Outputs:

  • clusters_stresses_tensor.txt: stress tensor per cluster,

    time cluster_id sxx syy szz sxy sxz syx syz szx szy
    
  • wall_forces.txt: global mechanical response,

    time delta_x delta_y delta_z eps_x eps_y eps_z Fx Fy Fz
    
python compute_clusters_stresses_tensors.py --dir . --density 2500
  • --dir: directory of the simulation outputs;
  • --density: particle density, used for the stress normalization.

Limitation

The script assumes a correct pairing between the .xyz and the interaction files.

Other scripts