Friday, July 16, 2004

 
I've been busy all week. According to my advisor, I've managed to finish in just over a week the project he had expected me to spend most of the summer on. It seems he had rather low expectations of me going in. So, he has given me a set of two coupled differential equations to study, which also model the dynamics of a beam plasma undergoing periodic focusing in a magnetic lattice. The difference in this system of equations is that they take into account the effect that the electrically charged particles of the plasma have on each other. Plasmas behave in a complex manner, as I say, because they like to play with themselves.
 
Today, I managed to generalize my previous program to solve this new system of equations. While extending my Newton's method to do a root search in 4 dimensions (as opposed to the previous 2 dimensions) I found that I had to invert a four by four Jacobian matrix, which is considerably harder than inverting a two by two matrix. Since there are many numerical analysis libraries out there that do linear algebra, such as Lapack, I thought it'd be easy to simply call one of these libraries from my own program to do the matrix inversion for me. I ended up spending the next 5 hours beating my head against the monitor, trying to get my c++ program to link against the fortran libraries, until I finally gave up and wrote my own implementation of the row reduction algorithm, which took about 30 minutes. The penalty for being lazy.

And I finally took some time this evening to sit down and comment my horrendously unreadable program, like a good little code monkey. I think this must be the first time I've given any thought to what exactly I'm doing in my code, as I've found that I'm allocating almost twice as much memory than I need, and that several averaging algorithms that I've written could be speeded up by factors of 50 or so, with no sacrifice in accuracy. So, I've dutifully made comments to that effect in my code, and I will probably never get around to implementing the improvements, as D-bar has just opened, and I don't think I'll be doing any more work tonight.



<< Home