Physics 22 Reading List for Week 1

This week's assignment is dense on the details, so I'll provide only a few hints and some other information here.

Plotting

Question 3 in the assignment asks you to produce a convergence plot. In a convergence plot, the axes should be chosen so that the lines are straight. As a general rule, the vertical axis is logarithmic, to show convergence over many orders of magnitude. For more convoluted algorithms, the horizontal axis may also be a log scale, and the vertical scale might be a log(log()) scale. In my opinion, it is easiest to modify the data to be plotted within python to the correct numerical values, but matplotlib et al. also have log plotting options.

Classes

This week's assignment asks you to implement a basic class called 'Vector'. You can also call it 'MyVector', if you would like to distinguish it from the vector class supplied in numpy or scipy. Ordinarily, one would simply use a ready-made class off the shelf for vector, tensor, etc operations, pre-written, debugged, documented, and so on. However, this course will ensure that you know how to implement a basic class in python. Therefore, you will write a script called myvector.py or similar, which will 'overload' the usual numerical operations for vector type objects, so that they 'do the right thing'. An example is given in the assignment, so generalising that to other operations is the way to go. How you implement them is up to you, though the example given uses the lambda calculus, which should be familiar to CS students. It is wise to test the operations of the class to check that it does what you think it does, especially since you'll be using it a lot this term. Professional software engineers will often write an automated test BEFORE they implement the code, to check that it all works properly.

Coding karma

Coding, like science, is almost always a collaborative exercise. Since someone else will have to eventually read and maintain your code, it is essential to provide useful comments in the code (explaining what is going on and WHY), sensible/intuitive variable names, and documentation. Many programming languages now support automatically compiled documentation, generally derived from a text block in the header file or similar. In python, it is done with triple inverted commas ”””. Also, chances are I'll have to look at your code at least once in order to help you find or fix some problem, and if it is nice to read, it makes my job a LOT easier.

Numerical integrators

This assignment talks about the explicit RK4 integrator, which is one of the most widely used numerical integrators in existence. This is because it's pretty stable, extremely versatile, simple to implement, and widely known. There are, however, and infinite variety of other integrators of all orders available! Explicit integrators include the RK family (of which explicit euler is a version), Adams Bashforth methods that don't interpolate between time slices, and some types of symplectic integrators. There are also implicit time steppers, which require the solving of a linear system of equations in order to find the next time step. To counter this additional computational complexity, they offer large timesteps and often unconditional convergence! Worth particular mention are symplectic integrators, which are invaluable for orbital dynamics problems, as they explicitly conserve integral quantities (such as energy and angular momentum) of the system. Despite this they, too, have their drawbacks. Ultimately it comes down to picking the right tool for the job. Wikipedia has a summary of various numerical integrators.

 
22.1.txt · Last modified: 2013/01/07 16:17 by chandmer
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki