Coding 2021-03-27

By Max Woerner Chase

Today, I followed a whim, and dug up some of my academic code from nearly a decade ago. It's meant to evaluate differential equation solvers in a way that I assume other people have thought of, but I haven't looked very hard. Basically, if you're modeling a physical system, then that system will have associated invariants that you know about, but it is unlikely that the differential equation solver specifically optimizes for them. So, given a system and an invariant, you can compare different solvers by their error metrics with that invariant.

I don't have any particular usage in mind for this, I just think it's neat.

Today, I just took some basic notes on the modules I wrote about nine years ago. I can't use them directly because of... reasons.

Closer to nine years ago, I wrote the initial implementation in pure Python, no support from libraries like NumPy. Performance was... painful. For a project in another course, I rewrote the code to use NumPy, which took things all the way to "sort of reasonable", but was still a lot of Python code firing per simulation step, with some truly questionable attempts at optimization.

Now, that wrapped up in the summer of 2012. Back then, Python packaging was a serious chore, so I kind of... didn't do it for this. No real tests either. (I'm sure some people are still unhappy with the state of Python packaging today, and to them I say "MANIFEST.in". Whatever you think of it now, now I'm using Flit, and it's just a completely different experience from back then. Huh, this code also appears to just barely predate the first public release of the wheel package. Sounds about right.) And it was in Python 2, because Python 3.3 wasn't out yet, and I'm pretty sure the narrative didn't start shifting on Python 3 until Python 3.4.

So, what do I want now? Well, I'm curious about Numba, and I think this code is the best candidate I have, in terms of code I've written, for "let's rewrite this to use Numba and see how it works". I'll have to be pretty careful about this effort, because this is not a simple rewrite. Among other things, it appears that I was in the middle of a rewrite effort eight years ago that left the codebase in a slightly nonsensical state. So, I have to work to figure out the spirit of the code, rather than the letter, as it were. Plus, I'm not writing the same style of code I was nine years ago, so I've got some choices to unravel that I would not, and will not, make the same way today.

All of that is for tomorrow. Today, I took inventory of the modules, and next, I need to plan how the different bits of data and functions relate to each other. It's going to be a whole thing, and the best thing to do for now to handle it right, is to get some sleep.

Good night.