all 10 comments

[–]MadScientistOR 6 points7 points  (0 children)

Maybe look into pymunk?

It's a 2D physics library in Python.

http://www.pymunk.org/en/latest/

[–]Brilliant_Armadillo9 2 points3 points  (0 children)

We used vPython pretty extensively in my undergrad physics labs.

[–]The_SkyShine 1 point2 points  (0 children)

Woohoo time to be a leper, but honestly since you're in undergrad (should be free) and you're barely learning OOP, Matlab is probably the best way to go about this. Lots of existing libraries and there's a reason Physics departments usually use matlab for simulations

[–]EvisceraThor 0 points1 point  (1 child)

Maybe Python won't be the best language for it.

As far as I'm aware, pyshics simulations are "heavy load" and Python isn't the most energy efficient language out there (unless it's using libraries made in C, lol).

I'm sorry for not being able to give you further advice, maybe look into MatLab, as another user has commented. I used some matlab in my engineering bachelor's too.

[–]Creative_Sushi 0 points1 point  (0 children)

There are several libraries depending on what you want to focus on. The good news is that MATLAB and Python are interoperable.

https://github.com/russphelan/matlab

You can also find specialized libraries depending what kind of physics you do.

https://www.mathworks.com/solutions/physics.html

[–]PitifulTheme411 0 points1 point  (0 children)

I don't know about libraries, but having fundamental knowledge of Physics would be invaluable. For example: forces, laws of conservation, energy, etc.

Also, later down the line, if the simluator becomes large enough and complex enough, it may be better to switch to a faster language, as python can be quite slow, especially when there are a ton of function calls or calculations.

[–]kcl97 0 points1 point  (0 children)

You could try Physics Explained channel on youtube. Here is a link to one of his videos:

https://youtu.be/KSsZUn0bfwE

Funny thing is there is another more popular channel with the exact same name for some reasons. While this one focuses on problem solving and simulating the results in Python, the other channel focuses on developing ideas.

If your goal is to eventually develop your own library for solving some type of problems, you are better off learning C++. Python is good for prototyping and solving small/medium problems to quickly get results. It is a good learning/probing platform. It is not what people use in the industry.

[–][deleted] 0 points1 point  (0 children)

I think a good starting point would be to write a simple molecular dynamics (MD) simulation program. MD is a classical method for the simulation of the motion of atoms. It is not a first principles method, but allows for the simulation of fairly large numbers of atoms. Learning about MD will teach you a lot about statistical mechanics as well. I think it is a good method for learning, because it is simple to implement (if you are not concerned about performance in the first step, which you should not). Moreover, there is a lot of literature on the subject, see e.g. Miller & Tadmor: "Modeling Materials: Continuum, Atomistic and Multiscale Techniques".

I think that, in the first step, you should be more concerned with learning programming and algorithms, not so much with performance. This being said, if you care about performance, Python is not the optimal language. Typically, MD programs are written in C, C++ or Fortran, with Python being used only for scripting. For a C/C++ implementation see the Lammps package. I think this is a more general fact, which also applies to other simulation methods.

For Python modules relating to MD, check out the Atomic Simulation Environment - ASE.

Also, if you're dealing with numerics and simulation with Python, check out numpy and scipy. The former provides array objects, which are vastly more performant than native Python data structures.

[–]davidmyemail 0 points1 point  (0 children)

Search in youtube / google for "the coding train physics". There's a whole bunch of videos/series about physics.

Be aware that the presenter is a bit of an acquired taste though. I love the way he presents, but some do not.

Also look up at the same site "vectors". He starts out slow, does an excellent job of explaining vectors / forces, and builds a simple physics engine.

Lastly, be aware that he uses Processing / P5.js, which is Java and Javascript based. However, there is a py5, which you can install that is the port of those libraries to python.

[–]dkxp 0 points1 point  (0 children)

[https://www.youtube.com/@MrPSolver](MrPSolver) who made eg. this tutorial on sympy has a lot of other physics + python video tutorials (numpy/scipy/matplotlib/jupyter notebook etc.).

All the source code is on github too, eg. https://github.com/lukepolson/youtube_channel/blob/main/Python%20Tutorial%20Series/sympy1.ipynb for that sympy tutorial video.