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
  • НаукаНаука

Комментарии • 56

  • @nmgreg11
    @nmgreg11 2 года назад +14

    As a recently retired ME, this channel is by far my favorite. Thank you so much for the awesome content and teaching style.

  • @blackguardian89
    @blackguardian89 2 года назад +14

    Awesome! You should definetly make a video about the Lattice Boltzmann Method for CFD :)

  • @syedabuthahirkaz
    @syedabuthahirkaz Год назад +3

    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.👍

  • @gothicknight5538
    @gothicknight5538 2 года назад +3

    It's always good to get an example of empirical proof.

  • @markushaysnielsen4885
    @markushaysnielsen4885 2 года назад +7

    What a great video! I can’t wait to show this to my students next semester🤓

  • @Louis-ml1zr
    @Louis-ml1zr 2 года назад +3

    Amazing! Ive been waiting for a video like this thanks !

  • @declanwk1
    @declanwk1 2 года назад +1

    brilliant video. Best kind of physics lesson

  • @mikekertser5384
    @mikekertser5384 2 года назад +4

    Thank you! Fantastic video!

  • @LearningWorldChatGPT
    @LearningWorldChatGPT 2 года назад

    Amazing... Fantastic video!!! Thanks for sharing your knowledge.

  • @mohdtauheed5242
    @mohdtauheed5242 5 месяцев назад

    Really great videos. Nice work, keep the good work up!

  • @danv8718
    @danv8718 2 года назад +4

    Awesome content, you're the best.

  • @jakobkrygersrensen74
    @jakobkrygersrensen74 2 года назад +1

    This video is awesome!. Thanks a lot!

  • @Sam-tg4ii
    @Sam-tg4ii 11 месяцев назад

    You are such a clear explainer

  • @charliearmour1628
    @charliearmour1628 2 года назад +1

    Super video. I'm amazed what can be done with Python. My imagination is firing on all cylinders...

  • @hericklenin
    @hericklenin 2 года назад +1

    This is awesome. Thank you!

  • @juanmanuelriosfranco3711
    @juanmanuelriosfranco3711 Год назад +4

    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.

  • @wenhanzhou5826
    @wenhanzhou5826 2 года назад +1

    Super cool video, keep it up!

  • @amrhssnn
    @amrhssnn 11 месяцев назад

    Great tutorial and video! Thank you very much

  • @Science4Ever
    @Science4Ever 2 года назад +4

    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?

    • @MrPSolver
      @MrPSolver  2 года назад +5

      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!

    • @Science4Ever
      @Science4Ever 2 года назад +4

      @@MrPSolver Where can I preorder it? :)

    • @a.andacaydn9736
      @a.andacaydn9736 2 года назад +2

      @@MrPSolver you definetely should; man this is gold, an thank you for doing this

  • @derekwang5982
    @derekwang5982 Год назад

    Indeed useful videos, the best of the best.

  • @HizBela_16
    @HizBela_16 2 года назад +2

    I would love it if you can have video on computational Physics in Python.

  • @HypnosisBear
    @HypnosisBear 2 года назад +1

    Nice video man 😀

  • @udomtipparach4894
    @udomtipparach4894 2 года назад

    Useful for undergraduate and graduate students

  • @novampiresremaininromania
    @novampiresremaininromania 2 года назад +2

    Продолжай в том же духе! Ты очень крутой

  • @KrishanuSengupta-ki8jo
    @KrishanuSengupta-ki8jo 24 дня назад

    Excellent

  • @relojsaturno
    @relojsaturno 8 месяцев назад +1

    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

  • @canelsproyect8824
    @canelsproyect8824 2 года назад +1

    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. :)

  • @cerioscha
    @cerioscha Год назад

    Great video thanks. Would it be possible (although maybe of no interest) to calculate / consider Mean Free Path length between collisions?

  • @hugoallen7175
    @hugoallen7175 Год назад

    You should make a video on fluid flow over an airfoil with the Lattice-Boltzmann method

  • @WinstonDodson
    @WinstonDodson Год назад

    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.

  • @shubhamghosal9336
    @shubhamghosal9336 2 года назад +1

    Chad moment.

  • @anatoliyzavdoveev4252
    @anatoliyzavdoveev4252 Год назад +1

    Amazing , interesting, I am going to try to repeat 😇

  • @prietjepruck
    @prietjepruck Год назад

    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.

  • @syedabuthahirkaz
    @syedabuthahirkaz Год назад

    Try Taking Ensemble Average. Then the velocity distribution will look much smoother over time. I will post a video shortly over this.

  • @WinstonDodson
    @WinstonDodson Год назад

    I think that it would be interesting to repeat building this model but with symphonic.

  • @user-yx4jh6gi5n
    @user-yx4jh6gi5n Год назад

    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!

  • @CoolDude911
    @CoolDude911 Год назад

    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

    • @CoolDude911
      @CoolDude911 Год назад

      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.

  • @Path_k_pradeep
    @Path_k_pradeep 2 года назад +1

  • @suryadharma3007
    @suryadharma3007 2 месяца назад

    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?

  • @Johan-yy9pk
    @Johan-yy9pk 2 года назад +1

    Do video about how to download python libraries for physics

  • @Brandon_Tyr
    @Brandon_Tyr 11 месяцев назад

    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!

  • @pranav_cha
    @pranav_cha Год назад

    whats with the spinning pairs/triplets of particles that seem 'stuck' together?

    • @haraldhetzinger
      @haraldhetzinger Год назад +1

      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.

    • @haraldhetzinger
      @haraldhetzinger Год назад +1

      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)

    • @pranav_cha
      @pranav_cha Год назад

      @@haraldhetzinger that clears it up thanks!

  • @pauldirac6243
    @pauldirac6243 6 месяцев назад

    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.

  • @ddiva1973
    @ddiva1973 2 года назад +1

    if you ever do a doctorate, wil you change your username from Mr. P Solver to Dr. P Solver?

    • @MrPSolver
      @MrPSolver  2 года назад +3

      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 😂

  • @jorgemalosti9308
    @jorgemalosti9308 2 года назад

    my advisor wants me to do pretty much the same... but in fortran i have no ideia how am i gonna do that

  • @DanushKumarSSMSP
    @DanushKumarSSMSP 2 года назад

    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???

  • @anjishnu8643
    @anjishnu8643 2 года назад

    0 dislikes and 255 likes. Sorry but I just can't like the video.