Solve Schrödinger Equation in Seconds with Python & GPU

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ต.ค. 2024
  • CHECK OUT MY NEW UDEMY COURSE, NOW 90% OFF WITH THIS CODE:
    www.udemy.com/...
    Code:
    github.com/luk...
    Old Video:
    • 2D Schrodinger Equatio...
    Get Your Billy T-Shirt: my-store-d2b84...
    Discord: / discord
    Instagram: / mrpsolver

ความคิดเห็น • 74

  • @baldpolnareff7224
    @baldpolnareff7224 ปีที่แล้ว +55

    This series on refactoring NumPy code to PyTorch is one of the best ideas ever, please never stop!
    Also, plotly is a wonderful plotting library

    • @Holeinone-v7n
      @Holeinone-v7n 5 หลายเดือนก่อน +1

      best idea ever...agree

  • @bobnull
    @bobnull ปีที่แล้ว +8

    No way. I started working on this kind of thing after watching your last video. I'm gonna put this in my queue and watch when I can really focus.

  • @LoserKing696
    @LoserKing696 ปีที่แล้ว +21

    Awesome vid dude. I am currently coding a simulator for the Shallow Water Equations using finite volumes, so I would love to see you tackle some CFD in python. Really curious about its performance.

  • @jobsmine
    @jobsmine ปีที่แล้ว +2

    Yesssss this is what I’m doing. One my classes final exam required deriving the greens function to the classical formals. I chose the diffusion 2D and solved it from scratch and I presented on Thursday.

  • @lhomme_flaneur
    @lhomme_flaneur ปีที่แล้ว +7

    ayo, keep posting these scientific computing videos, they are getting greater and greater btw :)

  • @astropgn
    @astropgn ปีที่แล้ว +1

    For years I've been wanting to plot the hydrogen atom orbitals and their potentials and I was never able to. Thank you so much, this video is awesome! I will definitely try it!

  • @martinzapata7289
    @martinzapata7289 ปีที่แล้ว +1

    Yooo, I’ve been following the channel for a while and the content only gets better. Good shit.

  • @AJ5
    @AJ5 ปีที่แล้ว +2

    I subscribed for this content, not the memes!
    Love the memes too, but this is invaluable and I appreciate you taking the time to put it together!!

  • @Tim-Kaa
    @Tim-Kaa ปีที่แล้ว +1

    Thank you, I watched the whole Schrodinger's series, amazing work.

  • @richardbennett4365
    @richardbennett4365 ปีที่แล้ว +5

    What happened to him after 23:10? He was his normal teaching-by-ydlling, crancked-up on speed personality, but after this point he became Mr Sedate, calmed-down man. Too funny.

    • @MrPSolver
      @MrPSolver  ปีที่แล้ว +6

      LOL recording crashed when I ran the GPU code, had to re-record the last 1/3rd if the video in the morning

    • @richardbennett4365
      @richardbennett4365 ปีที่แล้ว +1

      @@MrPSolver
      It's okay. I have my doctorate like you do, or will, so I understand your passion about your subject. I enjoy your videos. I majored in mathematics and physics in undergrad and went on to apply that quantitative background to the fields of biophysics, biochemistry ,and pharmacology. Keep making videos, and I hope to get mine up soon. I just hope I get some followers/subscribers and help people along the way. When I have my first few videos up, I'll let you know.

  • @fabiopimentel6981
    @fabiopimentel6981 ปีที่แล้ว +2

    This moment of the day is called happiness

  • @HitAndMissLab
    @HitAndMissLab ปีที่แล้ว

    Its really phenomenal to get first hand insight into the way how a scientist thinks.
    Your knowledge of maths is impressive. Immediately subscribed 🙂

  • @RalphDratman
    @RalphDratman ปีที่แล้ว

    So great to have a physicist teaching Python and computer topics. Thank you!

  • @TheFreeSpiritKID
    @TheFreeSpiritKID ปีที่แล้ว

    What a wonderful thing to watch after a few beers. And beautiful plots. Thx 🙂

  • @kevinchen8325
    @kevinchen8325 ปีที่แล้ว +2

    oh yeah, this is why i subscribed!

  • @Ricocossa1
    @Ricocossa1 ปีที่แล้ว +7

    Very cool! I'm a physicist equipped with a nvidia gpu, and this looks like a fun project to pass time!
    You mentioned your research. What do you work on?

  • @ericmiller6281
    @ericmiller6281 ปีที่แล้ว +2

    Great set of videos. Can you please elaborate on how you handled the boundary conditions? It was not obvious from looking at the code while watching the video. Many thanks.

  • @shivasluzz
    @shivasluzz ปีที่แล้ว

    Thanks for your wonderful videos! A video about solving Navier stokes equation for a simple 2D incompressible flow will be great.

    • @esojle
      @esojle ปีที่แล้ว

      I think Lorena barba has a 7stepstonavierstokes class you can follow for that

  • @yds6268
    @yds6268 ปีที่แล้ว +1

    Very nice! I'll have to check out your code. I wish I could solve Schrodinger equation in 3D fast, especially for scattering problems

    • @martinzapata7289
      @martinzapata7289 ปีที่แล้ว +1

      Depending on how complicated your problems are, you might want to consider a diferent approach. You can make many symplifying assumptions with central potentials, etc

  • @skilz8098
    @skilz8098 ปีที่แล้ว +3

    This is quite an amazing video and presentation. Mad props on the time, work, and effort put into this video. To create a Python Script in solving the Schrodinger Equation is by no means an easy task. Job well done!
    As a side note: Now if one is truly after a higher precision while maintaining high efficiency and performance then I'd suggest doing something similar in either C or C++ as opposed to Python. Don't get me wrong, Python is a great and powerful language and it is a bit quicker in writing the source code since it is an interpreted language, however compared to C or C++ it is orders of magnitude computationally slower compared to compiled languages. Also, if one does decide to do something similar in C/C++ then I'd also suggest to using either DX12 if on Windows or the Vulkan Graphics API, even modern OpenGL wouldn't be a bad suggestion, however, Vulkan and DX12 are way more flexible with less driver overhead compared to older versions of DirectX, and OpenGL. The major difference here is that there would be more boilerplate code to setup, there is no hand-holding since there is always a greater amount of responsibility that comes with having more flexibility and direct control over the hardware.

    • @98danielray
      @98danielray 4 หลายเดือนก่อน

      all of these libraries are precompiled C/fortran code. youre not losing multiple orders of magnitude from this, especially in hotspots. these wrappers have performance comparable to their lower level counterparts.

  • @firasnizam
    @firasnizam ปีที่แล้ว

    Amazing, I like implementing physics math to graph

  • @GustavoPinho89
    @GustavoPinho89 ปีที่แล้ว +1

    Hey, Billy. Could you do a video about the "new" scipy.sparse methods since they say in the documentation that such methods as kron, eye and diags are "deprecated". I really find the old way much simpler, but there aren't many tutorials going around. Cheers from Brazil

  • @Miguel_Noether
    @Miguel_Noether ปีที่แล้ว +2

    what is the precision of the numerical results when working with the GPU? If you work with higher precision do the calculation become as slow as doing it with a CPU?

  • @victorgabrielmoreleduarte5999
    @victorgabrielmoreleduarte5999 ปีที่แล้ว +1

    Very nice video! Interesting to see the analytical solutions of the Hydrogen atom popping out of a strictly numerical approach. It really helps you understand the problem even better, I think.
    I noticed you've been using vscode for a while now. Could you elaborate a bit on why you prefer to use it instead of native jupyter lab?
    Thanks a lot for the good work.

  • @J_CtheEngineer
    @J_CtheEngineer ปีที่แล้ว

    Mechanical Engineer here, I’m just here for the pretty plots!

  • @joshuastewart7309
    @joshuastewart7309 ปีที่แล้ว +4

    Around the 19 minute mark you mention the reason to use such a large amount of spacing is because of Dirichlet boundaries (saying the wave function goes to zero). Shouldn't this be a Neumann boundary? Could you give some detail on that boundary condition.

    • @MrPSolver
      @MrPSolver  ปีที่แล้ว +2

      From my understanding, if you look at the top left and bottom right entries of the diagonal matrix "D", you miss one the "1"s that come on either side of the main diagonal. So it's effectively equal to zero, meaning that when you compute the second derivative at those locations, it's equivalent to the wave function being equal to zero there.

    • @joshuastewart7309
      @joshuastewart7309 ปีที่แล้ว +2

      @@MrPSolver Are you saying the first and second derivative would be zero because the upper left and lower right are missing parts of the "stencil"? How are you getting to the conclusion that's equivalent to the wave function being equal to zero there? That sounds like a Neumann boundary to me because it involves a derivative normal to the boundary.

    • @MrPSolver
      @MrPSolver  ปีที่แล้ว +3

      @@joshuastewart7309 The first and second derivatives aren't necessarily zero there. It's the fact that when you compute the second derivative at the edges, you're not including points that exist beyond the boundary (because the matrix D is cut-off at these points). That's mathematically equivalent to including points beyond the boundary, but having them be equal to 0

  • @kevinsweeney2809
    @kevinsweeney2809 ปีที่แล้ว

    Thank you, your channel is amazing!!!!

  • @mikekertser5384
    @mikekertser5384 ปีที่แล้ว

    Thank you. I enjoy your videos very much! :)

  • @AJ-et3vf
    @AJ-et3vf ปีที่แล้ว

    Great video! Thank you!

  • @ignatiolu863
    @ignatiolu863 ปีที่แล้ว +2

    How fast can the operation be f = A^{-1} b if f and b are vectors and A is a sparse matrix (say the same size as the Hydrogen eigen-matrix).
    And as always, thank you for your content!

  • @voidwalker0x286
    @voidwalker0x286 ปีที่แล้ว +1

    How good of a GPU is required to do stuff like this? I doubt it but would an integrated GPU be able to do the job?

  • @szilardfineascovasa6144
    @szilardfineascovasa6144 ปีที่แล้ว +5

    Where's Billy?!

    • @samirdevechi8589
      @samirdevechi8589 ปีที่แล้ว +12

      Billy misunderstood PyTorch as the process of 'torching' a pie, and has accidentally set his home on fire :(

    • @szilardfineascovasa6144
      @szilardfineascovasa6144 ปีที่แล้ว +2

      @@samirdevechi8589 Hahaha! Wishing Billy a quick recovery, he could've grilled himself.
      (I have no doubt he would've been delicious, but I very much prefer his presence in...raw mode. 😆)

    • @MrPSolver
      @MrPSolver  ปีที่แล้ว +10

      Still recovering after defending his thesis.

    • @szilardfineascovasa6144
      @szilardfineascovasa6144 ปีที่แล้ว

      @@MrPSolver That was a hard weight to bear, as heavy as a medium-sized pile of average-sized rocks, pour feathered soul!

  • @HelloWorlds__JTS
    @HelloWorlds__JTS ปีที่แล้ว +1

    Phenomenal!

  • @Tharushi_SM
    @Tharushi_SM 3 หลายเดือนก่อน

    Thank you so much for this,

  • @ApteraEV2024
    @ApteraEV2024 11 หลายเดือนก่อน

    24:00 a lot of Quantum Mechanical textbooks???😅😅😅❤

  • @laarouasaid
    @laarouasaid ปีที่แล้ว

    you rock man!

  • @PrajjalakChattopadhyay
    @PrajjalakChattopadhyay ปีที่แล้ว

    My laptop doesn't have a dedicated GPU, but I have access to our institute's HPC cluster which has Nvidia Tesla V100 GPUs. I would like to try this code there.

  • @materiasacra
    @materiasacra 7 หลายเดือนก่อน

    It seems that the comparatively low accuracy is due to 'wasting' a large number of mesh points in areas where the wave function is near zero. This is a consequence of your treatment of the boundary conditions: having a hard wall 'very far' away. This is the aspect where improvement is likely to have the most 'bang for the buck'. I'm not sufficiently proficient in Python and its libraries to guess what the most practical approach would be. A fine mesh inside a coarse mesh? Take into account a estimate of the asymptotic behavior of the wavefunction?

    • @98danielray
      @98danielray 4 หลายเดือนก่อน

      yeah. maybe a non-uniform mesh of some kind

  • @lLuckM3412
    @lLuckM3412 4 หลายเดือนก่อน

    Very cool intro

  • @AriKath
    @AriKath ปีที่แล้ว

    This is such great content

  • @njyde
    @njyde ปีที่แล้ว

    Can you refer me to some relevant litterature for solving the SHE in 2D/3D numerically? Great video!

  • @6ygfddgghhbvdx
    @6ygfddgghhbvdx ปีที่แล้ว

    The wave function is generally complex numbers, can you explain where in your code this is reflected.

  • @mumujibirb
    @mumujibirb ปีที่แล้ว

    unfortunately, i still have not been able to get cuda to run.

  • @Roxas99Yami
    @Roxas99Yami ปีที่แล้ว

    cool videos as usual :)

  • @drdca8263
    @drdca8263 ปีที่แล้ว

    So is D \oplus D here, the same as (I \otimes D) + (D \otimes I)
    (Where I is the NxN identity matrix) ?
    Edit: ah, 8:44 answers this in the affirmative.

  • @bimasharahaman3870
    @bimasharahaman3870 ปีที่แล้ว

    Sir , If there is any numerical process to plot hydrogen wave function in 3d or 2d.. ....
    Sir , waiting for you reply

  • @peterchindove7146
    @peterchindove7146 ปีที่แล้ว

    What of (delta-y)^2?

  • @shanshanbond7040
    @shanshanbond7040 ปีที่แล้ว

    please make videos on casadi

  • @ibonitog
    @ibonitog ปีที่แล้ว

    How does Pytorch compare, performance wise, to CuPy?

  • @Levy957
    @Levy957 ปีที่แล้ว

    Amazing!!!

  • @PV10008
    @PV10008 ปีที่แล้ว

    This can't be done using the mps backend, right?

  • @BuciuEmilian
    @BuciuEmilian ปีที่แล้ว

    Does anybody know how can I setup VS Code so that I can rotate the figures like he does at 27:28?

  • @asaboor
    @asaboor ปีที่แล้ว

    What are computer specs you ran this code on?

  • @T3WI
    @T3WI ปีที่แล้ว

    I'm good thanks

  • @usuario-si9rr
    @usuario-si9rr ปีที่แล้ว

    Does this explain why butts are so beautiful?

  • @chromax1619
    @chromax1619 ปีที่แล้ว

    AAAAAAAAAAAAAAAAA

  • @theperfectionist1607
    @theperfectionist1607 ปีที่แล้ว +1

    Windows scrub

  • @nirajangupta7406
    @nirajangupta7406 ปีที่แล้ว

    sir, please start a series on numerical general relativity and quantum field theory using python. please! please! please!

  • @wdobni
    @wdobni ปีที่แล้ว

    what's the point? why solve for 3D in Schrodinger? its been done many times before over the past 80 years and you can look up the data if you want the results.....i guess its a good exercise in coding practice for the time in the future when you think up some useful application for your top level skills rather than rediscovering ideas that were discovered early in the previous century