Best Environment/Programming Language for simple physics Simulations

  • #1
372
12

Summary:

What is the best package to make visualizations and simulations of classical physics equations and particles
Hello, I am looking for something to simulate/visualize simple particles and classical physics equations, preferably moving in real time

Requirements:
-Able to turn matrices/functions into geometric representations(visualize sphere, visualize a cylinder etc.)
-Can do the classic ball bouncing between walls animation
-Can do a charged ball moving in an electric field
-Can do a cannon-ball falling in gravity, possibly with air resistance
-Possibly make simple statics simulations, f.ex. using beams with a certain elastic modulus and breaking point.

I am not looking to do super advanced plasma physics, I just want to be able to the visualize classical physics and engineering mechanics. I want to have the power of programming though, but I don't want to have to program everything from the ground up, such as the graphics packages and so on.

What I had thought of
R
C++
Python
Matlab(i don't really want to pay though)

What do you think is best, what packages or libraries do you recommend?
 

Answers and Replies

  • #2
30,357
6,845
R is really focused on statistics.

C++ is pretty verbose, so you have to write a lot of lines of code to get something to work. Not ideal for prototyping.

Python would be good and will probably be the best option of those you have listed.

For paid software I would go with Mathematica over Matlab. The symbolics are much better and for physics that is important.
 
  • Like
Likes vanhees71
  • #3
kuruman
Science Advisor
Homework Helper
Insights Author
Gold Member
9,545
2,855
About 20 years ago I started using Physlets. I had quite a ball with them creating simulations to use in my lectures as illustrations, online quizzes etc. I am sure they have improved since then although I have not done anything since I retired four years ago. The language is Javascript so it's quite easy to pick up and use. I used them in both semesters of intro physics and in intermediate mechanics.

I highly recommend that you take a look. They have a wonderful library of applets that are easy to implement. Your imagination is the limit.

Disclaimer: I know nothing about the current version, 3E; I have used 2E.
 
  • Like
Likes jedishrfu, vanhees71 and Dale
  • #4
372
12
About 20 years ago I started using Physlets. I had quite a ball with them creating simulations to use in my lectures as illustrations, online quizzes etc. I am sure they have improved since then although I have not done anything since I retired four years ago. The language is Javascript so it's quite easy to pick up and use. I used them in both semesters of intro physics and in intermediate mechanics.

I highly recommend that you take a look. They have a wonderful library of applets that are easy to implement. Your imagination is the limit.

Disclaimer: I know nothing about the current version, 3E; I have used 2E.
I have to say coming from a C++ background I am not a huge fan of javascript, but thanks for the suggestion
 
  • #5
372
12
R is really focused on statistics.

C++ is pretty verbose, so you have to write a lot of lines of code to get something to work. Not ideal for prototyping.

Python would be good and will probably be the best option of those you have listed.

For paid software I would go with Mathematica over Matlab. The symbolics are much better and for physics that is important.
Yes I guess python is where it's at, I saw a lot of tutorials and packages that may be helpful

As for R, it is statistics oriented but you'd be surprised by how much it can do, I have believe it or not managed to visualize a wave function moving in time using a simple plot-refresh function.
 
  • #6
12,231
5,935
  • #7
A.T.
Science Advisor
10,744
2,324
Yes I guess python is where it's at, I saw a lot of tutorials and packages that may be helpful

As for R, it is statistics oriented but you'd be surprised by how much it can do, I have believe it or not managed to visualize a wave function moving in time using a simple plot-refresh function.
There is also Julia, which combines a simple python-like syntax, with the mathematical functionality of R/Matlab.
 
  • #8
12,231
5,935
Yes, Julia is a good choice although Open Source Physics has a book and extensive examples to follow and its closer to the OP's experience with C++.

I like Julia a lot, there's a book called Algorithms for Optimization that came out recently with all examples in Julia:

https://www.amazon.com/Algorithms-O...-Kochenderfer/dp/0262039427&tag=pfamazon01-20

and for folks looking for a good alternative to Matlab sans the IDE and associated costs of ownership, Julia is the one to choose.
 
  • #10
12,231
5,935
That is true but they are no match for the Matlab ide honed over many years of use.

Personally I like the Jupyter notebooks and console web based IDE.
 
  • #11
1
1
Octave ( similar to Matlab ) is wonderful... and free.
 
  • Like
Likes jedishrfu
Top