Model + Simulate Spring Mass in Python

Поделиться
HTML-код
  • Опубликовано: 6 янв 2025

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

  • @ramos_4892
    @ramos_4892 10 месяцев назад +6

    As someone looking into studying Computational Science and Engineering, this is some incredible stuff, thank you

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

    Way to underrated... INSANELY underrated... Keep going 👍👍

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

      Thanks so much! Been busy with finals and applying to grad school. Should get some new videos out in a couple weeks

    • @btizzlenba7705
      @btizzlenba7705 10 месяцев назад

      @@logandihel cool stuff. I'm also an engineering student (optical). Any tips on survival?

    • @logandihel
      @logandihel  10 месяцев назад

      @@btizzlenba7705 find a quality study group and take advantage of office hours. You'll be way more productive with your time and make some friends along the way

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

    That super cool! Your work is so great, thanks and please keep updating it

  • @GiuvenxD
    @GiuvenxD 10 месяцев назад +4

    spectacular video

  • @kedvesendre-zsolt7842
    @kedvesendre-zsolt7842 10 месяцев назад

    Thanks for the great work!

  • @Daniboy370
    @Daniboy370 10 месяцев назад

    Beautiful example 🤙🏻

  • @draupathumesh4142
    @draupathumesh4142 10 месяцев назад +2

    Hi logan...pls tell how did you made that motion picture of oscillating spring mass system

    • @logandihel
      @logandihel  10 месяцев назад +3

      Code for the animations are available on my github page, which is linked in the description. The motion picture was done using the manim library, which I may put out a video later.

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

    Very cool animations!

  • @olsea1229
    @olsea1229 7 месяцев назад

    Another question is why on the diagram of speed versus time the speed does not tend to zero, it remains somewhere around 0.5?

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

      The velocity tends to zero when friction is added. Otherwise, no energy is lost and the velocity is sinusoidal

  • @ThrowTop
    @ThrowTop 2 года назад +6

    inconsistent mic volume but interesting videp. GJ

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

    You earned my sub!

  • @nguyenxuanthanh6988
    @nguyenxuanthanh6988 4 месяца назад

    Cool video.

  • @olsea1229
    @olsea1229 8 месяцев назад

    How to increase the oscillation time so that the pendulum swings to a complete stop?

    • @logandihel
      @logandihel  8 месяцев назад

      The solve_ivp() function allows you to input the simulation time (mine is set [0,10] meaning from 0 to 10 seconds) and also the evaluation time (mine is set from 0 to 10 seconds, evaluated 30 times per second). You can increase the 10s to a larger value like 25.
      You could also change the value of "b" (damping coefficient) to perhaps 5 to make the system lose energy faster

    • @olsea1229
      @olsea1229 8 месяцев назад

      @@logandihel I changed the value but the duration of the GIF image remained the same. What can be done?

    • @logandihel
      @logandihel  8 месяцев назад

      @olsea1229 which file are you editing? Is it SpringMass/animate.py ? If so, only lines 25 and 26 should need editing to change the .gif file time duration

    • @olsea1229
      @olsea1229 8 месяцев назад

      @@logandihel I changed it like this: sol = solve_ivp(spring_mass_ODE, [0, 30], (x0, x_dot0),
      t_eval=np.linspace(0,10,10*30))
      but the time of the gif animation has not changed

    • @logandihel
      @logandihel  8 месяцев назад

      @@olsea1229 change t_eval to np.linspace(0,30,30*30)

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

    Ey! I have a question, It’s the energy of the system constant? I mean, silly question, but when I plot E = T + V, it’s not constant...

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

      The energy of the system is constant only if friction is ignored. Set b to zero and you should see the energy is constant, perhaps with small changes due to numerical integration errors

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

      @@logandihel Ahh it oscilates... Thanks anyway! I was searching a bit and I think it’s common in the way it solves the ODE right? I was doing the kepler problem potencial to see orbits and again the energy driftt. I guess now i’m reading a book about numerical method for python... I thought this day will never come!

  • @gaz_3827
    @gaz_3827 10 месяцев назад

    I was wondering if you can change the setup to a horizontal one therefore getting rid of potentiel energy Vm and only leaving the elastic potentiel energy of the spring
    and starting the simulation after an initial displacement of the mass m

    • @logandihel
      @logandihel  10 месяцев назад +2

      Yes, that would totally work! That would be a great exercise for you.
      In fact, you could generalized the spring mass system to oscillate back and forth about any angle!

    • @gaz_3827
      @gaz_3827 10 месяцев назад

      @@logandihel Thanks for responding, I'll surely try it

  • @timreed9722
    @timreed9722 4 месяца назад

    Awesome video! How are you outputting the latex?

    • @logandihel
      @logandihel  4 месяца назад

      To view to the latex in the Jupyter notebook you need to run the command
      init_vprinting
      Which I did in my import statements at the top of the program.

    • @timreed9722
      @timreed9722 4 месяца назад

      @@logandihel Yeah, I did that. I'm not sure what actual function you're using. I have another route that is working for me now, but it's a bit messy and requires a bit of setup. Your method seems cleaner and simpler unless you've abstracted way much of the details.

    • @logandihel
      @logandihel  4 месяца назад

      I'd recommend copying the code directly from my github page (link in description), and if that doesn't work you can submit an issue on my RUclips GitHub repository. It's also possible you're missing a required package, or the packages have changed versions since I posted the video

  • @mohamedeljahmi2454
    @mohamedeljahmi2454 10 месяцев назад

    Why is positive x towards the ground and negative x towards the ceiling?

    • @logandihel
      @logandihel  10 месяцев назад

      Great question! It doesn't really matter how we define x, as long as we are consistent. If you want, simply replace x with (-y) in each equation, so that y positive is up.
      Fun fact: In aerospace literature, it is actually more common to define z to be down. This is just a convention

    • @mohamedeljahmi2454
      @mohamedeljahmi2454 10 месяцев назад

      In the foundation of robotics course, the z-axis was always the axis of motion. Thanks for your video. I have been studying lagrangian for the past week and the available videos are long and complex. Although yours is short, it contains a lot of information and I keep watching so I enhance my understanding and then move into complex topics.

    • @logandihel
      @logandihel  10 месяцев назад

      @mohamedeljahmi2454 good luck! I have some other videos for deriving equations of motion for the pendulum using Lagrangian mechanics, which is a great example of a nonlinear system

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

    The code you provide on your GitHub, is not working on my VS code.... So kindly tell me that which libraries or modules I have to install in VS code like minam, ffmpeg etc....

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

      You need ffmpeg to produce the .gif file. Follow instructions on my github here: github.com/logdog/RUclips/blob/main/README.md

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

    nice video!

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

    Did you using manim to animate mass pendulum at intro?

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

      Yes, I used the Manim Community version in Python

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

    how can we apply gas pressure in spring mass?

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

      You can model air resistance by modifying the ODE. Typically the drag is proportional to the square of velocity.

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

    My man!

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

    Logan, are you using VS Code as IDE?

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

      Yes, with the Jupyter Notebook extension

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

    ❤❤✔✔

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

    dayum

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

    Please make another videos ❤

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

      Done! Learn how to animate a spring mass system here: ruclips.net/video/mX1VDOY6wVc/видео.html

  • @ishaankumar4587
    @ishaankumar4587 10 месяцев назад

    Is this what we study physics for

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

    I need the next video :(

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

      Done! Learn how to animate a spring mass system here: ruclips.net/video/mX1VDOY6wVc/видео.html

  • @giacomobracci1047
    @giacomobracci1047 10 месяцев назад +1

    You cannot call this a simulation, this is only a visual representation of the solution of a problem analitically solved...

    • @projekcja
      @projekcja 10 месяцев назад +2

      Not true, when he called scipy.integreate.solve_ivp() it numerically solves the "initial value problem" by running a time-step by time-step simulation. It does not use the analytical solution of the ODE.
      The description of the function says "This function numerically integrates a system of ordinary differential equations given an initial value". There is nothing more fitting of the name simulation than that.

  • @BenjaminAster
    @BenjaminAster 2 года назад +22

    I really don't like Python and would prefer e.g. JavaScript/TypeScript, but the video quality is excellent nonetheless!

    • @vectoralphaSec
      @vectoralphaSec 2 года назад +31

      why? Python is way better than JavaScript to write. I could not stand to write in JavaScript.

    • @GuruCodeWriter
      @GuruCodeWriter 10 месяцев назад +3

      @@vectoralphaSeceh they both have their benefits, but i wouldnt choose python for that reason. It is just a standard for this kind of analysis, javascript being a little more tedious to use directly

    • @faysoufox
      @faysoufox 10 месяцев назад +30

      Python with jupyter notebooks is definitely a language used for science calculations. Other common softwares are maple, matlab and mathematica but python has the benefit of being free and having a huge amount of libraries. I would never use JavaScript for science computations nor have I have ever seen this case.

    • @coledelong427
      @coledelong427 10 месяцев назад +4

      I’ve never met anybody who uses js/ts for computation. If you want to get into physics simulation stick to python/Fortran/matlab etc

    • @Comonad
      @Comonad 10 месяцев назад

      Really? “Why don’t we double down on dynamic types. Just really get into weird implicit conversions, that’ll really make this maths easier”

  • @fudgenuggets405
    @fudgenuggets405 10 месяцев назад

    You need a better microphone.

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

    In complex system of more freedom coordinate Python is useless, C/ and C++ is better

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

      Agreed, but Python is more accessible for a RUclips audience. MATLAB is what I typically use as an engineer for quick simulations