Billiard Balls and the Boltzmann Distribution in Python
HTML-код
- Опубликовано: 11 июл 2024
- By simulating collisions between billiard balls in a closed box, we can model the velocity distribution of air molecules in a gas, and recover the Boltzmann distribution of gas molecule speeds.
Code: github.com/lukepolson/youtube...
Discord Server:
/ discord Наука
As a recently retired ME, this channel is by far my favorite. Thank you so much for the awesome content and teaching style.
Awesome! You should definetly make a video about the Lattice Boltzmann Method for CFD :)
You need not take the sqrt of the distances between pairs, just compare the distance squared with the sum of the radii of pairs to detect collision and this would significantly improve the performance of the code. Great Job I've done this independently in Processing Java.👍
It's always good to get an example of empirical proof.
What a great video! I can’t wait to show this to my students next semester🤓
Amazing! Ive been waiting for a video like this thanks !
brilliant video. Best kind of physics lesson
Thank you! Fantastic video!
Amazing... Fantastic video!!! Thanks for sharing your knowledge.
Really great videos. Nice work, keep the good work up!
Awesome content, you're the best.
This video is awesome!. Thanks a lot!
You are such a clear explainer
Super video. I'm amazed what can be done with Python. My imagination is firing on all cylinders...
This is awesome. Thank you!
i´m Colombian from, my inglish is very poor, but i'm doing my best to understand you, and it's incredible, you're explanations are better than many spanish youtubers. Thanks a lot. Take care. Grettings.
PD: Can you make a video explaining the variable time fields? like Maxwell ecuations solutions, but as a radiant field not waves.
Super cool video, keep it up!
Great tutorial and video! Thank you very much
I was waiting for this video, man! Thank you!
You should also make a video and tell us how you actually learned python. Like what books did you use?
I didn't really use books to be honest! Most of my knowledge I gained from TAing two undergrad computational physics courses at two different universities, and then also trying/experimenting things with regards to my own research. Maybe I'll write a book one day, there seems to be a lack of information in this area!
@@MrPSolver Where can I preorder it? :)
@@MrPSolver you definetely should; man this is gold, an thank you for doing this
Indeed useful videos, the best of the best.
I would love it if you can have video on computational Physics in Python.
Nice video man 😀
Useful for undergraduate and graduate students
Продолжай в том же духе! Ты очень крутой
Excellent
insted of check de distance between ALL pairs, it's better before check if two ball overlapes they horizontal and vertical proyection. I borrowed this idea from another video, I acelerate my simulation very much
Hello Mr. P. Solver, good video. Could you tell where you got the physical theory of the Boltzmann distribution for this video? Thank you, greetings from LATAM. :)
Great video thanks. Would it be possible (although maybe of no interest) to calculate / consider Mean Free Path length between collisions?
You should make a video on fluid flow over an airfoil with the Lattice-Boltzmann method
In the comment below I tried to suggest that rebuilding this model using Sympy would be a great next step. It would be a natural extension of your video on Sympy and allow a natural path to generalizing the simulation model to 3D. Then, it would seem to begin to illustrate how Sympy would be foundational to building Digital Twins in a way that can be scaled.
Chad moment.
Amazing , interesting, I am going to try to repeat 😇
Very interesting project. I wrote the same program in processing (a simplified java language). It calculates 4000 molecules at a 100 FPS single core. I could not be bothered to write it multiple core. Python is really slow.
Try Taking Ensemble Average. Then the velocity distribution will look much smoother over time. I will post a video shortly over this.
I think that it would be interesting to repeat building this model but with symphonic.
sympy not symphonic
Hi! I have question. How to make this animation frame-unlimited? I mean you set numbers of moving frames then gif image return to begin of loop. I whant nonlooping time unlimited modeling of moving. Thank you, for video!
I think this would be faster to calculate the distances between two arrays:
all_pair_idx = np.array(list(combinations(range(NR_PARTICLES), 2)), dtype=np.int64)
all_pair_idx = np.ascontiguousarray(np.tranpose(all_pair_idx)) # This is constant
distances = np.square(r[:, all_pair_idx[0]] - r[:, all_pair_idx[1]]).sum(axis=0)
# take the square of the threshold
Also the approach taken here could have three particles colliding and two of them would have a mutual collision while the other would collide of one of the other two.
Why do you define a with 2/500**2, while the boltzmann constant is 1.38*10^-23 and what is the temperature and mass of the particle?
Do video about how to download python libraries for physics
Can anyone recommend a book to learn stuff like this. RUclips is far too difficult to collect a coherent curriculum from, and I would love to learn how to do simulations coupled with animations in python preferably. Thanks!
whats with the spinning pairs/triplets of particles that seem 'stuck' together?
This happens when particles overlap (distance < 2*radius) i.e. at initial configuration. If these particles cannot manage to get rid of the overlap within the next time step dt the simulation will handle the pair in the next step as comming from the opposite side colliding again with new velocity directions. This results in those particles dancing around each other until they are hit an separated by a third fast collision partner. The simulation is not checking whether particles move towards each oder or away from each oder in case of overlapping scenarios.
x1, x2 (vectors of particle positions, v1, v2 (vectors of particle velocities).
If norm(x2-x1) < 2*r particles are overlapping
In this case we need to check if (x2-x1)(v2-v1)
@@haraldhetzinger that clears it up thanks!
It was fun up until about minute 20, then it just got too complicated to follow. Discouraging for such a simple, straightforward simulation... Thank god for Vpython to save time on the arduousness required to create basic animations in regular Python.
if you ever do a doctorate, wil you change your username from Mr. P Solver to Dr. P Solver?
Good question. But seeing as I won't finish my doctorate for at least another 3.5 years, I may put this question on the backburner for now 😂
my advisor wants me to do pretty much the same... but in fortran i have no ideia how am i gonna do that
Hi bro.... it's Danush here, I,m having problem in the simulation of scalar fields by metropolis algorithm to get the kink solution...my code is not working... Can u help me on fixing it ????? If it so.... can I get your mail id??? So that I can sent you my code and you can find what mistake I have done???
0 dislikes and 255 likes. Sorry but I just can't like the video.