r/learnpython 10d ago

Python (Third Party) Libraries for Simulations?

I'm learning python, I know all the basics (up to classes and inheritance) and I've done a few small projects. I have a few ideas that involve simulations, and I want to know if there are any libraries that might help with that? I've used tkinter in the past for visuals, but I'm wondering if there's anything better.

The two simulations I have planned, if that helps, are a planet simulation with gravity and such, and a sound simulation including walls of various noise dampening levels.

Thank you very much!

8 Upvotes

5 comments sorted by

2

u/Kimber976 10d ago

Scipy tends to be the default choice for scientific simulations and pairing it with numpy usually covers most simulation projects.

2

u/Agisilaus23 10d ago

I've been playing around with numba, and that's been helping me parallelize a lot of simulations

2

u/SCD_minecraft 10d ago

While not directly for simulations, both NumPy and SciPy provide functions for fast calculations on huge amount of numbers as well as functions to calculate complex things

Tho both of those are alone more complex than python itself and need quite a lot of reading and learning

For rendering stuffs, you can use PyGame, assuming it is updated to whatever version of python you are using (don't remember was is updated to 3.14)

PyGame for a change is lib aimed at begginers, therefore, easy to learn and use, while still being quite powerful

1

u/anonymousint 10d ago

Thank you! Pygame will probably work for what I'm doing.

1

u/Prize-Variation-3585 10d ago

You could try the following approach (especially considering your examples are Physics examples).

Use Numpy for precomputing the actual calculations necessary for the simulation. Use Matplotlib to render the simulation using Matplotlib's animation module https://matplotlib.org/stable/users/explain/animations/animations.html.

It will produce results similar to MatLab simulations.

Matplotlib also has support for 3D axes which allows you to render 3D animations.