Verlet Integration
Вставка
- Опубліковано 6 чер 2024
- Here's a video describing a simple method to solve Newton's equations of motion. More info can be found here: www.algorithm-archive.org/cha...
If you want to contribute, here's the github repo: github.com/algorithm-archivis...
The music came from Josh Woodward (sped up 1.5 times):
www.joshwoodward.com/
Please feel free to follow me on Twitter:
/ leiosos
Twitch (where I do all the simulations):
/ leioslabs
or Github:
github.com/leios
Also, discord:
/ discord
Also: Special thanks to butt4cak3 for the thumbnail! - Наука та технологія
"no one cares about our B term because it's a JERK"
You and you damned witticisms. I love the awesome pun!
Glad someone got it!
I find that kind of humour very derivative.
what does the B term stands for? I know the position formula but never saw a B occur in it
@@Gplaysmc third order derivative of displacement with respect to time, also known as 'jerk'.
I was about to comment about that. Absolutely fabulous.
Great video! I am a computational physicist and want to mention one really cool and important reason we prefer Verlet over more complex integrators. The Verlet integrator is both symplectic and time reversal invariant. This means that if you run it and then run it in reverse, it will return the system to the original starting point. Because of this, the total energy of the simulated system will be conserved, which is important for physically realistic dynamics. So, even though another algorithm, like Runge-Kutta, has smaller local errors than Verlet, it does not conserve the total energy and will produce less physical Dynamics.
Edit: I forgot to mention why being symplectic is important. Its because Newton's laws are symplectic and by using a symplectic integrator, we are guaranteed that our simulation will approach the true Newtonian solution. If you use an integrator that is time reversible but not symplectic, you will conserve an energy. But, that energy will not converge to the true energy as you make your time step smaller.
amazing explanation
What does symplectic mean?
You just made my research part of my module look a lot better
Such an excellent comment
Great explanation! Thank you!
Doing some game dev with cable physics this video proved to be INCREDIBLE, thanks for the concise and fast explanation. Wish you had content back when I was in University.
Small nitpick that your + and t looks very similar on the blackboard
yeah, I noticed that while editing. I'll try to do better in the future.
Thanks Buttercak3 for helping with the thumbnail!
Here are the algorithms I am thinking about going through next:
* Barnes-Hut (galaxy sim)
* Mersenne Twister (prng)
* Euclidean Algorithm (greatest common divisor)
* Breadth-First Search (trees and stuff)
We gotta start out simple, but it'll build quickly, I think.
Thanks for watching and let me know what you think!
I'd love to code Barnes-Hut with Haskell :)
I added the vote to all the others on twitter. BFS still edges it out, so we'll go through that one first. It might be a good idea to do a tree algorithm first anyway.
Top level video and additional material. I've been doing some physics and orbital mechanics simulation in a game engine and this has helped a lot to clarify this method. Thanks!
I enjoyed learning about verlet integration; the video was concise and informative. My only criticism is that your 't' and '+' symbols are identical.
edit: I just realized a previous comment already criticized this, making my criticism redundant
Yeah, I noticed that in the editing. I'll try to do better with it in the future.
Yr probably the nicest person on the internet
IDK, but I always encounter great videos just 1 day before the exam :(
Great work sir, thank you for helping us.
I think It's just seconde order finite difference approximation of acceleration. I think this would give a good framework to study stability, accuracy and convergence and to compare the methodes (because euler and verlet would be just a subcase of finite differences approximation). It would also help implementing the methodes using matricies which is more efficient and systematic.
"No one likes the b term because it's a jerk..."
oh you didn't LMAO
Finally someone gets it!
Re the comments on handwriting glyphs: In programming editors the modern trend is to use color highlighting editors that can automatically give variables, functions, and operators different colors.
You are using white chalk on a black board, and your camera is locked down and stationary.
So, you could colorize the final result when you are done writing, by using overlay rectangles that change white to whatever. Then apply that set of overlays to the entire segment -- it will have no effect on the blank board and you will have the foresight not to wear white cuffs.
The result: magic colored chalk that syntax highlights as you write.
I actually tried something like this once, but the issue was that the "white" was not white enough from the chalk. I also tried using different color chalks, but they didn't show up on camera.
I'll try to find some better ways to do it, though!
integrate x^n times f(n) by parts to infinite series. obtain limit expression for when n = 0. Calculate high precision evaluations of the differentials of f at x, and the accelerate the series by S(S(S(n)) of say 9 terms. The result of the summation is one of a results for each application of S, and these can be considered to be another limit sum S(S(L(n))) and in turn S(L2(L(n))) providing the evaluation of the integral at one endpoint L3(L2(L(n))). As subtraction of endpoint integrals is the definite integral, the estimator is based on the precision of evaluation of the functional differentials of f.
Nice explaination. We also use this technique in theoretical chemistry :)
Yeah, it's used everywhere for when you need a rough approximation of kinematics.
In which programming language codes are written in algoruthm archive.?
best video of verlet i've seen and that i can understand, now i can do my tarea numérica (i think)
I saw "verlet intregration" on minecraft and I wasnt expecting this
Awesome video! Thank!
Okay where the b term comes from?? they miss mentioning that in my school
what about verlet integration in the context of molecular dynamics simulations
Nice article and video! As a PhD student who focuses on numerical integration techniques, I'd like to point out one misguided detail of your explanation : in the article you say that Verlet integration has an error in O(dt^4), whereas Velocity Verlet is in O(dt^2), so it's two orders worse. That's not quite the case: the consistency error of both methods has order 2. Sure enough, O(dt^4) and O(dt^2) are the error term in the equations you wrote ; but if you run both of them for a fixed duration, the results are of similar quality, with a final error in O(dt^2).
How come Verlet converges only in O(dt^2)? Because it is only consistent at order 2. The simple way to isolate the consistency error is write the Verlet update as (x(t+dt)-2x(t)+x(t-dt))/dt^2 = a(t) + O(dt^2). You then see that as dt tends to zero, the left hand term converges to x'', with an error of O(dt^2). So this method is indeed an approximation of x''(t) = a(t), and we says it is "consistent at order 2".
For Velocity Verlet it's a bit more complicated.
In practice you must be very careful if you want to maintain order 2 consistency: dealing with collisions will almost surely drop the consistency order to 1 (so the error is in O(dt)).
In fact, all the scripts in the article make an error in O(dt) due to the fact that they stop squarely on a time step when they detect the ball has touched the floor!
Interpolating this time value from a simple linear approximation of the solution would drop this error to O(dt^2), which is the best we can hope for.
In general, a higher order of consistency can be obtained easily using Runge-Kutta schemes.
If you also want the method to be unconditionally stable you can use e.g. Gauss integration schemes, but things get much more involved quickly.
0:15 Could you please give some references about these higher order terms that you will not use after a^2/2?
The equation you’re familiar with is specific to the case of uniform acceleration. Uniform acceleration is a safe assumption if one is considering situations that take place on or near the surface of a planet. But this video is about a situation where the distance from the bodies involved varies a great deal over time.
@@AdrianBoyko This is not what I am familiar with. I am familiar with infinite number of higher derivation terms.
I'm now confident I get what you mean, though. Thanks.
Here's a very pythonic (3.6 only) implementation that tests the time of a 5 meter drop and the distance of a 1 second drop.
def verlet_drop(pos, acc, dt, end_time=0, end_pos=0):
time, prev_pos = 0, 0
acc_factor = acc*dt*dt
running = lambda: (time < end_time if end_time!=0 else pos
Great! Thanks!
Using Java:
//Given Starting conditions
int initialPosition = 5; //in meters above ground
double gravitationalAcceleration = 9.81; //Gravitational acceleration in m/s²
//Wanted
double timeToHitTheGround; //Time to hit the ground in seconds
//Calculate time to hit the ground
timeToHitTheGround = Math.sqrt( 2*initialPosition/gravitationalAcceleration);
//Print solution
System.out.println("Time to hit the ground: ~ "+(int) timeToHitTheGround+"s"
+"
["+timeToHitTheGround+" seconds]");
This prints out:
Time to hit the ground: ~ 1s
[1.0096375546923044 seconds]
Great! Thanks for the submission!
wait, I should have specified that the submissions should be using the verlet method mentioned in the video... I added an example in c++ to the archive: leios.gitbooks.io/algorithm-archive/content/chapters/computational_physics/verlet.html
I'll be more clear in the future. Thanks again!
It pretty much works just by copying your code, with a bit of adjusting:
static void verlet(double pos, double acc, double dt){
// Note that we are using a temp variable for the previous position
double prev_pos, temp_pos, time;
prev_pos = pos;
time = 0;
while (pos > 0){
time += dt;
temp_pos = pos;
pos = pos*2 - prev_pos + acc * dt * dt;
prev_pos = temp_pos;
}
System.out.println(time);
}
// Simple function for stormer-verlet
static void stormer_verlet(double pos, double acc, double dt){
// Note that we are using a temp variable for the previous position
double prev_pos, temp_pos, time, vel;
prev_pos = pos;
vel = 0;
time = 0;
while (pos > 0){
time += dt;
temp_pos = pos;
pos = pos*2 - prev_pos + acc * dt * dt;
prev_pos = temp_pos;
// The acceleration is constant, so the velocity is straightforward
vel += acc*dt;
}
System.out.println(time);
}
// Simple function for velocity-verlet
static void velocity_verlet(double pos, double acc, double dt){
// Note that we are using a temp variable for the previous position
double time, vel;
vel = 0;
time = 0;
while (pos > 0){
time += dt;
pos += vel*dt + 0.5*acc * dt * dt;
vel += acc*dt;
}
System.out.println(time);
}
public static void main(String[] args) {
verlet(5.0, -10, 0.01);
stormer_verlet(5.0, -10, 0.01);
velocity_verlet(5.0, -10, 0.01);
}
But snake_case should be changed to camelCase I guess?
Yeah, we can change it to camel case. Thanks again!
what about potential energy ?
What program did you use?
We wrote it ourselves in OpenGL or Cairo.
def duration(height): if height == 5: return 1
please the website (or link) at 2:22
In the description: www.algorithm-archive.org/chapters/physics_solvers/verlet/verlet.html
Mom can we have v sauce?
No we have v sauce at home
V sauce at home:
Huh. So this channel is kind of a Minute Algorithms
In a way, yes.
Dude, your 't's and '+'s look identical
Draw the horizontal bar on the 't' first and draw the vertical line with a curve on the bottom
Thanks
No one cares about your b ten because it's a jerk! That was hilarious!
Finally someone gets it!
Well, "finally" seems a bit excessive; according to the post above this one, someone got it 6 months ago. :P
can someone direct me to the full kinematic equation, please?
I wrote it down with an additional term. For the most part, it is a Taylor series expansion about a point.
oh yeah. why didn't i think about that? thank you
what is b?
Position over time is velocity. Velocity over time is acceleration. Acceleration over time is b, the "jerk" term.
Damn, that was fast, thanks! Bingewatching your videos and i'm loving them!
I'm glad you like the content! I do my best to respond to all comments as fast as I can.
Great video but your similarity to Ramsay Bolton is frightening :D
I think I'm in the wrong place
Is the educational level of this stuff too high for a just-graduated-from-highschool student like me? or am I just stupid?
You are definitely not too stupid.
"because of how straight forward this is"
hold up. That wasn't straight forward at all, I don't know what half of these terms mean so I didn't learn anything
b-b-beginner??
This one is hoping you know how to include s in a gitbook :)
With Scratch: scratch.mit.edu/projects/173039394/
I also had fun with Haskell:
github.com/jiegillet/Arcane-Algorithm-Archive/tree/master/Verlet
nerd
meow
😦