Presentation is loading. Please wait.

Presentation is loading. Please wait.

ESyS-Particle: An introduction to scripting DEM simulations D. Weatherley Earth Systems Science Computational Centre University of Queensland.

Similar presentations


Presentation on theme: "ESyS-Particle: An introduction to scripting DEM simulations D. Weatherley Earth Systems Science Computational Centre University of Queensland."— Presentation transcript:

1 ESyS-Particle: An introduction to scripting DEM simulations D. Weatherley Earth Systems Science Computational Centre University of Queensland

2 Outline ESyS-Particle features Why Python? Scripting a DEM simulation –Constructing a particle assembly –Specifying interactions –Simulation initialisation & execution –Real-time processing –Visualisation

3 Features Software: 3D C++ DEM engine Verlet list neighbour search algorithm Domain decomposition parallelism via MPI Python scripting interface Open source license

4 Features Particle Physics: Spheres & aggregates Contact models: –Linear elastic –Friction –Rotational bonds –Thermal diffusion Linear and tri-mesh walls Gravity, bulk viscosity

5 Why Python? An interpretive scripting language –Nice syntax and easy to learn Object-oriented design –Reusable packages and modules Extensive standard and 3 rd party modules – , web, XML, I/O, math etc. –Numarray, SciPy, matplotlib,... Existing C/C++/Fortran libraries can be “boosted” into Python easily

6 Scripting a simulation The esys.lsm Python package can be used in conjunction with existing Python modules for: Model initialisation geometrical configuration of particles configuration of inter-particle bonds Running simulations extract model data during simulation dynamic setting of model parameters, eg. creation of particles and bonds Visualisation Interactive visualisation for model debugging Batch option for large data sets and offline simulations

7 Constructing particle assemblies from esys.lsm.geometry import CubicBlock, HexagBlock from esys.lsm.util import Vec3 # Create a Face Centred Cubic (FCC) # rectangular block fcc = CubicBlock([20,15,10], radius=1.0) # Translate all particles in block fcc.translate(Vec3(10, 5, 10)) # Create a Hexagonal Centred Cubic (HCC) # rectangular block hcc = HexagBlock([40,30,20], radius=0.5) # Rotate all particles in block about centre # of block from math import pi hcc.rotate( Vec3(pi/2, pi/4, pi/8), hcc.getParticleBBox().getCentre() )

8 Particle assemblies (2) from esys.lsm.geometry import RandomBoxPacker from esys.lsm.util import Vec3, BoundingBox # Create randomly-sized spheres inside # a rectangular block rndPacker = \ RandomBoxPacker( minRadius = 0.1, maxRadius = 1.0, cubicPackRadius = 1.0, bBox = BoundingBox(Vec3(0,0,0), Vec3(20,15,10)), maxInsertFails = ) rndPacker.generate() rnd = rndPacker.getSimpleSphereCollection() Parameters for creating a random packing of SimpleSphere objects inside a box Generate the packing, uses a random- location with fit-to- neighbours algorithm Assign the collection of SimpleSphere objects

9 Particle Assemblies (3) Other assemblies: –Spherical aggregate grains –Cylinders via trimming of rectangular blocks Limitations: –Lacks some of the tricks of PFC Particle expansion Packing with specified porosity Random packing with specified radius size- distribution

10 Specifying Interactions Interaction Groups specified via IGprms objects Types of IGprms: –Body forces –Particle-particle –Particle-wall my_gravity = GravityPrms( name=”earth-gravity”, acceleration=Vec3(0,-9.81,0) ) wall_interaction = NRotElasticWallPrms( name = “SpringyWall”, wallName = “bottom”, normalK = # N/m ) particle_interactions = NRotElasticPrms( name = “SpringySpheres”, normalK = # N/m )

11 Specifying Interactions (2) Bonded particle interactions require a list of particle-pairs A NeighbourSearcher class provides a mechanism to compute particle-pair lists Bonded particle-wall interactions utilise particle “tags” to denote those particles to be bonded to walls bondGrp = \ sim.createInteractionGroup( NRotBondPrms( name = “SphereBonds”, normalK = , # N/m breakDistance = 10*r ) neighFinder = SimpleSphereNeighbours(maxDist=0.01*r) idPairs = neighFinder.getNeighbours(particles) bondGrp.createInteractions(idPairs)

12 Simulation Initialisation The LsmMpi class is a “container” for particle assemblies, walls, interactions etc. To initialise a simulation, we create an instance of the LsmMpi class and add the various features we need sim = LsmMpi(numWorkerProcesses=4, mpiDimList=[2,2,1]) sim.initVerletModel( particleType = “RotSphere”, gridSpacing = 2.5, verletDist = 0.5 ) domain = BoundingBox(Vec3(-20,-20,-20), Vec3(20, 20, 20)) sim.setSpatialDomain(domain) sim.createParticles(my_particle_collection) sim.createInteractionGroup(my_gravity) sim.createInteractionGroup(particle_int)...

13 Initialisation (2) & Execution sim.createWall( name = “bottom”, posn=Vec3(0,-20,0), normal=Vec3(0, 1, 0) ) sim.createInteractionGroup( NRotElasticWallPrms( name = “SpringyWall”, wallName = “bottom”, normalK = # newtons per meter )... sim.setTimeStepSize( ) sim.setNumTimeSteps(600000) sim.run()

14 Real-time processing A Runnable class permits users to script tasks to perform before/after each timestep Runnables: – control wall displacement/force (e.g. Servos) –Output data to disk –Move non-inertial particles/walls etc. Particle/Wall FieldSavers provide mechanism to store useful scalar/vector data at regular intervals –Particle savers include: Kinetic Energy Displ./Veloc. Field –Wall savers include: Force on wall Wall displacement

15 Real-time processing (2) from esys.lsm import * import cPickle as pickle class Saver(Runnable): def __init__(self, sim, interval): Runnable.__init__(self) self.sim = sim self.interval = interval self.count = 0 def run(self): if ((self.sim.getTimeStep() % self.interval) == 0): pList = self.sim.getParticleList() fName = “particleList%04d.pkl” % self.count pickle.dump(pList, file(fName, “w”)) self.count += 1. saver = Saver(sim=sim, interval=100) sim.addPostTimeStepRunnable(saver)

16 Visualisation Three Visualisation modules provide batch-mode visualisation for large/long runs Visualisation of: –Particle displacements –Velocity fields –Force chains –Other... Wrapping visualisation tasks as Runnables results in a library of re-usable visualisation tools pkg = povray sphereBlock = CubicBlock( [20,30,10], radius=0.25 ) scene = pkg.Scene() for ss in sphereBlock: ss.add( pkg.Sphere( ss.getCentre(), ss.getRadius() ) camera = scene.getCamera() camera.setLookAt( Vec3(10,15,5) ) camera.setPosn( Vec3(10,100,5) ) scene.render( offScreen=True, fileName="cubicBlock.png", size=[800,600] )

17 Resources ESyS-Particle Twiki pages: https://shake200.esscc.uq.edu.au/twiki/bin/view/ESSCC/ParticleSimulation EsyS-Particle API Documentation: 1.x.x/pythonapi/html/ HELP!


Download ppt "ESyS-Particle: An introduction to scripting DEM simulations D. Weatherley Earth Systems Science Computational Centre University of Queensland."

Similar presentations


Ads by Google