Modeling and animating the evolution of a cinder cone in Python
Numerically modeling of the evolution of a cinder cone where individual rock particles or "bombs" are launched from a central point with "random" trajectories from a central location and deposition/accumulation. Each process is explicit, eventually this process develops the shape of a classic cinder cone.
I wrote this as part of a graduate course and added comments throughout so it is easy to follow what is happening. Also included is an example of how to save images of the process and combine them into a gif animation.
Scientific and numerical modeling in Python is best accomplished with the Numpy library. This book (affiliate link) is a great resource if you are interested in improving your numerical methods in Python using Numpy, SciPy, and matplotlib.
Define physical parameters of bomb size and trajectories, determined from literature and trial and error.
Functions for creating, launching, and depositing bombs and defining the spatial domain.
Combining semi-random bomb creation, ejection, and deposition in a loop. This is also an example of how you can plot and save a series of images and then combine them to make an animation of the physical simulation.
Gather the saved images and use a natural (human) sorting to order them from start to finish then save as a gif animation with the imageio Python library.
And now for the fun part, click on the video below to watch the resulting animation of cinder cone evolution and bomb trajectories plotted every 5000 eruptions: