- Видео 17
- Просмотров 106 788
Logan Dihel
Добавлен 31 окт 2013
Learn engineering, math, and computer science from a graduate student and NASA scientist! My goal is to teach over 1,000,000 people something new with short, digestible content.
Run my tutorials on your machine!
Learn how to run the code in my other tutorials which are on my github page!
Github: github.com/logdog/RUclips
Github: github.com/logdog/RUclips
Просмотров: 417
Видео
Simulate 1000 Double Pendulums in Python! (Lagrangian Mechanics)
Просмотров 2,5 тыс.10 месяцев назад
Code (github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Double Pendulum Learn how to model, simulate, and animate 1000 Double Pendulum using Lagrangian Mechanics! Learn to model both the simple and compound double pendulum. [0:00] Intro [0:43] Model Simple Pend [4:30] Model Compound Pend [6:32] Euler-Lagrange Equation [7:48] Solve Euler-Lagrange [12:27] Simulate Simple...
Kapitza Pendulum: Model + Simulate + Animate (Lagrangian Mechanics)
Просмотров 1,1 тыс.11 месяцев назад
Code (github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Kapitza Pendulum Learn how to model, simulate, and animate the Kapitza Pendulum using Lagrangian Mechanics! History of the Kapitza Pendulum: en.wikipedia.org/wiki/Kapitza's_pendulum Real-life Kapitza Pendulum: ruclips.net/video/GgYABmG_bto/видео.html
Model and Simulate Elastic Pendulum in Python (Lagrangian Mechanics)
Просмотров 4,5 тыс.Год назад
Code (Github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Elastic Pendulum Learn how to model, simulate, and animate the elastic pendulum in Python. Video Chapters 0:00 - Intro 0:14 - Defining Variables 1:00 - Defining the Lagrangian 3:13 - Equations of motion 5:37 - Simulation 8:04 - Animation 13:37 - What's Next!
MATLAB Live Script Won't Open? Easy 3 Minute Fix!
Просмотров 209Год назад
I use MATLAB live scripts for research all of the time, but every now and then they won't open. Before I discovered this trick, this meant my hard work and effort was wasted, but not anymore! Note that before you edit any file, you should always make a back up of it somewhere on your machine.
Animate Spring Mass with Affine Transformations in Python
Просмотров 6 тыс.Год назад
Code (Github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Spring Mass Learn how to animate a spring mass system using affine transformations in Python. Video Chapters 0:00 - Intro 0:17 - Stretching a Spring 1:02 - Linear Transformations 1:19 - Affine Transformations 2:21 - Python Code 2:59 - What's Next!
Model + Simulate Spring Mass in Python
Просмотров 66 тыс.2 года назад
Code (Github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Spring Mass Learn how to model and simulate a spring mass system. Create and animate plots of x, x_dot, and create a phase diagram. Video Chapters 0:00 - Intro 0:10 - Model System by Hand 1:16 - Model System w/ Python 2:00 - Simulation 2:44 - Time Domain Plot 3:13 - Phase Diagram 3:44 - Model System with Friction ...
Simulate + Animate Simple Pendulum in Python
Просмотров 13 тыс.2 года назад
Code (Github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Simple Pendulum Learn how to simulate and animate a pendulum, and make a variety of different plots: - Theta, Theta dot vs Time - Theta vs Theta dot (Phase Diagram) - Animate a Pendulum - Multiple Animations - Custom matplotlib colors Video Chapters 0:00 - Intro 0:25 - Simulation 2:17 - Time Domain Plot 3:20 - Ani...
Simple Pendulum with Python + Sympy
Просмотров 3,3 тыс.2 года назад
Learn how to solve the equations of motion for a simple pendulum using the sympy library. Code (Github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Simple Pendulum Derive the equations of motion by hand: ruclips.net/video/0PUrSlr6XCk/видео.html. Sympy Library Download: docs.sympy.org/latest/install.html#installation. Video Chapters 0:00 - Intro 0:10 - Finding the Lagrang...
Simple Pendulum without Forces? Lagrangian Mechanics 101
Просмотров 3,1 тыс.2 года назад
Learn how to derive the equations of motion for a simple pendulum using Lagrangian Mechanics by hand. Code (Github): github.com/logdog/RUclips/tree/main/Lagrangian Mechanics in Python/Simple Pendulum Derive the equations of motion in Python: ruclips.net/video/ZCzIoaGls4g/видео.html Simulate and Animate the Pendulum: ruclips.net/video/WNJJuSWfuTY/видео.html Video Chapters 0:00 - Intro 0:10 - Fin...
Lagrangian Mechanics 101 with Python: An Overview
Просмотров 4,2 тыс.2 года назад
An overview of Lagrangian Mechanics, including a brief example of a simple pendulum with massless rod.
Inverted Pendulum P Controller Test 2 - October 11, 2022
Просмотров 2892 года назад
Implemented microstepping to create a smoother action and reduce jerkiness at low speed. This alone increased the run time of the pendulum, however we still see that over time the cart speeds up and eventually either cannot move fast enough or far enough to stabilize the pendulum. Next steps: - increase encoder resolution from 1200 PPR to 2400 PPR - adding position estimation and angular veloci...
Linear Systems: Gramian Matrix and W test
Просмотров 1,2 тыс.2 года назад
A proof of why the W-test works for testing the controllability of a linear time-varying system. Based upon the notes in Wilson J. Rugh's LINEAR SYSTEM THEORY second edition.
Project 1 Walkthrough using Simulation
Просмотров 1393 года назад
Project 1 Walkthrough using Simulation
Pretty nice
This step by step tutorial is super helpful. Thank you, Logan!
Awesome video! How are you outputting the latex?
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.
@@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.
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
Cool video.
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...
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
@@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!
One more question pls. How does python know if you are doing differentiation or partial differentiation because even when you are coding for partial differentiation you still write diff()
Great question! I don't think that it really matters in Python whether you are doing a full derivative or a partial derivative because they both use diff(). I just make sure to explicitly declare that my derivatives are with respect to time
@@logandihel Thanks bro
Really nice video. Thank you. In the first line you wrote "from sympy import *". What is *?
* simply means to import everything (functions, classes, variables) from the sympy library into the current namespace. This way you don't need to use the module name (sympy) as a prefix: symbols() instead of sympy.symbols()
Really good video. I was confused on the ODE stuff and why you used matrix notation and where the theta dot came from at then end in the matrix
I used the matrix notation (state space model) because that is the gold standard in nonlinear system theory, and ode solvers in python/matlab expect that format
@@logandihel Thanks man
you do not need to copy from the symbolic to numeric there is a function call "smp.lambdify()" that you can transfer from symbolic to numeric
Another question is why on the diagram of speed versus time the speed does not tend to zero, it remains somewhere around 0.5?
The velocity tends to zero when friction is added. Otherwise, no energy is lost and the velocity is sinusoidal
How to increase the oscillation time so that the pendulum swings to a complete stop?
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
@@logandihel I changed the value but the duration of the GIF image remained the same. What can be done?
@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
@@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
@@olsea1229 change t_eval to np.linspace(0,30,30*30)
❤❤✔✔
Real Hero. Thanks
This is art....THANK YOU from sudan,africa
Thanks for the great work!
on phase diagram i've got a deprecation warning: MatplotlibDeprecationWarning: Setting data with a non sequence type is deprecated since 3.7 and will be remove two minor releases later phase_dot.set_data(theta_deg[i], theta_dot_deg[i]) <==solved by putting some brackets[ ] : phase_dot.set_data([theta_deg[i]], [theta_dot_deg[i]]), on both lines.
i've got an small issue with the snippet: animate theta, theta_dot vs time where the animation would render(.mp4) but the graph in the browser(notebook, colab) would be empty, solved by putting plt.show() after anim.save(...) line
Good catch! I haven't tried running in notebook collab before - I just use vscode with Jupter extension. Thanks for sharing
Incredible!
Your videos are stunning
Beautiful example 🤙🏻
You need a better microphone.
As someone looking into studying Computational Science and Engineering, this is some incredible stuff, thank you
Wish I had find this channel sooner.
Good day. Your "simple" pendulum is in fact a "double" pendulum. Thank you.
"Simple" in the sense that the pendulums are point masses and not rigid bodies with rotational inertia
Sorry, that is not the usual definition of a simple pendulum.
You're correct. A simple pendulum usually refers to a linear model of a single point mass pendulum. I just wanted to differentiate between point masses versus rigid bodies, and the phrase "point-mass double pendulum" was too long to fit on the screen!
@@logandihel Ok, no problem, thank you for your videos.
You cannot call this a simulation, this is only a visual representation of the solution of a problem analitically solved...
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.
Amazing
spectacular video
Hello Logan, extremely informative video mate. Could you please also make a tutorial om how to do mathematical modeling using Python. RUclips just doesn’t have a brief tutorials for mathematical modeling and we would appreciate if there is one for some of us learners.
Could you give an example of what sort of mathematical models you are looking for? Most of the content I've made so far is for modeling nonlinear dynamical systems.
@@logandihel Thank you so much for your kind reply. The modelling like SIER, Logistics growth, behaviour of functions with respect to different parameters, etc would be nice to know. If it is out of scope for your channel, I totally understand.
I think the topic of bifurcations with respect to varying parameters for 2-dimensional nonlinear systems would be a good fit for this channel. Thanks for the ideas!
Hi logan...pls tell how did you made that motion picture of oscillating spring mass system
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.
Is this what we study physics for
Why is positive x towards the ground and negative x towards the ceiling?
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
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.
@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
I have no idea why the youtube algorithm recommended me this vid. While I enjoyed calculus and differential equations to a certain degree, I got off the math wagon at matrices and I abhor any form of coding with a passion. While thostensibly
Well, I hope you like the animations at the end!
Gotta say this video was an absolute blast to watch. I am someone who works with this kind of tooling all the time, but the plots and the code were both so clean. I can't wait to see more from you.
It would be nicer to explain what are the difference between the two types before explaining the mats for them.
(in the introduction)
Hi guys! I noticed one small error in my derivation 😬The last term in the kinetic energy at [6:55] should be "1/2 * I_2 * (theta_1_dot + theta_2_dot)^2". The angular velocity (theta_1_dot + theta_2_dot) represents the total rotational velocity of the second pendulum relative to the {s} frame. We always need to express our energy in terms of the {s} frame for the Euler-Lagrange equation to work. I will go ahead an update all of the code on my GitHub so your simulations are correct :) Also, I provided the full (correct) derivations of the mathematics on my GitHub, so be sure to check it out!
Well done. Pretty and interesting simulation. Thanks!
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
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!
@@logandihel Thanks for responding, I'll surely try it
Thank you for all your videos. I appreciate a lot. could you do the spring-mass model for running ? It's a bit similar to this but i cannot really animate it
Spring mass system for running? I'm not familiar with this system. Could you share a link?
@@logandihel Of course ! Here is the link : www.cs.cmu.edu/~hgeyer/Teaching/R16-899B/Papers/Blickhan89JBiom.pdf (thanks a lot, from France !)
@@Arthur-e8x4n Same here bruh 👍 🇨🇵 (ça bosse le tipe)
Just saw this notification today! School is busy right now, but ill see what I can do
I would like to thank you for all your videos. Could you make the spring-mass model for running ? It's a bit similar to this but i can' really simulate it
dayum
Is this like math or something i dont understand
Yes, there's some math involved, but you can understand it! Check out the other videos in this playlist to learn where these equations come from 💪
my real question is... is this data science? data analytics? whats the main field for the videos --- im making animations with python and matplotlib animations but they are only random numbers using np.linspace... etc nothing more... thats why im asking brother. @@logandihel
LOGAN IS ALIVE!!!!!!!!!!!!!!!!! I guess the goat sacrifive worked, thks BAal
Very low volume
Hi, can you use statespace method next time , for any other system, I could see you use diff equation, which I could follow up easily, but for controls part, I am dealing with state space matrices, thanks for the content , very intuitive
You can convert any ordinary differential equation into a state space model. You just need to choose your state variables as theta, theta_dot, ell, and ell_dot
@@logandihel yeah doing that now, thanks for the info
hi logan, I have a doubt ,I am trying to solve a nonlinear differential equation, I am looking for closed solution as a function of time , I couldn't solve with dsolve in sympy, raising error->" cannot be solved by the factorable group method " using scipy integrate gives me the array of t and q(differential parameter) values, I want to simulate the model for t-> tends to infinity, how can I do that?
You can very rarely solve a nonlinear system. Most of the time it is actually impossible (like for the pendulum). You need to simulate starting with some initial conditions
Great 👍 video , make video like this
brilliant; too bad channel seems bad, hope you'll make more
awesome i was using matlab but this is useful too
Assuming total length to be L, is the Lcos theta pointing down and Lsin theta pointing towards right? So y is negatiive and x is positive?
Yes, but only because we defined the origin to be at the pivot, with the x axis to the right and the y axis vertical, and theta being counterclockwise from the downward position. So at resting position, x is zero and y is negative. At 0 < theta < pi/2, x >0 and y<0
Funny ending.