Computational Physics (Chong)

Categories:

Recommended

An introductory course in computational physics for upper-level undergraduates. Topics covered include numerical linear algebra, eigenvalue problems, sparse matrix problems, numerical integration and initial-value problems, Fourier transforms, and Monte Carlo simulations. Programming examples are based on Scientific Python.

Scipy Tutorial

This is a tutorial for Scientific Python (Scipy), a scientific computing module for the Python programming language. There are a couple of other introductions to Scipy online, which are of excellent quality:

  • Scipy Tutorial: the official tutorial.
  • More Python Scientific Lecture Notes: a textbook which goes in-depth into using Scipy.

The present tutorial serves a slightly different purpose. It acts as a “walkthrough”, guiding you through each step of writing a basic but complete Scipy program. You can use this as the basis for a more complete exploration of Scipy, possibly using the above online resources.

I will assume no pre-existing knowledge of the Python programming language. Programming language constructs are explained as they appear. But if you need more an even more basic tutorial on Python, feel free to consult any of the dozens available online.

Sequential Data Structures

In the previous part of the tutorial, we worked through a simple example of a Scipy program which calculates the electric potential produced by a collection of charges in 1D. At the time, we did not explain much about the data structures that we were using to store numerical information (such as the values of the electric potential at various points). Let’s do that now. There are three common data structures that will be used in a Scipy program for scientific computing: arrays, lists, and tuples.

These structures store linear sequences of Python objects, similar to the concept of “vectors” in physics and mathematics. However, these three types of data structures all have slightly different properties, which you should be aware of.

A Model of Computing

A modern computer is a tremendously complex system, with many things to understand at the level of the hardware, the operating system, and the programming software (e.g. Python). It is helpful to consider a simplified computing model, which is basically a “cartoon” representation of a computer that omits the unimportant facts about how it operates, and focuses on the most important aspects of what a computer program does. The standard paradigm of computing that we use today is the Von Neumann architecture, which divides a computer into three interconnected units: processor, memory, and input/output devices. We’ll use this as the basis of our simplified model, with an emphasis on the processor and memory parts. A computer’s memory is essentially a chunk of space where we can store numbers. For now, we won’t concern ourselves with how the contents of memory are organized or formatted. The processor can read one or more numbers from any locations (or addresses) in memory, perform some basic operations on them, and then write the results into any other addresses. We also make three other important assumptions.

Category:

Attribution

“Computational Physics (Chong)” by Y. D. Chong, LibreTexts is licensed under CC BY-SA .

VP Flipbook Maker

Created a flipbook like this. This flipbook is made with Visual Paradigm Online. Try this free flipbook maker and create you own flipbook now!