Tutorial: How to simulate the wave equation

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ม.ค. 2025

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

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

    I've been trying to make something like this for over 2 years now, but all websites show a double slit experiment with none of the mathematics behind simulating light waves. Keep up the useful information.

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

      It is not that hard. I hope the presentation will be useful to you.

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

    I would love to see some lecture on the electromagnetic waves. I'm working on vector wave equations and to me it's very complicated especially to treat boundaries, impedance boundaries, radiation conditions etc. But it's fascinating area for simulation. Anyway, thank you for the excellent lesson!

  • @mferraro89
    @mferraro89 11 หลายเดือนก่อน +1

    Thanks Nils! At 25:31 the 1D difference equation uses C^2, but at 28:32 the 2D difference equation uses just C, not C^2. Is this correct?

    • @NilsBerglund
      @NilsBerglund  11 หลายเดือนก่อน +1

      That is a type, sorry for that. It should be C^2 in both cases.

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

    Thank you so very much for giving us all that value, it's great!

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

    Great presentation, thanks for the time you took to make it! The next step in optimization to me would be multithreading, where threads each work on a patch of the lattice. Since there's no instantaneous feedback you dont have concurrent data dependencies and therefore no need for thread synchronization beyond waiting for all threads in a frame to finish.
    Then there are specialized SIMD instructions that provide instruction-level parallelism by lalowing you to compute several floats at once.
    Since most computers nowadays have 8 threads in their CPU and support 4-float SIMD instructions, there is a theoretical 32x speed improvement on the non-boundary calculations.
    Alternatively, you could translate the reccurence equation to an OpenCL or CUDA kernel to have it run on the GPU, which should be fairly easy for the same reasons of not having instantaneous feedback in the recurrence equations.

  • @Rodrigo-xf2oe
    @Rodrigo-xf2oe ปีที่แล้ว

    Have you experimented with simulating waves in the frequency domain (given the solution you showed at 16:20)?
    It appears that in the frequency domain, you can simulate the state of the wave at any point in time in constant time (assuming the dimensions of the wave are constant). The only problem I see with that, at least in the 1D case, is the need to perform an inverse Fourier transform for each saved image, which may be costly. However, the advantage is that you can simulate for an arbitrarily long time with no error accumulation (or so I believe).
    But I don't know how well or poorly these properties would translate to the 2D case.

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

      The frequency domain is useful in many cases, and a commenter made some videos on their channel using this method. However, boundary conditions tend to be hard to implement that way, except in very special cases. That is why I have not developed the approach so far in my code.

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

    Great work keep it up!❤

  • @preguica_net
    @preguica_net 4 หลายเดือนก่อน +1

    There are 3 types of simulation: pure quantum, very heavy with few particles, semi classical with classical particles but with quantum mechanics implict like Lennard Jonnes and density for big systems but you can't track a single particle way. The simulations of this channel is density.

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

    For the 2D case, do you get any interesting effects by modelling the displacement as a 2D value per cell? In my head, with the 2D spring model in mind, I expected the displacement to be a two dimensional value.

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

      You would get two uncoupled wave equations, one for each direction of displacement. So it may create some nice interference patterns, depending on your initial state, but there will be no real interaction between the directions.

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

      @@NilsBerglund I think there could still be interaction between the components. The X axis springs could affect the Y offsets via the transverse math that you hinted at in the video, and vice versa. And one way to interpret the scalar values per cell you use is as offsets in the Z direction, transverse to both X and Y. But since you say that the result after going through the math of treating the waves as transverse ends up being the same as longitudinal, I wonder if it basically all cancels out, and you'd get effectively just the same simulation, except a bit slower.

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

    What is the PowerPoint template that you use?

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

      I'm not using PowerPoint. I'm making the slides in LateX, beamer document class, the theme is called Singapore.

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

    Excellent! Always lots of good insight.
    P.S. What the hell is all that banging noise?

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

      @@stereomachine LOL 🙂

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

      Thanks!
      Sorry for the noise, it comes from a fire door my colleagues tend to let bang as it closes. Perhaps I should try using a better microphone.

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

    Thank you so much for this!!!!

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

    A big thank you for showing how it work !! I had to think about "Huygens Optics Channel" which mostly deals with light experiments...and some theory. Many thanks !!

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

      You are welcome! Jeroen from Huygens Optics indeed makes some nice videos, including real life experiments.

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

      @@NilsBerglund I was fascinated by his Videos on the spatial and the temporal coherence of light waves

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

      Yes, I contributed a simulation to one of those videos.

  • @srinathmallikarjunan1259
    @srinathmallikarjunan1259 8 หลายเดือนก่อน +1

    In a finite difference solver for the wave equation, wouldn't you also face a constraint on the time step size (Courant Levy condition). Also purely from a wave equation perspective is it possible for a "shock front" to emerge for Electromagnetic waves ?
    I guess not, because Speed of light is a constant wrt all observers.

    • @NilsBerglund
      @NilsBerglund  8 หลายเดือนก่อน

      Yes, you need to satisfy a CFL condition, it is mentioned in the tutorial. Shock waves are indeed not possible with light in our relativistic universe, but they are possible with sound and water waves. See for instance th-cam.com/video/E-8P4nJqfVQ/w-d-xo.html

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

    4:30 - the famous 1st chaotic behaviour "linear" system that was observed on Eniac (AFAIR) by Feynman and other phycisists.

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

      You are thinking of the famous Fermi-Pasta-Ulam experiment, I assume. In their system, they added a non-linear term to the spring force.

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

      @@NilsBerglund Thank you - i might have been mistaken Fermi/Feynmann but i recall an image that there were many linearly connected oscillators without a nonlinearity. I remember that at least 3 degrees of freedom and a nonlinearity in contained phase space are required for the onset of chaos but maybe there was some numeric error involved or they approximated the 2D movement with that nonlinearity - 2D double pendulum is enough for the onset of chaos still i dont remember if the arms need to be stiff or can be flexible - rather rigid.

  • @jetbend
    @jetbend 9 หลายเดือนก่อน

    Informational and helpful, thanks.

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

    This is amazing, I could try it on interferometry.

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

    Can you give an example of how much time such simulations take per minute? Like the one with finer mesh for parabolic reflectors.

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

      The 2d one took about 12 minutes of simulation time per minute of movie. You can check the simulation time in the description of most videos.

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

      Nice. Very interesting work indeed! What about the boundary conditions for lens simulations, like the ones you shared with that other channel (Huygens optics). I tried to find such simulations in your GitHub, but could not find them. Thanks and happy new year!

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

      Thanks, same to you!
      To reproduce a simulation, look up the file Parameter_**.md of the correct month, and adapt the parameter values in the specified C file. Some extra dummy values may have to be added if you use a more recent version of the code.

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

    wow, FINALLY

  • @shikaishik
    @shikaishik 10 หลายเดือนก่อน

    日本語版が欲しいですね。。。
    日本人の弟子はいませんかね?

    • @NilsBerglund
      @NilsBerglund  10 หลายเดือนก่อน

      Have you tried automatic translation of the subtitles to Japanese? I don't know how well this works, but it could be worth a try.

    • @shikaishik
      @shikaishik 10 หลายเดือนก่อน

      @@NilsBerglund 日本語自動翻訳、どこがやってるのか、まだ分かってないです。3blue***?は、理系の専門家が自分で手入力し、日本語翻訳しています。
      そういうわけで、翻訳について、まだ開拓はされてません。
      専門用語の翻訳環境の構築、何がボトルネックになっているのか解明する必要はあるかもしれません。