3D viewer for granular material
Use pip install name to install needed package
General :
sys
numpy
PyGLM
Graphic :
pygame
pyOpenGL
-
Import function and class :
import gl3Dview_class as gl3Dc import gl3Dview_function as gl3Df
-
Create class object :
data = gl3Dc.data_class()
-
Import data :
- look data Importation part for more details
data.get_time( dt=dt, dt_index=dt_index) data.get_particles(state_types=state_types, states=states, radius=radius, positions=positions, orientations=orientations) data.get_interactions(intrsPid=intrsPid, intrsNorm=intrsNorm, intrsNF=intrsNF, intrsSF=intrsSF)
-
Call
gl3Df.main(data)to display with default setting.
You needed to import your data in the used classes, by following this schem.
int[index_1][index_2][etc] represent array with type int and index in order [index_1][index_2].
-
Create data object :
data_class_name = gl3Dc.data_class()
-
Import time data :
data_class_name.get_time(dt = time_step, #float time_index = int[time_index])
-
Import particles data :
states_typeis the list name of the differents state.statesis the differents state for each particles for each time step, default state is''.radiusis the particles radius for ech particles.positionsis the position of each particles for each time step.orientationis the orientation each particles for each time step, it must be like[angle, x, y, z]where theangleis in degree andx, y, zrepresent the rotation axis.
Unsed for the moment :
▫️velocitiesis the velocities of each particles at each time step.
▫️rotation_velocitiesis the rotation velocities of each particles at each time step.
▫️forcesis the forces of each particles at each time step.
▫️torquesis the torques of each particles at each time step.It's better to adimentionalize particle size (radius) and position by the mean particle size.
data_class_name.get_particles(states_type = str[state_index], states = str[time_index][particle_index], radius = float[particle_index], positions = float[time_index][particle_index][coord_index], orientations = float[time_index][particle_index][angle:axis_coord_index],) #velocities = float[time_index][particle_index][coord_index], #rotation_velocities = float[time_index][particle_index][coord_index], #forces = float[time_index][particle_index][coord_index], #torques = float[time_index][particle_index][coord_index])
-
Import interactions data :
inrtsPidis the index of particles involve in this interaction.intrsNormis the norm of the interction (unit vector in between the two particles).intrsNFis the normal force of the interaction.intrsSFis the shear force of teh interaction.
data_class_name.get_interactions(intrsPid = int[time_index][interactions_index][p1_index:p2_index], intrsNorm = float[time_index][interactions_index][coord_index], intrsNF = float[time_index][interactions_index][coord_index], intrsSF = float[time_index][interactions_index][coord_index],)
Call gl3Df.main(data_class_name) to display with default setting.
-
Display setting :
winSizeis the window size in pixels.cam_targetis the point where the view is pointing at the begining.
gl3Df.main(data_class_name, winSize = [xSize, ySize], #int cam_target = [0, 0, 0]) #float
-
Interaction setting :
nfLogNormset a log scale for normal force.nfSizeset the minimum size first and maximum size second for normal force.shearForceDisplayallow to display shear interactions.sfLogNormset a log scale for shear force.sfSizeset the minimum size first and maximum size second for shear force.
gl3Df.main(data_class_name, nfLogNorm = False, #bool nfSize = [0.05, 0.5], #float shearForceDisplay = False, #bool sfLogNorm = False, #bool sfSize = [0.1, 0.5],) #float
-
Control Setting :
rotButtonset the rotation button of the mouse.dragButtonset the drag button of the mouse.transFactorset the transaltion speed (drag).zoomFactorset the zoom speed.rotFactorset the rotation speed.posTimeKeyset the button to get to +1 time step.negTimeKeyset the button to get to -1 time step.restartTimeKeyset the button to get to 0 time step.
gl3Df.main(data_class_name, rotButton = 0, #int dragButton = 2, #int transFactor = 0.01, #float zoomFactor = 2, #float rotFactor = 0.005, #float posTimeKey = pygame.K_d, #100 #int negTimeKey = pygame.K_q, #113 #int restartTimeKey = pygame.K_s, #115 #int )
States reffer to the different textures you want to apply to particles. By default the first texture (0.png) is applyied, then state[0] is for the second texture (1.png), etc...
By default 3 textures are aviable (0.png, 1.png, 2.png). More texture can be add in ./gl3Dview/texture, the original texture template is avaible in ./gl3Dview/texture/texture.xcf with layering to modifiy back ground color.
Note that the gl3Dc.texture class will load every file with .png extention present in ./gl3Dview/texture and sort it by alphabetic order.
Be carefull loading heavy texture will result of a lack of fluidity.

