Simulating physics on a computer
In this part of your summer school you will learn how to write computer code to simulate physical situations. This is a very important aspect of modern physical sciences and just about every aspect of physics makes considerable use of computational techniques.
Aims and Objectives
During these sessions you will learn the basics of a modern program language (Python) and you will then use them to write simulations of the experiments that you are carrying out in the laboratory parts of the of your summer school. In a few days we cannot hope to give you a comprehensive course in Python. Instead our hope is that you will begin to acquire skills which will allow you to simulate a wide range of physical situations and that you will be able to develop them further after the summer school. In this way we hope that this becomes a lifelong skill. There are many good online course that can help you to extend your knowledge after the summer school.
Why Python?
We have chosen python for a number of reasons:
- It is a widely used scientific programming language.
- It is a scripting language and is much easier to use than most compiled languages. This means that you can develop your computational models much more rapidly.
- It has been interfaced to many very powerful (compiled) mathematical computing libraries which means that you simulate very mathematically complex situations very easily. These can be imported as modules. You will use the very powerful NumPy, SciPy and matplotlib (through PyLab) packages.
- In fact there are modules to do just about anything in Python (at least the folks at xkcd think so).
- Python is free and available for most platforms (including Windows, Mac and Linux). The vast majority of Python modules are also free. This means that you can install it at home and continue to use it after the summer school.
There are many ways to install python on your computers. The distribution that you will be using for this summer school is Anaconda which is freely available for Windows, Mac and Linux. You can download Anaconda for free from the Anaconda web site. If you wish to download Python and the individual packages separately, then you can do. The packages that you will be using are SciPy, NumPy and matplotlib (also we would suggest IPython).
Python Anywhere
pythonanywhere provides (for free, registration required) a Python environment (including SciPy and NumPy) within a web browser.
Learning Environment
Python programs (often called scripts) are just plain text files and they can be edited with any plain text editor (such as notepad). These can then be run by the Python interpretor. However, we have decided to use Jupyter notebooks for this course. These are very useful as they allow you to enter code, run it, save the output and make notes on it all in one place. This way we hope that you will be able to take away a record of what you have learnt that will be useful in the future.
There are many free distributions of Python and we happen to have chosen Anaconda which is free to download and available for Windows, Macs and Linux.
You will be given a 16GB memory stick so that you can take your work away with you. This is also plenty big enough if you want to download a copy of Anaconda to take away with you.
Now download the zip file containing the course material on to your memory stick. Then right-click on the file and select "Extract All". This will extract all the files into a directory. Also, download and extract the Jupyter startup script.