23

How important is programming in physics?

I am studying physics at university and these first years there is actually no approach (as it is understandable) to what working in physics is like. Now, I know programming is actually important (I've read several posts in forums - even the one present here on Stack Exchange), but I actually was wondering: what 'hardware' is used in physics? Is it worth to learn to manage things like a Raspberry Pi-kind-of board? Or it just wouldn't be worth?

I don't know if that could be of use to answer this question, but I would be interested in condensed matter physics for the future.

Klopmint
  • 451
  • 4
  • 7

3 Answers3

35

As a computational physicist working in materials/condensed matter, I'm either highly biased or well-placed to comment on this.

Physics, in practice, is divided into three overlapping approaches: experimental, theoretical, and computational. (The highest impact research papers usually include a combined effort from all three.)

If you plan to go into computational research then you will have to do a fair amount of programming. However, I don't know anyone who has made use of Raspberry Pi's for physics research (that's not to say that no one has, but it's a novelty rather than something that is commonly done). In computational physics, your code will almost exclusively be executed either on standard desktop machines or supercomputers (where you use message-passing systems like MPI to exploit huge parallelism). Virtually all universities have their own supercomputers, but you may also be granted access to some larger national or even international supercomputers (such as ARCHER, Jaguar, and so on).

Graphics cards have also become quite popular for physics research in recent years due to the rise of CUDA, and most supercomputers now include several nodes packed with high-end graphics cards. So GPGPU programming is a nice skill to have but by no means a necessity.

It's also worth mentioning programming languages. Mainly for historical reasons, most academic code is actually written procedurally in Fortran (which is so archaic it still has functionality left over from the punch-card era). C/C++, Java, and Python are also widely used, along with the Unix shell (most academic machines run Linux). Those who do a lot of statistical modelling mostly use R or IDL. And those who are too lazy to do real programming - mostly mathematicians and engineers - use MATLAB or Mathematica (okay, I'm being a bit harsh on that one).

Let me finish by discussing theoretical and experimental physics. Virtually every theorist I know does much of their work on computers - programming code to numerically solve, or test something, for instance. And many of their 'theories' are aimed at advancing computational methodologies. A classic example of this is the Hohenberg-Kohn theorems which laid the foundation for density functional theory, and there are now many theorists trying to extend this by developing linear-scaling and real-space DFT.

It has also become common for experimentalists to program. Whether that be microcontrollers like Arduinos (as pointed out by Emilio Pisantry below), scripts to analyse data, or even employ standard simulation techniques to better understand their experimental observations.

lemon
  • 13,320
3

Hardware-wise, it would be likely that you would write code on a unix-like system that can distribute code to multiple cores and/or at least one GPU.

If this post relates to what hardware you should be using: I would suggest you set up a desktop PC with the following for a cheap but effective solution:

  • An NVIDIA graphics card - Only NVIDIA graphics cards can run CUDA and consequently work with the most GPU accelerated libraries. AMD / other brands can utilise OpenCL but you may have a situation where your course uses a library only compatible with CUDA. Currently, certain libraries such as python's theano only really support NVIDIA cards because of their CUDA dependency
  • A CPU with at least two cores - so you can play with multicore code
  • Ubuntu is a very simple and effective unix-like platform that will give you a good programming set up
  • Dual Boot Windows - mainly for ease when writing coursework

The above list allows you to play with GPU accelerated code, multi-core programming and lets you install libraries easily through ubuntu.

From my experience, you can often run intensive code on university supercomputers but you may not want to have to go through the effort of accessing them all the time / you might not have the ability to access them all the time.

As a recent physics graduate in the UK, I can say that every job I have been approached about or applied for, related to physics, has had a computational requirement.

As for languages, I have had to learn Python and C/C++ since graduating from a course that taught Fortran. I would recommend learning all three.

2

Much theoretical physics and simply "learning" physics doesn't require much programming. This is the case deep into many physics fields.

Experimental physics with data processing on the contrary does. Not programming directly, but a good knowledge of calculation and data/matrix-based software. These often require some programming skill, like Matlab or Maple from MathWorks.

When you get to the field of condensed matter physics and molecular structures etc., you will need some statistical physics methods and tools for numerical iteration and simulation, which are impossible without a CAS tool.

Of course, reaching the electronic world often requires some kind of circuit control. An Arduino or Raspberry Pi and whatever else they are all called are tools to control circuits. But often this is not for physics work, unless you step all the way into the digital area and away from the physics principles behind it.

Steeven
  • 53,191