So in the previous lecture, we had our own encounter, we had chosen our starting we lost teeth such
that our lips almost hits the Moon.
And if we then don't do anything, we will get thrown out of the trajectory around the Earth and close
to the Moon, and we will then just circle around the sun.
This is, of course, really nice if you want to leave Earth and want to save a bit of fuel, but it
can also be used to break at this point and then to go on a trajectory around the Moon.
And this is what we want to do now.
So the task for this very special lecture is to set up a space program where we will encounter an orbit
around the Moon and we want to plan ahead what we want to do with our engine, at which point of time.
So.
For this, we have to modify our equations of motion, but only a single one.
Only the motion of the spaceship, of course.
And also we have the same thing as before and just add a single term here.
So I told you that I want to break and breaking in space is not really possible.
Can I just push a brake pedal?
Because, yeah, you have no friction.
So what you have to do is you have to accelerate it into the opposite direction.
You have to use an engine, some booster along the opposite direction and with opposite direction,
I mean opposite direction with respect to the relative velocity of our spaceship compared to the Moon,
because we want to enter an orbit around the Moon.
So we have to break along the opposite direction of the velocity of our spaceship relative to the velocity
of the Moon.
Sounds difficult, but if you think about it, it's not that difficult.
You could just say, OK, here we have our distance spaceship to the Moon.
And at this point you look down to the moon, you see your velocity and you push the the engine and
you accelerate along the opposite direction along which you are moving.
OK.
So this will be the term just some, some some prefecture times the direction.
So the direction is really what's important here.
And the prefecture will be, of course, time dependent because we don't want to have this false the
whole time.
We just want to have it when our engine is on.
And this is really what we want to do here.
We have times where the engine is on and we have times where the engine is off.
So the first question would be how can you program a function which is on and off?
Of course, we could just take our F40 and use an if statement.
And if our time is in a specified frame, then we use the term and if not, then we don't use the term.
But it's always better to avoid if statements and mathematicians use, in this case, the so-called
heavy side function.
Let me show you how this works.
This is basically just a step function.
So I start with Telus just for the plotting and pitot in space.
Oops.
Sorry, typos
and alan space goes from, I don't know, it doesn't matter here zero to 100.
And what we want to plot is for the x axis to T list the time and then for the wireless R plot to have
a site function and p dot.
Have you sites?
We see it's an important function.
It's implemented in NumPy, so the guy who was named heavy side.
So that's why it's not with a y.
What would an AI and he rewrite it rewrite T list minus some shift, for example.
Twenty five.
And then we have to write here.
A number could read zero one.
That doesn't really matter for us.
If you want to know the details, you can look that description, but it doesn't matter.
We should just write one here.
This is what matters for us.
And what happens then is it's a step function that zero for arguments that are smaller than this number,
and it is one for arguments that are larger than this lumber.
So now we can subtract another heavy side function with a different shift, for example.
75.
And so then we get such such a step, step up, step down.
And it is one only between these two arguments and this is exactly what we want.
We could now, of course, write this here in brackets and multiply some factor, like 100.
And then you see, it's zero all the time and then only in this range here it's a hundreds.
So this is what we will add to our EV ODI.
So let me scroll back up to the notebook and copy the Odyssey and a few plots, and then I'll be back
in a second and then we modify all of these commands and then we go to approach this moon orbit.
So here I'm back.
We have just discussed the equation of motion and the heavy side function.
And now we want to add this term he with the heavy side function to our F ODI, which I have copied
from above.
And then also I have copied here.
This is code that we have written before with the starting conditions and the solution by integrated
solve underscore IVP and the plots.
And then here, another plot spaceship tune that's all just copied from above.
OK, so we will leave everything as it is.
We will just use here the same starting velocity that we had before.
One point thirty four times we orbit and then we can.
Basically rallied as soon as we have out a Tier two additional term to the equation, so I will right
here.
This factor, I will call be off a break and then we have to program here this direction, which is
basically this one.
The velocity of the space ship with respect to the velocity of the moon and then divides by the known.
All right.
So, all right.
Minus the art times before minus the three divided by and pitot taught Lynn Rock tot mom.
And then once again, we three minus three or four or vice versa doesn't matter in this case.
What do you have to be careful here?
You have to write me four minus three.
Otherwise, it will be an acceleration, which is not what you want.
We want to really break.
OK, so this is the new term here.
Be our times the distance of two vectors of the velocities divided by the norm of this distance.
And now we must, of course, program the hour before and we leave three.
So the three is ah, and we could just take this one plus 12 plus 12.
And B, four, nine plus 12 and 12 plus 12, you could, of course, just calculate it, but I just
want to show you this just shift of this index by 12th because we have 12 variables.
And yeah, the first 12 are the positions and the other 12 are the velocities.
So now I can find the brake function.
So this will be B art is and now we need an amplitude.
And you have to be honest, I spend like maybe half an hour trying a bit of a parameters.
And this is what I came up with.
So I have 27 million so times 10 to the power of six.
This will be Newton, 27 Newton or 27 Mega Newton.
And we apply this force for a certain time and this we will construct by using the heavy side function,
of course.
So I will just copy this.
We will, of course, use the same type of command here.
This was our amplitude.
Sorry, here we of course, have the exponent 10 to the power of six.
And now we have here.
Do you have your site function?
OK, so we don't have to list anymore, but tea, which is important to change.
So now for the first time, our differential equation is actually T dependent.
But that's no problem because it was it could have been Tiede dependent all the time.
And now we must subtract here the starting time and the end time, and we see here that we approach
the Moon approximately after 0.11 years.
So I will use the engine approximately at this point of time.
So let me copy this time factor here and then multiply it by zero point one one, which will then be
zero point one one years.
So here's where it goes.
T minus zero point one one times.
Then this time factor and then this heavy side function will be the point where the engine is turned
off again.
And I don't know, I just take zero point twelve.
So basically, we have the engine on four one hundredths of a year, which is, of course not how it
would be done.
In reality, they're they would really just boost for a few, I don't know, few seconds.
Few minutes.
I don't know.
I'm not an astrophysicist, but definitely not for one hundredth of a year, which is almost four days.
But anyway, this is what I just found to work.
So we boost here for four days with a force of twenty seven Meghan Newton divided by the mass of the
object, of course.
So this is here an acceleration then, and this is our heavy side function.
So this means the engine is turned on just in this range from zero one two zero point twelve years.
OK, and if I did not make a mistake, then I think it should work now.
Let's see.
I run this, run this and run this all three cells.
And I think, no, it will take a bit of time.
This one worked, but now it's running here.
Maybe we have to think for how long we want to run.
Actually, I want to run only for 0.3 years as before.
So before we look, let me rerun this zero point three and this is what we get.
So first of all, let's look again at the trajectory without the engine.
This was this oval shape.
And then once we encountered the moon, we leave it, which we also saw here at the distance plot.
And now with the engine turned on at this short amount of time, we get such a trajectory.
First, the Oval and then you see it moves somewhere close to the trajectory of the Moon.
And you see this is what happens when you plot the distance spaceship moon.
It goes first on this funky oval shape and then here and 0.11.
Maybe here to here we turn on the engine and we break the spaceship a whole lot.
And then you see, this is what we end up with.
So that's pretty cool, I think.
It's not the last thing that I want to show you is a plot similar to this one where we have plotted
the trajectory of the spaceship with respect to the Earth, where the Earth was fixed here.
So as well as with respect to Earth.
So I copied this code here and adapted it.
And instead, now we are in the reference frame of the Moon.
So we have X and Y with respect to the Moon and the X and Y limits are a bit zoomed in, of course,
because the radius of the trajectory is, of course, pretty, pretty small here.
As you can see, it's oscillating pretty closely around the Moon compared to the previous rotation around
the Earth.
And here I changed the indices.
So previously we had here three and four for the Earth, and now it's six and seven for the Moon and
you see already the results.
This is what we get.
We have a point where we enter the vicinity of the Moon, which is positioned here at zero zero and
then we oscillate on the rather strange looking trajectory.
So it looks pretty funny, actually very, very oval.
And also, since these points here are quite far still from the position of the Moon, it will still
very strongly feel the influence of the Earth.
So this is why it will not move on the same oval, the whole time of why it will be shifted around the
whole time.
So we could fix this if we want to make our orbits here are circular.
And if we would make it pretty small, this we could achieve, for example, by breaking another time
when we are here, so we could now add here in our plots, for example, when we are here at this point
or also maybe at this point we could break another time so we could change here on a break function
and add another two heavy side functions and another brake maneuver.
But I want to leave it as it is, even though it looks a bit funny, it is a trajectory and an orbit
around the Moon, even though it's not very, very stable.
I think if you would simulate this for several years, you would eventually leave the Moon once again.
But you could easily avoid this in reality by just breaking another time, as I just told you.
And we could go even one step further by breaking at this point, even stronger.
And then we would hit the Moon, we would crash into the Moon.
So now it's really just a matter of optimizing the parameters or adding more break maneuvers and making
everything a bit more complicated.
And then you can really achieve everything we want.
So if you want to do it, that's nice exercise to play a bit more with the code and the parameters.
But eventually, everything comes down to using the integrator to solve IBP, and it comes also down
to programming this differential equation here.
And for this one, we have a four body problem.
We had 12 plus 12 equations, 12 equations for the coordinates of the four objects and 12 equations
for the velocities.
So that's the end of this lecture about the three body problem, which we have actually turned into
a full body problem.
And we have learned quite a lot about in America and also about the physics, especially.
I think this is a very nice lecture because we have achieved this moon orbit, we have achieved the
surface K by a moon and counter.
We have achieved the regular purpose escape and we have achieved a circular and an overall trajectory
around the Earth.