Тёмный

How To Solve and Animate a 3D Double Pendulum in Python 

Mr. P Solver
Подписаться 136 тыс.
Просмотров 19 тыс.
50% 1

Опубликовано:

 

11 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 78   
@babajani3569
@babajani3569 2 года назад
hello. When I tried running the 'sols' part of the code, when you solve the systems of Lagrage's equations. My jupyter lab can't seem to be able to finish loading that code. I don't know why that is. Could someone please help? Everything else was fine.
@tyw1387
@tyw1387 2 года назад
I am having the same problem. I'm on a 2019 Intel i9 MacBook Pro running Python 3.10. When I run the posted copy of vid32.ipynb, it gets "stuck" on the sols computation. It's been running over 9.5 hours and the Python process is consuming one of the CPUs (staying ~100% consistently). vpython is v7.6.3 and sympy is v1.9. This is the third attempt to run it. I terminated the last one after 9.5 hours, but then decided to give it another try. There are no errors in the Jupyter log so far. If this fails to complete, I'll try breaking up the sols into four different solution invocations. Anybody else having this problem? Any thoughts, Mr. P?
@MrPSolver
@MrPSolver 2 года назад
Strange...are you basically just downloading and running the notebook?
@tyw1387
@tyw1387 2 года назад
@@MrPSolver Correct. I cut off the last long run at 39+ hours. Now I'm experimenting with partial solutions. [LE1, LE2], [LE1, LE3], [LE2, LE4] all solve in a short amount of time. I'm now trying [LE1, LE2, LE4]. It's been keeping one CPU ~100% for over 11 minutes without yielding a solution set.
@MrPSolver
@MrPSolver 2 года назад
@@tyw1387 I wonder if it might be an issue with RAM (though it seems unlikely)..how much memory do you have on your computer?
@tyw1387
@tyw1387 2 года назад
@@MrPSolver The laptop has 32GB of RAM. The Python Kernel computing the solution set is reported as having 827.1MB of private memory. Kind of unrelated, but is doub_pen_3d.png posted somewhere? It's referenced by the second cell in the notebook.
@danv8718
@danv8718 2 года назад
How hasn't this channel exploded is beyond me!
@lucasthompson1650
@lucasthompson1650 Год назад
Maybe the singing? Hrm… nah, love the singing. 😊
@Louis-ml1zr
@Louis-ml1zr 2 года назад
The results looks awesome, congrats. Didnt know we could do this with python
@pythonixed4448
@pythonixed4448 2 года назад
Your pyramid metaphor is great. Amazing how much power you can have with a few lines of code.
@MichaelT_123
@MichaelT_123 2 года назад
Very nice & tidy presentation. If you want to extend it, consider checking "the imperfection of reality"; in other words, how a realisation of an idea deviates from its true meaning. In your pendulum case, there are two key equations sets: the symbolic one (idea) and the numerical representation (reality). Consider checking how the reality outcome changes depending on the precision and time step parameters of the numerical equation solver. You might find how 'realities' (simulated pendulum movements) diverge from each other by even the slightest inaccuracies of 'ideas' implementations (symbolic pendulum equations).
@fufaev-alexander
@fufaev-alexander 2 года назад
This intro is godlike! 😎
@AjSmit1
@AjSmit1 2 года назад
ok but great choice showing the result right as my attention began to fade, excellent hook
@a.andacaydn9736
@a.andacaydn9736 2 года назад
I hope he never stops doing this. This is gold! thank youuuu !
@noPwRon
@noPwRon 2 года назад
Thank you for these awesome videos, they have really helped me when I was dealing with robotics theory. I'd love to see similar video that deals with an inverted double pendulum or applied forces on a double pendulum.
@andrewiglinski148
@andrewiglinski148 2 года назад
Dude I swear... I took 5 years off between my junior and senior year to work abroad so grad school wasn't as appealing when I graduated at almost 28 but now that I work as a software engineer I feel like I'm catching up on the stuff I missed out on with these videos.
@hsh7677
@hsh7677 2 года назад
Amazing!!! I love your content, I'm learning a lot!! Keep it up bro, you're the best!!
@MrPSolver
@MrPSolver 2 года назад
Lots more fun stuff to come
@Zymplectic
@Zymplectic 2 года назад
This does not work well because of the choice of coordinates. You create a singularity at the poles (what is phi if the pendulum heads straight down?) The problem occurs for both the single spherical pendulum and double spherical pendulum. If you examine the energy of the system, you should notice dramatic change if either pendulum approaches either pole - even if you use adaptive high order RK-methods.
@rafacoreman4728
@rafacoreman4728 Год назад
This is my computational physics final project, thank you so much for the inspiration!
@M3TaTr0Nx
@M3TaTr0Nx 9 месяцев назад
Beautifully explained and demonstrated! 🤜💯 thanks bro
@anshumanchoudhary4732
@anshumanchoudhary4732 Год назад
Love this sort of stuff ! Great for people interested in maths, physics and cs. Btw can this be useful as a college project?
@frankkoslowski6917
@frankkoslowski6917 Год назад
Investigatig why this instruction specific to this solution, --> sols = sp.solve([LE1, LE2, LE3, LE4], (the1_dd, the2_dd, phi1_dd, phi2_dd), simplify=False, rational=False) as supposed to The Double_Springed Pendulum, appears to take forever: Pay attention! --> sols_1 = sp.solve([LE3, LE4], [the1_dd, the2_dd], simplify=False, rational=False) We get --> dict_keys([Derivative(\theta_1(t), (t, 2)), Derivative(\theta_2(t), (t, 2))]) Next --> sols_2 = sp.solve([LE1, LE2], [phi1_dd, phi2_dd], simplify=False, rational=False) We get --> dict_keys([Derivative(\phi_1(t), (t, 2)), Derivative(\phi_2(t), (t, 2))]) as expected. By comparison: --> sols_1 = sp.solve([LE1, LE2], [the1_dd, the2_dd], simplify=False, rational=False) This goes nowhere. Consequently: --> sols = sp.solve([LE1, LE2, LE3, LE4], (phi1_dd, phi2_dd, the1_dd, the2_dd), simplify=False, rational=False) This can not work on the basis of prior discovery. 😮‍💨 Is this magic, or is it the greatest heap of nonsense ever? 😖
@sausix
@sausix 2 года назад
odeint is deprecated as mentioned in the documentation. solve_ivp is recommended and offers multiple solvers and more control. I've been working on a too big project for me to visualize different initial parameters of a "simple" 2D double pendulum.
@mohamedaminebenbouali2941
@mohamedaminebenbouali2941 2 года назад
this will help me in my impedance control masters degree I wanna simulate a double pendulum and then apply impedance control on it wish me luckk
@1401quaker
@1401quaker Год назад
Thank you. You made my day. Im a big fan of the pendulum myself, and you did an awesome thing there
@wenhanzhou5826
@wenhanzhou5826 2 года назад
The physics is really cool, but this intro was something else!
@daddy_myers
@daddy_myers Год назад
I managed to create a function for the shadow size-adjusting, here's the code: def shadow(r, i, z1, z2): return r + 1/3 * np.abs(r - z1[i]/np.min(z1)), r + 1/3 * np.abs(r - z2[i]/np.min(z2)) And in the animation while loop: shadow = shadow(insert_sphere_radius_here, i, z1, z2) s1.radius, s2.radius = shadow Where z1 and z2 are the z-position arrays for the pendula.
@sonnycupcake
@sonnycupcake 2 года назад
I love how this guy loves science with python
@priyajanswongamikha3294
@priyajanswongamikha3294 2 года назад
Thank you so much for such interesting content, Hoping for more
@tahabukhari3189
@tahabukhari3189 2 года назад
Hello sorry. I was wondering why should one use Python when, I have heard at least, that Matlab is much faster than python in its computational abilities. Sorry about my ignorance. I am only a high school student. Also, could you please create a tutorial for this library as well? Thank you.
@mohamedaminebenbouali2941
@mohamedaminebenbouali2941 2 года назад
just because something else is better doesn't mean everyone should use it, I could tell u eating worms is the healthiest thing in the world, but is it fun? no, Matlab has a lotta math and is fast too but python is a general purpose language, u can setup a backend server and host this simulation on a website in minutes, u can turn it into a game, u can compile it into an app, u can do anything with this
@julians.2597
@julians.2597 2 года назад
there's two main points for why you might use python over matlab, which @Mohamed already touched on, but both hinge on the fact that python is a general purpose language. 1.) If you write it in python, you can easily push it onto e.g. a webserver, into a game, desktop app or whatever and deploy it as an actual application, whereas matlab is just useful in a _lab_ context. 2.) Many people already know python and are very familiar with optimiizing python code. For them, it's much faster to learn just a single new library, rather than a total different language. I also would call to your attention the fantastic libraries numpy, pandas and scipy, which are incredibly fast, by allowing you to do calculations in C and even using processes like SIMD if you optimize for it, reducing any computational deficit vs other languages to a minimum for these time-consuming calculations.
@tahabukhari3189
@tahabukhari3189 2 года назад
@@mohamedaminebenbouali2941 Sorry, yes. What you have mentioned are thinks that are for general usage e.g. creating websites but I am talking about in Physics. What is it about python that can't be done in Matlab, or re-phrased, what can python do better than Matlab so that I should prefer it over Matlab? Thank you.
@tahabukhari3189
@tahabukhari3189 2 года назад
@@julians.2597 Thank you.
@geodancer7281
@geodancer7281 2 года назад
I would like to add to what @Mohamed Amine Benbouali and @Julian S. have said -- While you are in school, Matlab is very easy to get. I admit it is powerful and easy to learn. But after you leave school, Matlab is quite expensive. The Matlab community is mostly inside academics. Python, along with a very large number of modules, are free. For example, look into "Anaconda." Python is only a little harder to learn than Matlab. When you "publish" (for example, github) your Python code, people all over the world, inside and outside academics, will immediately be able to use your code. In this way, you will join a much larger community, be able to "meet" people, maybe some who can give you ideas about how to add to your project.
@AJ-et3vf
@AJ-et3vf 2 года назад
awesome video! Thank you! great and inspirational as usual!
@amineelamri7073
@amineelamri7073 2 года назад
best channel so far keep going man!!
@lisa-mariarubsam-tu5je
@lisa-mariarubsam-tu5je Год назад
Hi @Mr.P Solver! Many thanks for the great video and skript. Are you aware of any experiments to transfer theory into practice for the 3D version? Or existing/ available simulations in CAD software? Many thanks!
@albertorossi6093
@albertorossi6093 Год назад
congrats for the video, the post processing was amazing. Do you know how to add a fixed coordinate system (with labels) to the animation in order to visualize the pendulum movement more easiliy?
@user-st8rv6mf1v
@user-st8rv6mf1v 25 дней назад
should I type o1 definition in python?
@tahabukhari3189
@tahabukhari3189 Год назад
For some reason, when I load the last the last cell, it gives errors. I don't know why.
@1401quaker
@1401quaker Год назад
how about the n-body problem and the dzhanibekov effect, those are my projects now
@1401quaker
@1401quaker Год назад
Thank of the pendulum, . Im a big fan
@youngidealist
@youngidealist 2 года назад
Could you simulate an electron waveform as it encounters and reacts with a proton in 3d? I want to see the dance of the orbital taking form.
@mariomuysensual
@mariomuysensual 2 года назад
I fucking love vpython
@Oceansteve
@Oceansteve 2 года назад
Literally JUST started looking for 3D animation in Python today.... and this pops up..
@BryanWLepore
@BryanWLepore Год назад
Impressive!
@SarthakGamer
@SarthakGamer 2 года назад
Another amazing video!!
@koushikvijayakumar7924
@koushikvijayakumar7924 7 месяцев назад
It shoes 'Failed to interpret the file as pickle
@maxdemarr4411
@maxdemarr4411 2 года назад
Another fantastic video! You should look into Glowscript's VPython, if you haven't already. It's one of the best for 3-D simulations!
@frankkoslowski6917
@frankkoslowski6917 Год назад
Another SymPy odety: LE1 = sp.diff(L, the1) - sp.diff(sp.diff(L, the1_d), t).simplify() This instruction seems too difficult for SymPy. Although it will produce a result eventually, the solver in it's function, was shown to walk off into oblivion. However, LE1 = sp.diff(L, the1) - sp.diff(sp.diff(L, the1_d), t) LE1.simplify() when broken up into two separate jobs, it was found to work fine, and the result allowed the solver to return the correct solution swiftly.
@kamelkamelkamatchou9380
@kamelkamelkamatchou9380 2 года назад
Awesome bro
@user-lc6jq1hi1r
@user-lc6jq1hi1r 2 года назад
nice beard yo, may Allah reward you well for the physics.
@subhamchowdhury2271
@subhamchowdhury2271 2 года назад
Good Day to you sir.... Very Interactive lessons indeed. I am very much getting benefitted from these. A request sir, Can you make videos on Discrete Element Simulation of rigid granular medium via Python coding ?
@brianlane723
@brianlane723 2 года назад
"Is that VPython? ... THAT'S VPYTHON!"
@sonnycupcake
@sonnycupcake 2 года назад
Thank you so much
@mikekertser5384
@mikekertser5384 2 года назад
Awesome! :)
@brianlane723
@brianlane723 2 года назад
More VPython info: ru-vid.com/group/PLdCdV2GBGyXOnMaPS1BgO7IOU_00ApuMo
@1401quaker
@1401quaker Год назад
because there is music in there
@ErikChromjak
@ErikChromjak 2 года назад
Thats great
@sonugeorgealex
@sonugeorgealex Год назад
wow🤩🤩
@1401quaker
@1401quaker Год назад
oh, i was doing it the wrong way, with linear algebra and runge-cutta
@jr_qr1446
@jr_qr1446 2 года назад
35:20 bad choice of words
@riccvven2078
@riccvven2078 8 месяцев назад
better than sex 10/10
@yogeshwagh2849
@yogeshwagh2849 2 года назад
I'm not a rapper
@1401quaker
@1401quaker Год назад
All i can say is zz top has a great tune called lagrange. I am taking your code and putting sound to the xyz because