Solve Schrödinger Equation in Seconds with Python & GPU

Поделиться
HTML-код
  • Опубликовано: 20 апр 2023
  • CHECK OUT MY NEW UDEMY COURSE, NOW 90% OFF WITH THIS CODE:
    www.udemy.com/course/python-s...
    Code:
    github.com/lukepolson/youtube...
    Old Video:
    • 2D Schrodinger Equatio...
    Get Your Billy T-Shirt: my-store-d2b84c.creator-sprin...
    Discord: / discord
    Instagram: / mrpsolver
  • НаукаНаука

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

  • @baldpolnareff7224
    @baldpolnareff7224 Год назад +54

    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

    • @rico879able
      @rico879able 3 месяца назад +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.

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

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

  • @lhomme_flaneur
    @lhomme_flaneur Год назад +7

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

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

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

  • @Tim-Kaa
    @Tim-Kaa Год назад +1

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

  • @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 🙂

  • @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!

  • @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!!

  • @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.

  • @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.

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

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

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

  • @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.

  • @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.

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

  • @fabiopimentel6981
    @fabiopimentel6981 Год назад +2

    This moment of the day is called happiness

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

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

  • @AJ-et3vf
    @AJ-et3vf 10 месяцев назад

    Great video! Thank you!

  • @kevinchen8325
    @kevinchen8325 Год назад +2

    oh yeah, this is why i subscribed!

  • @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

  • @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

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

    Thank you, your channel is amazing!!!!

  • @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.

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

  • @Tharushi_SM
    @Tharushi_SM Месяц назад

    Thank you so much for this,

  • @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

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

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

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

    Amazing, I like implementing physics math to graph

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

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

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

    What are computer specs you ran this code on?

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

    This is such great content

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

    you rock man!

  • @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

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

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

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

    cool videos as usual :)

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

    How does Pytorch compare, performance wise, to CuPy?

  • @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 2 месяца назад

      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.

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

    What of (delta-y)^2?

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

    Amazing!!!

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

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

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

    Very cool intro

  • @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 5 месяцев назад

    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 2 месяца назад

      yeah. maybe a non-uniform mesh of some kind

  • @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!

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

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

  • @ApteraEV2024
    @ApteraEV2024 9 месяцев назад

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

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

    please make videos on casadi

  • @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.

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

    I'm good thanks

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

    AAAAAAAAAAAAAAAAA

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

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

  • @usuario-si9rr
    @usuario-si9rr Год назад

    Does this explain why butts are so beautiful?

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

    Windows scrub

  • @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

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

    Phenomenal!