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_processingandscripts/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:
- reads the Neper tessellation (
.tess); - extracts the vertices, faces, edges and polyhedra;
- computes the face normals, oriented toward the cell centers;
- 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; - computes the volume, the center of mass and the inertia tensor (Monte Carlo integration);
- 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,stickVerticesInClustersparameter).
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: -
interaction files
InteractionOutputDir-*/InteractionOutputDir-*_0.txt, written with:
Outputs:
-
clusters_stresses_tensor.txt: stress tensor per cluster, -
wall_forces.txt: global mechanical response,
--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¶
scripts/post_processing/interaction_summary.py: interaction statistics;scripts/post_processing/profile_pos_vel.py: average positions and velocities;scripts/post_processing/avg_stress.gnu: stress tensor plot;scripts/tools/restart_template.py: restart deck;scripts/tools/*: dump tools.