Archive for odeint

Elliptical Discussions

Posted in Cute Problems, Education, Maynooth, The Universe and Stuff with tags , , on April 7, 2022 by telescoper

It’s the ninth week of Semester 2 and I’m coming to the end of lectures and laboratory sessions for my Computational Physics module; for the remaining three weeks (plus the Easter vacation) the students in this class will be mainly concentrating on the mini-projects that form part of the assessment.

This afternoon, though we had a session on how to transform higher-order differential equations into sets of coupled first-order ODEs suitable for vectorization and consequent solution using standard techniques. The problem we focussed on today was the simple problem of orbital motion of a test particle under the gravitational force in plane-polar coordinates, which can be prepared for physical solution thusly:

This sort of thing reminds me of my undergraduate theory project at Cambridge, where I did a similar thing to solve the equations governing the action of a four-level laser, though that was in Fortran rather than Python. In my own solution I used Python’s off-the-shelf solver odeint.

I like the orbital motion problem a lot because it’s a bit more than a coding exercise: students have to think about how to choose initial data, how to test the their code and interpret the results. Even before that there’s the issue of what units to use; SI units are a bit daft for astronomical problems. For solar system calculations it makes sense to use Astronomical Units for distances and years for time; in such a system it’s easy to work out that GM is just 4π2, which avoids having to deal with ridiculously large or ridiculously small numbers.

Anyway, the fun thing about this lab was that once everyone had got their code working they could try setting initial data to get a circular orbit as a special case, explore how the shape of elliptical orbits depends on the input data, how to make an unbound orbit, and so on. It’s important to understand the output of a numerical calculation in terms of basic physical principles. All that led to a discussion in class of solar system exploration, transfer orbits, what would happen if the mass of the Sun suddenly changed, or if G was a function of time, and lots of other things.

I find sessions like this that encourage students to explore problems themselves very rewarding and I think they add a valuable extra dimension to standard teaching formats. I hope the projects that they’ll be doing from now on – involving topics in areas ranging from atomic physics, cosmology, particle physics and climate science, and done in groups – will provoke even more discussion of this type.