Posts about python
PlasmaPy v0.6.0 release!
I'll take the opportunity to cross-post this one from the PlasmaPy website; I'm pretty happy about how this went.
PlasmaPy 0.6.0
We're really happy to announce that we've just released PlasmaPy version 0.6.0!
SymPy for physics homework in 2020
I've been doing my university physics homework in SymPy and Jupyter for a little bit, and I thought I could share a little about the workflow I've developed for it. It might come useful for you.
Parsing SC2 replays for later analysis
I've realized I owe you an explanation on how to parse your own SC2 replays for the series of posts on Bayesian SC2 replay data analysis. Let's go through it here!
Learning my per-matchup MMR in Starcraft II through PyMC3
In this post we'll continue our SC2 replay research, started last time. You may want to go back to that and pick up on the terminology!
To recap: we used replay data from my SC2 games over 2019 to estimate a "true MMR" value and infer the size of per-game fluctuations. This time, we'll redo that analysis, except to get something more useful: we'll look at the three matchups I played and infer separate MMR values for each of those. Let's dig into it!
Bayesian modeling of StarCraft II ladder performance
I've been in a bit of a pickle recently. I really need to figure out Bayesian inference as practice for my masters' thesis. I've been wondering, what kind of cool project - hopefully with my own data - could I make?, I thought as I fired up StarCraft II in the evening, as I usually do to unwind nowadays. What kind of fun use of PyMC3, the neat Python library for probabilistic programming, could I showcase?, I wondered as I watched my ladder ratings fall from the distraction. What kind of useful knowledge could I try to acquire using it?, I thought, watching my game performance fluctuate over the course of months.
And then it hit me.
Dealing with backlogs
I have a backlog problem.
Like probably many of you in 2020, I suffer from having too much interesting content to read, watch, listen to or play through. I've been thinking about ways to tackle my gathering points, and I think I finally have something I'm willing to share that could be useful for you as well.
Better Numba calculation of inter-particle distance matrices
Recently, I've been looking for efficient ways to compute a distance matrix in Python. I'm deliberately trying to implement a naive n-body simulation so as to find optimized ways of calculating those, as practice. Let's do that using Numba.
Simple Binder usage with Sphinx-Gallery through Jupytext
It's been a busy week for PlasmaPy. I recently found out about Binder support in sphinx-gallery. The latter is a package that we use to turn python scripts with comments into Sphinx pages and Jupyter Notebooks. I figured adding that could be a nice fit for our existing example gallery .
However, I quickly realized that the system in place is a bit unwieldy. Binder takes a link to an existing GitHub repository and executes .ipynb
notebooks located there online. However, with sphinx-gallery, we don't have those notebooks in the repository - we have .py
files with comments. The currently recommended way of setting this up with sphinx-gallery is keeping your built documentation in another repository and hosting it via something along the lines of GitHub Pages rather than ReadTheDocs, which we are currently using.
I added the results of this investigation to sphinx-gallery's docs, but I didn't want to switch away from RTD, so I figured I'd go ahead and find another way. I think I've got something that works well enough now!
Trigger warning: later on during this post, there may be monkeypatching of sphinx_gallery internals. Beware.
Post mortem for my engineering thesis code, PythonPIC
I'm giving a presentation on this less-than-glorious subject on Friday, so I figured, hey, it might be a nice time to write a summary of what that old repository on my GitHub page is. In a single video:
Admittedly, this post is going to be rather personal - this messy little code was basically my life for a few hundreds of hours.
On the recent "On the Boris solver in Particle-in-cell simulations" paper
I recently came across a pretty cool paper by Zenitani and Umeda named "On the Boris solver in particle-in-cell simulation". There are many splendid descriptions of the Boris solver on the Internet, so while I would rather not duplicate them, here's a brief overview. In PIC simulations, the Boris solver (or pusher) is the usual algorithm of choice for moving and accelerating particles in given electric and magnetic fields.
You may wonder, since the equations of motion are ordinary differential equations, what's wrong with using the usual Runge-Kutta 4 solver? As it turns out, that one has a pretty major flaw. It has great accuracy for short term calculations, but over time your particle's motion will lose energy. This is a deal breaker for periodic motion, and simulations of, for example, plasma waves need to conserve that energy to provide accurate results.
Boris came up with his solver in the 1950's, and in a single sentence: the algorithm splits the acceleration via electric field into two parts and sticks a rotation about the magnetic field between them. This turns out to conserve energy and will probably come up again on this blog as I read more about symplexicity.