Which programming language is best for computational physics and modeling?

In summary: Fortran announced, but that doesn't mean that it is not being used. It is a very versatile language and can be used for a variety of applications.
  • #1
Lavabug
866
37
I'm interested in picking up some programming skills specifically for modeling or solving physics-related things. Like solving PDE problems, like the heat or wave equation boundary problems I had in my PDE course. I'd also like to learn how to make animated simulations of the solution for example, or making simpler models of things like orbital motion, mechanical systems, etc. Fluid dynamics I find appealing too but I'm guessing that's way more advanced.

I have only rudimentary knowledge of some Mathematica (basic calculus, ODE's, integral transforms, plotting data(which I'm terrible at, so I always end up using Origin), not much else).

I'm led to believe Python is the way to go in my situation, is it a good choice for my purposes? The astrophysics grad students at my university use IDL a lot, would it be a better idea to get acquainted with that one instead?
 
Last edited:
Physics news on Phys.org
  • #2
A friend of mine is doing some theoretical astrophysics research this summer (mapping magnetic field lines to stars) and has been using MATLAB for most of the summer, he just now is starting to learn IDL.

Python is a good language to have under your belt but I would also recommend Fortran.
 
  • #3
That sounds interesting. I *think* MATLAB is what we'll have to use in our computational physics course next year(no syllabus yet).

I think I forgot to mention something crucial. I'm looking for something without a steep learning curve(I'm doing this for fun atm), so I'll be able to dive right into and do fun things like modeling systems of particles for example, or solving PDE's. I'm guessing that sort of rules out Fortran or other "hard" languages?

I've noticed there is a huge amount of books with titles like "mathematica/matlab for physics", can anyone recommend one that teaches by example and builds from the ground up?
 
  • #4
At our university they teach C in the Computational Physics classes. The book we used was C Programming: The Essentials for Scientists and Engineers by Brooks. It was pretty good with a lot of examples.
 
  • #5
Clever-Name said:
Python is a good language to have under your belt but I would also recommend Fortran.

I'd heard that Fortran was a dead language. Is it still useful for things like computational physics? I'm not really experienced in this area, though I would like to get into it in the next couple of years. Also, my understanding is that there are multiple versions of Fortran. Is there anyone in particulr that you'd recommend?
 
  • #6
I don't personally know Fortran but one of my professors uses Fortran in his research and he stands by it as the best programming language out there... Though that may just be his biased opinion.

It was developed and used by IBM in 1957, the latest release for the code was last year so I can only assume that means it's still in use and is still supported.

This is an interesting blurb from wikipedia:

Since Fortran has been in use for more than fifty years, there is a vast body of Fortran in daily use throughout the scientific and engineering communities. It is the primary language for some of the most intensive supercomputing tasks, such as weather and climate modeling, computational fluid dynamics, computational chemistry, computational economics, animal breeding, plant breeding and computational physics. Even today, half a century later, many of the floating-point benchmarks to gauge the performance of new computer processors are still written in Fortran (e.g., CFP2006, the floating-point component of the SPEC CPU2006 benchmarks).
 
  • #7
I believe Fortran and C(++) are the most used languages in computational physics research. At least in applications where good performance of the code is essential. The reason for this is mostly because the two languages have a wide variety of libraries available for scientific computing.

I don't know what level are you on (I'm suspecting undergrad), but I'd recommend learning Matlab first. If you're just interested in learning how to solve physics problems using computers, Matlab is definitely your choice. It's easy to learn and yet virtually all the physicists that I know use it in research too. Actually at least in my university they teach Matlab on mandatory undergrad courses so you might run into it too during your courses at some point.

As for the physics side, I'd recommend Thijssen's Computational Physics book. It assumes that you know the physics behind the problems though.

So: Matlab and Thijssen's Computational Physics. Python is also very popular, but if you're just starting out, I think Matlab is more essential tool to learn.
 
  • #8
Fortran is not as pretty or bells-and-whistles prone as C++, but it is BLINDLINGLY fast at numerical computations. It makes most languages look pokey in comparison if used correctly. If you need a million by a million matrix dealt with, you use Fortran. Got a ton of equations to integrate? Fortran. Massive fluid dynamics calculations? Fortran!

It is 'dead' in the sense that it has fallen out of favor with some areas of science but it is ubiquitous in stuff like astrophysics, high energy, and computational fluid dynamics. Python is better in terms of user-friendliness, C++ in terms of popularity. There's no use hand-wringing about which language. Pick one of those three and go at it!
 
  • #9
Looks like MATLAB it is... Found some free ebook on physical modeling with MATLAB for newbies to the language/program (author: Downey), looks good as a starting point!
 

1. What is computational physics?

Computational physics is a branch of physics that uses computer algorithms and numerical methods to solve complex problems and simulate physical systems. It involves using mathematical models and equations to simulate and analyze various physical phenomena.

2. How does computational physics differ from theoretical and experimental physics?

Computational physics differs from theoretical physics in that it involves using computers to solve equations and simulate physical systems, while theoretical physics focuses on developing mathematical descriptions and models to explain physical phenomena. Experimental physics involves conducting experiments to collect data and test theoretical predictions.

3. What are some common applications of computational physics?

Some common applications of computational physics include simulations of fluid dynamics, electromagnetism, quantum mechanics, and condensed matter physics. It is also used in astrophysics, climate modeling, and computational materials science.

4. What skills are necessary to get started in computational physics?

To get started in computational physics, it is important to have a strong background in mathematics, especially in calculus and linear algebra. Knowledge of programming languages, such as Python, C++, or Fortran, is also essential. Familiarity with numerical methods and algorithms is also helpful.

5. Are there any resources available for learning computational physics?

Yes, there are many resources available for learning computational physics. Online courses, textbooks, and tutorials can provide a good foundation in the subject. There are also software packages specifically designed for computational physics, such as MATLAB and Mathematica, which offer tutorials and examples. Additionally, joining a research group or attending conferences in the field can provide valuable hands-on experience and networking opportunities.

Similar threads

  • STEM Academic Advising
Replies
9
Views
1K
  • STEM Academic Advising
Replies
2
Views
1K
  • STEM Academic Advising
Replies
3
Views
942
  • STEM Academic Advising
Replies
10
Views
1K
  • STEM Academic Advising
Replies
24
Views
2K
  • STEM Academic Advising
Replies
4
Views
2K
  • STEM Academic Advising
Replies
4
Views
1K
Replies
37
Views
3K
  • STEM Academic Advising
Replies
16
Views
407
  • STEM Academic Advising
Replies
14
Views
1K
Back
Top