Revisiting an old project: KMCS in Python
This is a project that has followed me around for quite a few years.
During my PhD, I asked my student Chris Vos to make the first MATLAB implementation of a kinetic Monte Carlo simulation for thin-film growth. His work built on an earlier C# version developed by Bouwe Kuiper and became part of Chris' thesis.
The idea behind the model was closely connected to our Reflection High-Energy Electron Diffraction (RHEED) experiments. We had measured activation energies for the individual materials and their interfaces, and we wanted to know whether those experimentally obtained values could be used directly in a growth simulation. This was important because it meant that we did not have to fit the model until it produced the morphology we wanted to see.
The experiments worked well, the simulations reproduced the observed trends, and the work eventually became a publication:
The original MATLAB code did what we needed for the paper, but none of us were really programmers. It was slow, difficult to maintain, and limited to two deposited materials.
I always wanted to revisit it.
My goal was to translate the model to Python, both because Python is easier to access and because I wanted the code to be more general. In particular, I wanted to move beyond two-material systems, allow multiple layers with different parameters, and run several simulation conditions automatically instead of configuring every experiment by hand.
Then life happened.
Immediately after my PhD, I was hired as a senior scientist in the same research group. That was a great opportunity, but it also meant that the time available for my own unfinished projects became increasingly limited. I attempted the Python port several times, but without a dedicated block of time, I never reached a version that I was satisfied with.
The unfinished code kept returning to my mind every year.
More recently, AI-assisted coding tools became good enough to change what was possible for someone like me. They are, frankly, much better programmers than I am. With their help, I was finally able to work systematically through the old MATLAB implementation, translate it to Python, compare the behavior, organize the analysis tools, and finish the project that had been sitting on my list for far too long.
The result is a new public version of KMCS.
The Python version can now:
- Simulate individual materials as well as multi-material systems
- Handle more than two deposited materials
- Build successive layers with different compositions and growth parameters
- Run temperature and deposition-frequency sweeps automatically
- Save complete simulation states for later analysis
- Measure pillar number density
- Produce two-dimensional and three-dimensional visualizations
- Perform a Design of Experiments analysis across multiple simulation conditions
- Reproduce the temperature and frequency trends observed with the original MATLAB model
I also added a small example dataset, so the analysis and visualization tools can be explored without first running a full scientific-scale simulation.
The Design of Experiments functionality is probably my favorite addition. The original paper compared temperature and deposition frequency separately. The new workflow makes it possible to run a complete matrix of conditions and examine how the two parameters interact across a much larger experimental space.
I have also tried to make the repository honest about its limitations. This remains a kinetic model rather than a complete thermodynamic description of thin-film growth, as it was clearly brought to my attention during my PhD defense.
The code was ported and organized with substantial help from ChatGPT. I think it is worth being transparent about that. The scientific model, parameter choices, validation, and interpretation remain my responsibility, but AI assistance made it possible for me to finally convert years of ideas and incomplete attempts into a usable public project.
More than anything, I am happy that the model is no longer sitting unfinished on my computer. It is documented, reproducible, and available for other people to inspect, use, and hopefully extend.
The complete code, examples, figures, and instructions are available here: