Best Environment/Programming Language for simple physics Simulations

Click For Summary

Discussion Overview

The discussion revolves around the best programming environment and language for simulating and visualizing simple physics concepts, particularly in classical mechanics. Participants explore various programming languages and libraries suitable for real-time animations and basic physics simulations.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants suggest Python as a strong option due to its ease of use and availability of tutorials and packages.
  • Others argue that R is primarily focused on statistics but can still be used for visualizing physics concepts, citing personal experiences with wave function visualization.
  • C++ is mentioned as verbose and less ideal for rapid prototyping, though some participants with a C++ background express familiarity with it.
  • Mathematica is recommended over Matlab for its superior symbolic capabilities, although some participants express a preference for free alternatives.
  • Physlets, a JavaScript-based library, is highlighted for its ease of use and extensive library of applets, although one participant expresses a personal bias against JavaScript.
  • Open Source Physics libraries in Java are recommended for their comprehensive examples and ease of transition for those familiar with C++.
  • Julia is proposed as a good alternative, combining a simple syntax with strong mathematical functionality, and is noted for its lack of associated costs compared to Matlab.
  • Octave is mentioned as a free alternative similar to Matlab.
  • Some participants express a preference for Jupyter notebooks and web-based IDEs for their usability.

Areas of Agreement / Disagreement

Participants generally agree that Python and Julia are strong candidates for the task, but there is no consensus on the best overall choice, as differing opinions on R, C++, and JavaScript persist.

Contextual Notes

Some limitations include the varying levels of familiarity with programming languages among participants and the subjective nature of preferences for specific IDEs and libraries.

Who May Find This Useful

Individuals interested in programming for physics simulations, educators looking for tools to visualize classical mechanics, and those exploring alternatives to commercial software like Matlab.

Jarfi
Messages
384
Reaction score
12
TL;DR
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?
 
Technology news on Phys.org
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   Reactions: vanhees71
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   Reactions: jedishrfu, vanhees71 and Dale
kuruman said:
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
 
Dale said:
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.
 
Jarfi said:
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.
 
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/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.
 
jedishrfu said:
and for folks looking for a good alternative to Matlab sans the IDE and associated costs of ownership, Julia is the one to choose.
JuliaPro (Juno IDE) is a free IDE for Julia, similar to RStudio:
https://juliacomputing.com/products/juliapro
 
  • #10
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
Octave ( similar to Matlab ) is wonderful... and free.
 
  • Like
Likes   Reactions: jedishrfu

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 54 ·
2
Replies
54
Views
5K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K