PK iAU
( Problem_Set_2/01-Symplectic_Euler.en.srt1
00:00:00,000 --> 00:00:04,000
Now we come to the first problem of Unit 2. This time we're still dealing with orbits.
2
00:00:04,000 --> 00:00:07,000
We have a pendulum and we want to create expressions
3
00:00:07,000 --> 00:00:09,000
for the position, velocity, and acceleration.
4
00:00:09,000 --> 00:00:11,000
As always, we've given you some code to help you out.
5
00:00:11,000 --> 00:00:14,000
Here you can see the time set, the magnitude of the acceleration due to gravity,
6
00:00:14,000 --> 00:00:17,000
and the length of the pendulum, which is just the length of the
7
00:00:17,000 --> 00:00:20,000
string to which the bulb of the pendulum is attached.
8
00:00:20,000 --> 00:00:24,000
What we're asking you to do is to first fill in this definition of the acceleration of the pendulum
9
00:00:24,000 --> 00:00:27,000
showing how it depends on the position of the weight.
10
00:00:27,000 --> 00:00:30,000
Now if you think about the way that a pendulum swings, you can imagine
11
00:00:30,000 --> 00:00:32,000
that if we extend the trajectory, we would get a circle.
12
00:00:32,000 --> 00:00:35,000
So position is the length of this curve path.
13
00:00:35,000 --> 00:00:39,000
The next thing that you need to do is to fill in this function called symplectic Euler
14
00:00:39,000 --> 00:00:45,000
in which logically you will use symplectic Euler method to calculate both distance and velocity.
15
00:00:45,000 --> 00:00:49,000
To help you out a little bit, here is a refresher on what the symplectic Euler method says.
16
00:00:49,000 --> 00:00:52,000
Another important piece of information if you're not super-comfortable with physics stuff
17
00:00:52,000 --> 00:00:57,000
is Newton's second law right here showing the relationship between force, mass, acceleration.
18
00:00:57,000 --> 00:00:59,000
So looking back at our code, you can see that we've created
19
00:00:59,000 --> 00:01:03,000
empty arrays for you--for position and for velocity.
20
00:01:03,000 --> 00:01:07,000
It's up to you to fill these arrays in including the initial conditions.
21
00:01:07,000 --> 00:01:12,000
Remember you'll need to initialize x and v where x is zero and v is zero
22
00:01:12,000 --> 00:01:15,000
equals something that you're going to figure out.
23
00:01:15,000 --> 00:01:17,000
I'm going to give you a few hints though--you can see that we've created
24
00:01:17,000 --> 00:01:21,000
this constant called numinitial condition and set it to equal to 50.
25
00:01:21,000 --> 00:01:25,000
What you're really doing overall in this problem is looking at 50 different pendulums
26
00:01:25,000 --> 00:01:30,000
which each have different initial values for x and v, and to give you a visual of what this looks like,
27
00:01:30,000 --> 00:01:33,000
I'm going to show you the final plot that you'll get with this program.
28
00:01:33,000 --> 00:01:38,000
So here's the set of graph that you should get as your final result if the program is working correctly.
29
00:01:38,000 --> 00:01:42,000
You're going to ignore these top two graphs for now. Let's focus on this bottom plot.
30
00:01:42,000 --> 00:01:47,000
This is showing velocity on the vertical axis and position on the horizontal axis.
31
00:01:47,000 --> 00:01:52,000
If we look at the top two graphs, we can see that this green set of points right here
32
00:01:52,000 --> 00:01:55,000
corresponds to what's happening at time zero.
33
00:01:55,000 --> 00:02:00,000
Since green ellipse down here is showing the set of initial conditions
34
00:02:00,000 --> 00:02:03,000
for the 50 different pendulums that we're looking at.
35
00:02:03,000 --> 00:02:06,000
This green ellipse is kind of like a snap shot of what's happening
36
00:02:06,000 --> 00:02:09,000
to all these different pendulums at time zero.
37
00:02:09,000 --> 00:02:11,000
The way that I want you to figure out how to set
38
00:02:11,000 --> 00:02:16,000
the values for each pendulum for x and for v is just think about this ellipse.
39
00:02:16,000 --> 00:02:20,000
Now in Unit 1 you learned about orbits and you'll actually be able to use
40
00:02:20,000 --> 00:02:24,000
some of that knowledge in this problem knowing that this green shape is an ellipse.
41
00:02:24,000 --> 00:02:29,000
You can see that its major axis right here lies along the line v=0
42
00:02:29,000 --> 00:02:33,000
and its minor axis lies along this line x=2.
43
00:02:33,000 --> 00:02:37,000
Now the half length of the major axis is 0.25
44
00:02:37,000 --> 00:02:40,000
so I guess actually it don't looks like the major axis here.
45
00:02:40,000 --> 00:02:47,000
It's really the minor axis if these two sets of axes had the same scales applied to them.
46
00:02:47,000 --> 00:02:52,000
Either way, this rightmost point on ellipse corresponds to x=2.25
47
00:02:52,000 --> 00:02:56,000
and the leftmost point corresponds to x=1.75.
48
00:02:56,000 --> 00:03:01,000
In terms of v, we have values ranging from -2 down here to 2 up here.
49
00:03:01,000 --> 00:03:07,000
So think about what equations for x and v you'll need to create an ellipse with these dimensions.
50
00:03:07,000 --> 00:03:10,000
That would be how you set the initial conditions for x and v.
51
00:03:10,000 --> 99:59:59,000
I think this is a very interesting problem so I hope you enjoy doing it. Good luck.
PK iAϩ$ 1 Problem_Set_2/02-Symplectic_Euler_Solution.en.srt1
00:00:00,000 --> 00:00:05,000
Let's go over the solution to this problem starting with the definition of the acceleration function.
2
00:00:05,000 --> 00:00:07,000
We know the acceleration due to gravity points downward.
3
00:00:07,000 --> 00:00:10,000
So let's put this factor into two components.
4
00:00:10,000 --> 00:00:14,000
We have one component right here that is parallel to the string of the pendulum
5
00:00:14,000 --> 00:00:17,000
and another component that is perpendicular to this green one.
6
00:00:17,000 --> 00:00:22,000
Now we know that the acceleration in this direction is going to be exactly cancelled out
7
00:00:22,000 --> 00:00:25,000
by the acceleration due to the tension in the rope.
8
00:00:25,000 --> 00:00:28,000
So that means that the acceleration we're looking for is really just this pink component,
9
00:00:28,000 --> 00:00:32,000
which any point along the path is going to be tangent to the trajectory.
10
00:00:32,000 --> 00:00:36,000
Now if we call this angle θ right here, we can figure out the length of this pink component
11
00:00:36,000 --> 00:00:42,000
by just saying that it is equal to length of the resultant vector times the sine of θ.
12
00:00:42,000 --> 00:00:47,000
The θ down here is actually exactly equal to θ in the diagram of the pendulum itself.
13
00:00:47,000 --> 00:00:50,000
So that means to figure out the length of this component,
14
00:00:50,000 --> 00:00:53,000
we can use information that we already know about this larger diagram.
15
00:00:53,000 --> 00:00:58,000
Since position is just the arc link right here of this imaginary circle,
16
00:00:58,000 --> 00:01:02,000
then the measure of that angle in radiant is going to be equal to the length of the arc
17
00:01:02,000 --> 00:01:06,000
that it corresponds to divided by the radius of that circle.
18
00:01:06,000 --> 00:01:13,000
So that means that in our case, θ is equal to arc length over radius or position over length.
19
00:01:13,000 --> 00:01:16,000
So since θ equals position over length and we want the sine of θ,
20
00:01:16,000 --> 00:01:21,000
we fill in our definition for acceleration as -g or negative
21
00:01:21,000 --> 00:01:26,000
magnitude of the acceleration due to gravity times sine of the position over length.
22
00:01:26,000 --> 00:01:29,000
Okay, moving on towards symplectic Euler function.
23
00:01:29,000 --> 00:01:32,000
We have to fill in this for loop with the input numinitial conditions.
24
00:01:32,000 --> 00:01:39,000
As I said in the InterVideo of the problem, we wanted the initial x to vary from 1.75 to 2.25
25
00:01:39,000 --> 00:01:42,000
and the initial v to vary from -2 to 2
26
00:01:42,000 --> 00:01:46,000
corresponding to the coordinates of every point along that green circle that I'd showed you.
27
00:01:46,000 --> 00:01:49,000
Now a convenient way to make a variable cycle through values that are symmetric
28
00:01:49,000 --> 00:01:52,000
about an equilibrium value is to use sine or cosine.
29
00:01:52,000 --> 00:01:54,000
So we're going to keep that in mind.
30
00:01:54,000 --> 00:01:58,000
Now as you learn from the circular orbit problem of Unit 1, if we consider any point
31
00:01:58,000 --> 00:02:04,000
along the circumference of the circle, then we can define an angle that corresponds to that point.
32
00:02:04,000 --> 00:02:06,000
These are coming from right here as a zero radian mark.
33
00:02:06,000 --> 00:02:12,000
You can write the coordinates of this point then as the radius of the circle times the cosine of the angle.
34
00:02:12,000 --> 00:02:15,000
That's for the horizontal component and for the vertical component,
35
00:02:15,000 --> 00:02:18,000
we get the radius times the sine of the angle.
36
00:02:18,000 --> 00:02:23,000
In the phase based plot that I showed you in the InterVideo, we saw that position lying along
37
00:02:23,000 --> 00:02:26,000
the horizontal axis and velocity lying along the vertical axis.
38
00:02:26,000 --> 00:02:32,000
So we wanted to plot the coordinates of the points on that green circle--the initial condition circle
39
00:02:32,000 --> 00:02:36,000
where the position is going to correspond to cosine and the velocity is going to use sine.
40
00:02:36,000 --> 00:02:40,000
Now I created a variable called phi. You could pick any name you want I guess.
41
00:02:40,000 --> 00:02:44,000
And phi effectively split the circle into 49 segments
42
00:02:44,000 --> 00:02:49,000
by marking out 50 different points along the circumference.
43
00:02:49,000 --> 00:02:54,000
So every time I increases by one, we're going to step to the next point along the circumference.
44
00:02:54,000 --> 00:03:00,000
Since as we saw in the phase base plot, we have a complete circle of green points.
45
00:03:00,000 --> 00:03:05,000
The x values of those green points vary like this with 2 as the middle value
46
00:03:05,000 --> 00:03:07,000
and the v coordinates vary like that.
47
00:03:07,000 --> 00:03:10,000
You noticed that the amplitude in either case corresponds to the
48
00:03:10,000 --> 00:03:13,000
half link of the green shape in that direction.
49
00:03:13,000 --> 00:03:18,000
So actually we have in a phase base plot is an ellipse for that set of initial conditions.
50
00:03:18,000 --> 00:03:22,000
Now that we have our starting additions figured out, we can finally use the symplectic Euler method
51
00:03:22,000 --> 00:03:25,000
to proximate the values with x and v at later sets.
52
00:03:25,000 --> 00:03:31,000
This code right here is just a direct transition pretty much of the equations that I showed you earlier.
53
00:03:31,000 --> 00:03:33,000
Now let's go back to looking at the plot that we get things plugged in
54
00:03:33,000 --> 00:03:36,000
but first let's look at our top two plots.
55
00:03:36,000 --> 00:03:40,000
The horizontal axis in both of them represents time measured in seconds.
56
00:03:40,000 --> 00:03:42,000
The vertical axis in the top one is x measured in meters
57
00:03:42,000 --> 00:03:45,000
and here it is v measured in meters per second.
58
00:03:45,000 --> 00:03:52,000
So you can see that our initial values of x go from 1.5 to 2.25 and v from -2 to 2.
59
00:03:52,000 --> 00:03:55,000
So that corresponds to this green ellipse right here.
60
00:03:55,000 --> 00:03:58,000
The most important thing to notice about this bottom graph, which like I said earlier represents
61
00:03:58,000 --> 00:04:04,000
phase base is that if we look closely at each one of these ellipses they all have the same area.
62
00:04:04,000 --> 00:04:06,000
Now let's look at the shapes that we have down here in this bottom graph.
63
00:04:06,000 --> 00:04:12,000
If you look closely and do a bit of calculating, you'll notice that all these different color shapes
64
00:04:12,000 --> 00:04:16,000
have the same exact area even though they are well shaped very differently.
65
00:04:16,000 --> 00:04:21,000
This is a great example of how phase base is conserve in the system where energy is conserve.
66
00:04:21,000 --> 00:04:24,000
Now the fact that its conservation principle holds in this diagram
67
00:04:24,000 --> 00:04:30,000
shows how the symplectic Euler method improve upon the accuracy of the forward Euler method.
68
00:04:30,000 --> 00:04:34,000
When the forward Euler method is used, it often result in the energy suddenly increasing.
69
00:04:34,000 --> 00:04:38,000
So it means that the area of each of these shapes down here will get progressively bigger.
70
00:04:38,000 --> 00:04:42,000
Symplectic Euler method, however, confirms much better the equations of motion in physics,
71
00:04:42,000 --> 99:59:59,000
It never reflects exactly radical predictions more accurately. Great job with the first problem in Unit 2.
PK iAWXB. . # Problem_Set_2/03-Safe_Return.en.srt1
00:00:00,000 --> 00:00:02,640
For this problem, we're about the claim the spaceships.
2
00:00:02,640 --> 00:00:07,520
Actually, we're dealing with the Apollo 13 mission. We should go from 1970.
3
00:00:07,520 --> 00:00:11,090
They were supposed to take astronauts from the earth and land them on the moon.
4
00:00:11,090 --> 00:00:14,080
However, at some point during the trip, they encountered a problem
5
00:00:14,080 --> 00:00:18,300
with one of their oxygen tanks and they had to abort their mission of landing on the moon
6
00:00:18,300 --> 00:00:21,970
and instead figure out how to get the crew back to the earth safely.
7
00:00:21,970 --> 00:00:24,960
Well in this problem, we're going to show how changing the velocity of the ship
8
00:00:24,960 --> 00:00:30,720
using boost rockets can change the trajectory of the ship to make it loop around the earth
9
00:00:30,720 --> 00:00:34,620
instead of landing on the moon and bring it back to where it started on the earth.
10
00:00:34,620 --> 00:00:38,550
This is definitely the most complex part that we've given you so far.
11
00:00:38,550 --> 00:00:41,390
So don't worry if it seems a little bit complicated at first.
12
00:00:41,390 --> 00:00:45,640
I'm going to help you out by continuing to chunk and giving you some hints.
13
00:00:45,640 --> 00:00:48,710
As always, we told you some important information to start up with.
14
00:00:48,710 --> 00:00:51,680
We have some information about the earth and gravity,
15
00:00:51,680 --> 00:00:55,410
and also significant information about the moon including the period of the moon
16
00:00:55,410 --> 00:00:58,260
or the time that it takes the moon to orbit around the earth.
17
00:00:58,260 --> 00:01:02,100
Well, once you have unique value that you see here is no initial angle
18
00:01:02,100 --> 00:01:05,630
and this is just the angle at which the moon is initially placed from the earth.
19
00:01:05,630 --> 00:01:10,240
This is a zero degree or 0 radian line and the angle between this line
20
00:01:10,240 --> 00:01:15,250
and the position vector of the moon is equal to moon initial angle.
21
00:01:15,250 --> 00:01:19,830
Let's have the total duration of the flight that we're considering in the times measured in meters
22
00:01:19,830 --> 00:01:23,710
which has resulted to local truncation air that we're going to allow the flight path to have.
23
00:01:23,710 --> 00:01:25,440
Well, Jorn mentioned this brief in the unit,
24
00:01:25,440 --> 00:01:27,970
and I'll give you little bit more explanation about it in a minute.
25
00:01:27,970 --> 00:01:32,260
We've laid out five tasks for you to complete to make it fundamental as a cohesive halt.
26
00:01:32,260 --> 00:01:35,050
The first one, which you can see right here, is to find
27
00:01:35,050 --> 00:01:37,240
the moon's position vector as a function of time.
28
00:01:37,240 --> 00:01:39,730
And here we're going to consider the earth is the origin here,
29
00:01:39,730 --> 00:01:44,030
as the position vector of the moon is just the vector from the earth to the moon.
30
00:01:44,030 --> 00:01:46,290
Now remember this is dependent on time.
31
00:01:46,290 --> 00:01:49,900
You can also say that the moon is going to move in counter clockwise around the earth
32
00:01:49,900 --> 00:01:52,550
or at least that's how it looks in this picture.
33
00:01:52,550 --> 00:01:54,050
Then the next thing that you need to figure out
34
00:01:54,050 --> 00:01:57,590
is how to calculate this spaceship's acceleration to the gravity.
35
00:01:57,590 --> 00:02:00,530
Well the input here is time and position.
36
00:02:00,530 --> 00:02:06,290
The position right here is not the same as position that you just computed in the task above.
37
00:02:06,290 --> 00:02:11,400
Instead, this position is a position of the spacecraft and not of the moon.
38
00:02:11,400 --> 00:02:17,160
So the second task is going to define the position of the spaceship depending on time
39
00:02:17,160 --> 00:02:20,150
and then you need to figure out how the gravitational attraction
40
00:02:20,150 --> 00:02:23,950
to the earth and to the moon affected deceleration.
41
00:02:23,950 --> 00:02:27,650
You think about how you can use vectors to do this and also as I said earlier,
42
00:02:27,650 --> 00:02:29,420
pretend that the earth is not the origin.
43
00:02:29,420 --> 00:02:33,730
Well, each of the first two tasks notice what your return values are
44
00:02:33,730 --> 00:02:38,600
and make sure that you define variables with the event in their proper places and it's function.
45
00:02:38,600 --> 00:02:41,170
So now you come to the slightly trickier part.
46
00:02:41,170 --> 00:02:45,250
In order to adjust the spaceship's trajectory to make it go around the moon,
47
00:02:45,250 --> 00:02:48,020
and then back in the right spot on the earth.
48
00:02:48,020 --> 00:02:52,400
It would be helpful if the crew had some control over it's velocity during the flight,
49
00:02:52,400 --> 00:02:55,150
lucky for them and lucky for us too.
50
00:02:55,150 --> 00:03:00,670
Those spaceship has rocket mechanisms that will allow to reduce it's speed on the way to the moon
51
00:03:00,670 --> 00:03:03,210
and increase it's speed on the way back to the earth.
52
00:03:03,210 --> 00:03:07,990
And we applied boost function right here. We've created two variant variables for you.
53
00:03:07,990 --> 00:03:11,620
And now I'm going to help you program some of these changes in velocity.
54
00:03:11,620 --> 00:03:15,830
This first one first two mid course correction or MCC
55
00:03:15,830 --> 00:03:19,440
and this task is whether or not the initial deceleration has occurred.
56
00:03:19,440 --> 00:03:22,960
Right now, it's set to false since at the beginning of the flight, this hasn't happened yet.
57
00:03:22,960 --> 00:03:28,280
Similarly, we have a second variable which at first does descent propulsion system or TPS.
58
00:03:28,280 --> 00:03:30,410
And this represents a second change in velocity.
59
00:03:30,410 --> 00:03:34,060
And the amount of which we're going to change the velocity at this point
60
00:03:34,060 --> 00:03:36,820
is what we're going to call the variable boost.
61
00:03:36,820 --> 00:03:40,830
Now, at these two moments, remember that we want to change just the management of the velocity.
62
00:03:40,830 --> 00:03:44,410
We don't want to mess with the direction at all. That would deal with itself.
63
00:03:44,410 --> 00:03:48,470
So, if your task is going to be to include these two velocities shifts
64
00:03:48,470 --> 00:03:53,610
and of course include them at the right times which I listed in the code.
65
00:03:53,610 --> 00:03:56,750
You can notice in the setup position of velocity vectors for you right here
66
00:03:56,750 --> 00:04:00,570
and plugged the initial values as well; however, it's up to you to figure out
67
00:04:00,570 --> 00:04:05,820
how to adjust their values with each step using Jorn's method and adapt a step size.
68
00:04:05,820 --> 00:04:08,760
You're going to that down here in this while loop.
69
00:04:08,760 --> 00:04:11,690
Here's Jorn's for you just to help you out a little bit.
70
00:04:11,690 --> 00:04:14,760
Once you calculated position and velocity using Heun's method.
71
00:04:14,760 --> 00:04:18,190
We also need to adjust the step size of the end of the while loop
72
00:04:18,190 --> 00:04:22,260
to reset it was a new value for the next time that we go to the loop.
73
00:04:22,260 --> 00:04:27,770
Now, just as we did in section 12 of the unit, we're going to store whatever the present step size is as h.
74
00:04:27,770 --> 00:04:31,710
And whatever the step size that would be in the next step of h new.
75
00:04:31,710 --> 00:04:35,110
To figure out the relationship between h and h new,
76
00:04:35,110 --> 00:04:38,130
you need to calculate the local truncation error or LTE.
77
00:04:38,130 --> 00:04:41,650
We also use basically the error that is made in a single time step.
78
00:04:41,650 --> 00:04:45,510
The difference after each time step between exact quantity
79
00:04:45,510 --> 00:04:48,890
and the quantity estimated by the approximation method that we're using.
80
00:04:48,890 --> 00:04:52,990
So new step size, h new is going to depend on the current step size,
81
00:04:52,990 --> 00:04:56,760
the tolerance, which we gave you earlier and the LTE.
82
00:04:56,760 --> 00:05:00,210
So consider calculating a local truncation error takes into account
83
00:05:00,210 --> 00:05:04,960
the difference between the values of position calculated by Euler and by Heun
84
00:05:04,960 --> 00:05:08,070
and the difference in values of velocity.
85
00:05:08,070 --> 00:05:11,660
T right here is the total duration of the flight so far.
86
00:05:11,660 --> 00:05:16,370
This needs to be here to let all of the units line up and LTE to be measured in length.
87
00:05:16,370 --> 00:05:20,510
Once you filled everything in, we're going back to the top of the applied boost function
88
00:05:20,510 --> 00:05:24,700
and figure out what the proper value of the constant boost is.
89
00:05:24,700 --> 00:05:28,070
Remember that our goal is to get the spaceship all the way around the moon
90
00:05:28,070 --> 00:05:31,580
and then have it just as it touches the earth when it comes back.
91
00:05:31,580 --> 00:05:36,520
Once you filled in everything down here, go back to the top of the applied boost function
92
00:05:36,520 --> 00:05:40,110
and figure out what the proper value for the constant boost is.
93
00:05:40,110 --> 00:05:46,260
We've given you just an initial value of zero, but we've also given you some other values to try out.
94
00:05:46,260 --> 00:05:48,760
So try plugging each these in and see what happens.
95
00:05:48,760 --> 00:05:52,470
Remember that our goal is put the spaceship all the way around the moon
96
00:05:52,470 --> 00:05:58,080
and then come back the earth and just touch the place where it initially took off.
97
00:05:58,080 --> 00:06:01,130
And because of the total time that we set at the top of our code,
98
00:06:01,130 --> 00:06:06,430
the shoot trajectory is not actually going to stop in the plot right initially when the ship gets to the earth.
99
00:06:06,430 --> 00:06:09,090
Instead, it's going to continue out in the earth as the spaceship
100
00:06:09,090 --> 00:06:11,840
is going to go back to the moon the second time.
101
00:06:11,840 --> 00:06:15,120
And the reason we did this was to try to make it a little bit easier for you
102
00:06:15,120 --> 00:06:17,780
to tell which value of the boost you should use.
103
00:06:17,780 --> 00:06:21,470
The correct value of boost will have the tail of it's trajectory
104
00:06:21,470 --> 00:06:25,250
reaching just back to the radius of the moon's orbit.
105
00:06:25,250 --> 00:06:30,030
Incorrect values of these could make the trajectory end short, go off in the wrong direction,
106
00:06:30,030 --> 00:06:34,240
but even if the spaceship crash into the earth which we definitely don't want to happen.
107
00:06:34,240 --> 00:06:36,010
And I'm sure the crew doesn't either.
108
00:06:36,010 --> 00:06:40,740
Well, now that this is a complex problem, but I'm sure you'll be able to return the crew safely home.
109
00:06:40,740 --> 99:59:59,000
If you need any help, just come to the front
PK iAx{[! ! , Problem_Set_2/04-Safe_Return_Solution.en.srt1
00:00:00,000 --> 00:00:04,639
Since you have so many different tasks to complete in this problem, let's go through them one by one.
2
00:00:04,639 --> 00:00:06,909
First things first the moon position function.
3
00:00:06,909 --> 00:00:10,649
Now we ask to start the moon off at moon initial angle.
4
00:00:10,649 --> 00:00:14,459
So we define moon angle or the angle of the moon at a given time
5
00:00:14,459 --> 00:00:22,759
as moon initial angle plus 2π times the time that has past divided by the total period of the moon.
6
00:00:22,759 --> 00:00:27,670
So this is basically the fraction of its orbit that the moon has gone through so far.
7
00:00:27,670 --> 00:00:30,759
We then created a 2-dimensional array for the moon's position
8
00:00:30,759 --> 00:00:33,869
but looks like the horizontal position in this drawing is equal to
9
00:00:33,869 --> 00:00:37,619
the distance between the earth and the moon or moon distance
10
00:00:37,619 --> 00:00:43,719
times the cosine of moon angle and the vertical position is the same except use a sine instead.
11
00:00:43,719 --> 00:00:46,669
So next comes the function of the acceleration of the spacecraft.
12
00:00:46,669 --> 00:00:49,709
Now let's talk about gravity for a second--we know that the gravitational force
13
00:00:49,709 --> 00:00:56,619
that one body feels as a result of another body is dictated by Newton's law of universal gravitation.
14
00:00:56,619 --> 00:01:01,689
We know that our spaceship is going to be pulled towards the earth and also towards the moon.
15
00:01:01,689 --> 00:01:03,409
So we need to take into account how the
16
00:01:03,409 --> 00:01:05,939
acceleration would be affected by both of these objects.
17
00:01:05,939 --> 00:01:08,629
Since we're interested in acceleration rather than force,
18
00:01:08,629 --> 00:01:12,648
we can use Newton's second law along this law of gravitation
19
00:01:12,648 --> 00:01:15,689
to come up with an expression for the total acceleration of the spaceship.
20
00:01:15,689 --> 00:01:20,659
To figure this out, however, we need information about the relative position of our three objects.
21
00:01:20,659 --> 00:01:25,989
So we started in the acceleration function by declaring a new variable called moon pause,
22
00:01:25,989 --> 00:01:29,728
which is just equal to the moon's position at any given time.
23
00:01:29,728 --> 00:01:34,978
Now we can define a vector from the moon to the spaceship, this green vector right here,
24
00:01:34,978 --> 00:01:38,639
as just the position vector of the spacecraft minus moonpos.
25
00:01:38,639 --> 00:01:42,558
Since moonpos is just the position vector of the moon.
26
00:01:42,558 --> 00:01:47,729
Then we can define a new variable called acc or at least that's what I'm going to pronounce this word.
27
00:01:47,729 --> 00:01:50,348
Using the equation of the acceleration due to gravity.
28
00:01:50,348 --> 00:01:53,618
We really owe Isaac Newton a lot of credit in this problem
29
00:01:53,618 --> 00:01:55,388
consider we're using two of his different laws.
30
00:01:55,388 --> 00:01:59,709
So you can see modifying his law of gravitation using the second law give us an expression
31
00:01:59,709 --> 00:02:03,689
for the vector sum of the total acceleration of the spacecraft.
32
00:02:03,689 --> 00:02:06,759
Here everything with a subscript as it stands for spacecraft.
33
00:02:06,759 --> 00:02:10,709
Now our next task was to make the velocity changes happen.
34
00:02:10,709 --> 00:02:14,769
If the first shift in velocity has not happened yet but it's after the time
35
00:02:14,769 --> 00:02:20,217
at which it was suppose to happen, then we decreased the velocity by 7.04 m/s
36
00:02:20,217 --> 00:02:22,839
but keep the spaceship moving in the same direction
37
00:02:22,839 --> 00:02:29,709
by dividing our quantity by the norm of the velocity vector and then multiplying it by this vector again.
38
00:02:29,709 --> 00:02:31,819
We do pretty much the same thing for boost
39
00:02:31,819 --> 00:02:36,739
but this time we replaced the time with the correct value 212,100 seconds.
40
00:02:36,739 --> 00:02:40,669
In each case since you've changed the velocity in the way it's prescribed,
41
00:02:40,669 --> 00:02:42,789
you can change the proper booleans to true.
42
00:02:42,789 --> 00:02:46,729
Now finally we get expressions for velocity and position using Heun's method.
43
00:02:46,729 --> 00:02:50,758
Right here we have a simple translation of his equations into Python.
44
00:02:50,758 --> 00:02:54,789
You can see Euler values with the e's and Heun's values with the h's .
45
00:02:54,789 --> 00:03:00,748
At the end of this, we set velocity and position equal to velocity h and position h.
46
00:03:00,748 --> 00:03:05,669
So that each time we go through another iteration, they will shift to equal the new Heun's values.
47
00:03:05,669 --> 00:03:08,539
Now in order to adjust the step size for each position of the spacecraft,
48
00:03:08,539 --> 00:03:13,619
we need to know the difference between Heun's and Euler values for position and velocity.
49
00:03:13,619 --> 00:03:16,629
You'll remember that we use this to calculate the error.
50
00:03:16,629 --> 00:03:21,659
Then the new step size is set as prescribed here in this line of code.
51
00:03:21,659 --> 00:03:25,729
Since we're up finishing up the step in which h, the current step size is valid,
52
00:03:25,729 --> 00:03:30,668
we add this to the current time and now that the next time step is about to happen,
53
00:03:30,668 --> 00:03:34,008
we set h equal to h new--updating its value.
54
00:03:34,008 --> 00:03:37,649
So this explains why we use h in the equations for Heun's method
55
00:03:37,649 --> 00:03:40,648
but are still able to lock the value cycle.
56
00:03:40,648 --> 00:03:44,639
Since our program is now complete, we can run it using different values for boost.
57
00:03:44,639 --> 00:03:48,587
We're getting zero as a value to start out with but let's try -10 first
58
00:03:48,587 --> 00:03:52,129
so we can check out one extreme of the range that we gave you.
59
00:03:52,129 --> 00:03:58,489
But a boost of -10 m/s, we can tell that the ship is pretty far away from touching the earth
60
00:03:58,489 --> 00:04:02,589
and then when we extend the path out again, it travels past the moon's orbit.
61
00:04:02,589 --> 00:04:04,619
We can clearly tell that this is not right.
62
00:04:04,619 --> 00:04:07,630
We definitely want to make sure that the crew actually gets back to the earth
63
00:04:07,630 --> 00:04:09,660
not just circles around again.
64
00:04:09,660 --> 00:04:11,310
Let's try a different value.
65
00:04:11,310 --> 00:04:16,738
Now since 100 is the largest value that we gave you to try, let's see what happens with that.
66
00:04:16,738 --> 00:04:18,768
Well that certainly looks different from the last plot that we saw.
67
00:04:18,768 --> 00:04:21,939
Though, this also doesn't look exactly right.
68
00:04:21,939 --> 00:04:26,669
So up close we can tell that it looks like the ship is actually crashing into the earth
69
00:04:26,669 --> 00:04:29,709
and that's definitely not what we want to happen either.
70
00:04:29,709 --> 00:04:32,139
We wanted to just barely scan the surface.
71
00:04:32,139 --> 00:04:35,599
Zooming out again, you can see that the tail of its trajectory
72
00:04:35,599 --> 00:04:38,899
doesn't reach out to the radius of the moon's orbit like we said that it would.
73
00:04:38,899 --> 00:04:44,619
So the correct value for boost is in between these two values at 10 m/s.
74
00:04:44,619 --> 00:04:47,619
Here is the solution plot. This looks perfect.
75
00:04:47,619 --> 00:04:50,749
You can see that the spaceship takes off, loops around the moon, comes back
76
00:04:50,749 --> 00:04:55,319
and just cruise the surface of the earth, and then, if we let it go out again,
77
00:04:55,319 --> 00:04:59,659
it will return to exactly the same radius that it left to initially.
78
00:04:59,659 --> 00:05:03,539
This is a really complex problem so great job for getting it done.
79
00:05:03,539 --> 00:05:07,709
The fact that we're done talking about spaceships and orbits, I get excited for Unit 3.
80
00:05:07,709 --> 99:59:59,000
We're going to talk about how diseases spread to the populations.
PK iAU
( Problem_Set_2/01-Symplectic_Euler.en.srtPK iAϩ$ 1 Problem_Set_2/02-Symplectic_Euler_Solution.en.srtPK iAWXB. . # 5 Problem_Set_2/03-Safe_Return.en.srtPK iAx{[! ! , d Problem_Set_2/04-Safe_Return_Solution.en.srtPK `