WEBVTT

NOTE
Simple Harmonic Motion: What Your Sensors Measure (and What the Models Show)
Transcript by BioGeeks: https://biogeeks.org/videos/gbcrecNtHzo

1
00:00:00.430 --> 00:00:10.650
Hello, everybody. Thank you so much for joining us. We are so excited to dive into simple harmonic

2
00:00:10.650 --> 00:00:16.410
motion. Let me go ahead and pull up the slideshow so you guys know where you are.

3
00:00:21.980 --> 00:00:28.440
While I'm getting this set up, go ahead and pop in the chat and let us know where you're

4
00:00:28.440 --> 00:00:41.880
joining us from. I am here. Sorry, I've got all my windows open. I am here in Oregon where the

5
00:00:41.880 --> 00:00:53.600
Vernier headquarters is. Oh, we've got someone from Argentina. That's cool. Awesome. Good to see you.

6
00:00:53.600 --> 00:01:00.980
Syracuse, New York, California, Texas. Oh, Roger from Boulder, Colorado. I went to CSU in Fort

7
00:01:00.980 --> 00:01:06.640
Collins. Sorry, Roger. But my twin brother went to Boulder, so I'm an ally.

8
00:01:08.340 --> 00:01:13.940
Kaysville, Utah, Pennsylvania, Selma, Syracuse. Oh, Marianne from Swarthmore. Hi.

9
00:01:14.540 --> 00:01:22.720
Nice. Hayward, California. Awesome. Well, thank you all so much for joining us today. I want to get to

10
00:01:22.720 --> 00:01:30.180
the meat and potatoes of today's presentation. Oh, hi, Tony. Perfect. Sorry. Oh, no, you're good.

11
00:01:32.180 --> 00:01:39.420
I wanted to hop into some housekeeping items. So, as you can see, we are in on 24, which means that

12
00:01:39.420 --> 00:01:44.160
you are going to get a follow-up to this webinar very quickly. I think it sends a follow-up within

13
00:01:44.160 --> 00:01:49.860
the day. We will have it, you know, on our website and on YouTube within three to five business days.

14
00:01:49.860 --> 00:01:55.320
We still just have to edit it if it's going on YouTube. But you will get that and a certificate

15
00:01:55.320 --> 00:02:02.460
of attendance. I'm also going to tell you where to find that right now. So, looking at the top of

16
00:02:02.460 --> 00:02:07.080
your screen, a quick walkthrough of what you're seeing. So, if you look at the speakers tab,

17
00:02:07.500 --> 00:02:13.580
you'll see some info about today's presenters as well as how to contact them. I know you all already

18
00:02:13.580 --> 00:02:19.440
located the attendee chat. That's where you'll be active today. So, that's where you can ask your

19
00:02:19.440 --> 00:02:24.540
questions, give us your comments. I'm going to keep an eye on the chat. I know that Fran is also

20
00:02:24.540 --> 00:02:29.520
keeping an eye on the chat. Under additional resources, you'll find a link to the certificate

21
00:02:29.520 --> 00:02:35.080
of attendance and anything else we drop to you. You shouldn't need to, you know, follow an experiment

22
00:02:35.080 --> 00:02:41.660
or something. Rhett will walk you through the whole thing. And there's also reaction buttons. We want to

23
00:02:41.660 --> 00:02:46.860
know what you think about this whole shebang. So, please use those reaction buttons. Let us know how

24
00:02:46.860 --> 00:02:54.460
the presentation is going. And besides that, if we happen to miss a question that you drop in a Q&A

25
00:02:54.460 --> 00:03:01.400
or if it comes to you later, please reach out to us. You can reach us at physicsatvernier.com and

26
00:03:01.400 --> 00:03:08.820
you'll have that email address again later if you need to contact us. So, really quickly today,

27
00:03:08.820 --> 00:03:14.700
we are just going to go through some introductions. Rhett has an amazing presentation. We'll cover any

28
00:03:14.700 --> 00:03:19.940
questions at the end that you might want to wait for a further conversation, anything like that. But

29
00:03:19.940 --> 00:03:24.420
please feel free to be dropping that in as we're going through the presentation. And then we are doing

30
00:03:24.420 --> 00:03:30.920
a prize drawing. We're doing a $100 gift certificate to Vernier that is only open to folks who

31
00:03:30.920 --> 00:03:38.240
are still live on the meeting at the end. So, stay with us. And then a quick meet the presenters.

32
00:03:39.200 --> 00:03:43.680
So, I'll let you two introduce yourselves, but I have some fun facts up here.

33
00:03:45.160 --> 00:03:46.540
Rhett, will you go first?

34
00:03:47.560 --> 00:03:48.360
My fun fact?

35
00:03:49.120 --> 00:03:49.860
Go ahead.

36
00:03:50.640 --> 00:03:57.460
So, my fun fact that we came up with was I remember meeting Fran, I think it was at the Chicago AAPT

37
00:03:57.460 --> 00:04:01.860
meeting, and it was a long time ago. Because she was, and I knew her because she was a blogger.

38
00:04:02.260 --> 00:04:03.140
Isn't that correct?

39
00:04:04.340 --> 00:04:05.500
That's correct. Yep.

40
00:04:06.040 --> 00:04:06.860
That's my fun fact.

41
00:04:07.860 --> 00:04:08.540
Pretty cool.

42
00:04:08.540 --> 00:04:14.440
And my fun fact is that I'm learning Korean, so I can turn off the subtitles on the K-dramas

43
00:04:14.440 --> 00:04:19.940
that I watch. And the Korean there just says that I like K-dramas.

44
00:04:19.940 --> 00:04:29.860
All right. And with that, I will stop sharing my side and kick it over to you, Rhett. Thank you so

45
00:04:29.860 --> 00:04:30.180
much.

46
00:04:31.460 --> 00:04:40.400
Okay. So, what I'm going to do, the goal here is to collect data on simple harmonic motion

47
00:04:40.400 --> 00:04:47.320
and then to model simple harmonic motion numerically. And I'm going to do this in a format that I would

48
00:04:47.320 --> 00:04:51.580
do to my, for my students. So, I mean, I'm going to, I'm going to tell you things that you probably

49
00:04:51.580 --> 00:04:56.800
already know, but I'm presenting it in a way that you could do it also for your students. And this

50
00:04:56.800 --> 00:05:02.340
would work for pretty much any level. I think from, you know, high school, even algebra-based

51
00:05:02.340 --> 00:05:07.040
physics. I would even do this in calculus-based physics because it's that awesome. So, what we're

52
00:05:07.040 --> 00:05:13.040
going to do is use the GoDirect cart to collect data, and then we use Python to model it. So, I want

53
00:05:13.040 --> 00:05:22.660
to talk first about springs, mass on a spring. So, let's look at a mass on a spring. If we

54
00:05:22.660 --> 00:05:33.460
have a mass or any spring in general, and I stretch it some distance, S, then it will

55
00:05:33.460 --> 00:05:39.000
exert a force backwards. And the magnitude of that force is K times S. So, the strength of

56
00:05:39.000 --> 00:05:43.740
the force on the spring is proportional to the stretch. And this proportionality constant

57
00:05:43.740 --> 00:05:53.000
is the spring constant. Constant. Now, the first thing that we want to do in order to

58
00:05:53.000 --> 00:05:57.820
model simple harmonic motion is to determine the value of our spring constant. So, I have

59
00:05:57.820 --> 00:06:04.220
a spring. So, let me show you my spring. And you can do this with any spring, but here's

60
00:06:04.220 --> 00:06:11.260
my spring right here. I think for this particular experiment, the lower spring constant springs

61
00:06:11.260 --> 00:06:15.640
work better. But again, anything can make, you can make any of them work. So, what I want

62
00:06:15.640 --> 00:06:19.900
to do is to measure the spring constant for this. The traditional way is you would hang

63
00:06:19.900 --> 00:06:24.120
it right here. You'd place masses on there. It would stretch down. You measured the stretch.

64
00:06:24.440 --> 00:06:29.820
You can determine the force based on the gravitational force pulling it down from the mass. But we're

65
00:06:29.820 --> 00:06:33.360
going to use the cart instead because I love this method, and it's really great for other

66
00:06:33.360 --> 00:06:38.600
kinds of springs too. So, what I want to do is I have my cart already connected to LoggerPro.

67
00:06:38.600 --> 00:06:44.100
I'm going to show you, not LoggerPro, graphical analysis. I'm going to show you what it looks

68
00:06:44.100 --> 00:06:49.260
like first, and then I'll come back and I'll collect the data live. So, I'm going to move

69
00:06:49.260 --> 00:06:53.160
my camera over here just for a second. I don't have the best set up, but I think I can get

70
00:06:53.160 --> 00:07:02.640
this to work. So, here we go. There's my track. And I have my cart. It's already connected

71
00:07:02.640 --> 00:07:08.140
to the computer. I want to mount my spring somehow. Well, you can be mounted in any creative

72
00:07:08.140 --> 00:07:13.980
way, and then I want to connect it to the cart. And the track should be level.

73
00:07:15.700 --> 00:07:22.560
Now, what I can do is just pull the cart back. Since the cart measures position with the roller

74
00:07:22.560 --> 00:07:28.900
wheel and force with the front hook, I can get position and force data for both there and back

75
00:07:28.900 --> 00:07:34.320
all right at one time. Okay. So, that's what I'm going to do. So, I'm going to put it back over here,

76
00:07:34.320 --> 00:07:44.490
and then we're going to switch, and we're going to collect data for that. Okay. Let's see.

77
00:07:46.810 --> 00:07:56.150
So, this is, I have graphical analysis loaded. I've already connected my cart to the program,

78
00:07:56.290 --> 00:08:01.450
and I have all this stuff because I turned on both position and force, and I don't want all

79
00:08:01.450 --> 00:08:07.310
these graphs. So, let's just switch this to one graph, number of graphs, one. Another thing I want

80
00:08:07.310 --> 00:08:14.990
to do, and it's not super important, but the cart has the positive x direction in the direction of

81
00:08:14.990 --> 00:08:19.430
the spring. I actually want to measure positive x the other way. It doesn't matter. Okay. You still

82
00:08:19.430 --> 00:08:25.930
get the same thing. So, down here, I'm going to change my, click the position. I'm going to reverse

83
00:08:25.930 --> 00:08:30.250
the direction. I'm also going to zero it out, even though that, again, also doesn't matter. For the

84
00:08:30.250 --> 00:08:36.650
force, I'm going to zero that too. Now, I want to, I have force versus time. I'm going to change this

85
00:08:36.650 --> 00:08:44.070
to force versus position. One final thing. I'm going to switch this to collect data for 10 seconds,

86
00:08:44.330 --> 00:08:51.270
just so I have enough time. So, now I have force versus position. I'm going to collect data. I'm

87
00:08:51.270 --> 00:08:56.310
going to pull the cart back, and then I'm going to let the cart go back to its unstretched position,

88
00:08:56.510 --> 00:09:06.910
and then we'll analyze it from there. So, I'm clicking collect, and it did really slow,

89
00:09:07.570 --> 00:09:11.630
and then I'll let's zoom in so you can see what that looks like. I mean, that's actually a pretty

90
00:09:11.630 --> 00:09:16.570
awesome graph. You can see that you do have a slight different set of data for when you're

91
00:09:16.570 --> 00:09:22.150
pulling it and when you're coming back, but it's so close together that it works fine, and the slope

92
00:09:22.150 --> 00:09:28.330
of this line is the spring constant. So, that's it. Now, down here, I maybe don't want that data,

93
00:09:28.410 --> 00:09:35.010
so I'm just going to highlight that part over here, and then I'm going to go to apply curve fit,

94
00:09:35.010 --> 00:09:42.610
linear, apply, and then there's my spring constant right there. So, I have a spring constant of 7.612

95
00:09:42.610 --> 00:09:53.550
newtons per meter. Let me write that on the board before I forget. K, 7.62. What was it? 612?

96
00:09:55.630 --> 00:10:08.260
612. Of course. Yep. Okay. That's K. Now, we're going to also collect data on the oscillation of the

97
00:10:08.260 --> 00:10:15.320
cart. Now, before we do that, we're going to need the mass of the cart. You can take your cart and put

98
00:10:15.320 --> 00:10:22.420
it on a scale, but why would you do that when I can just measure the mass of the cart directly?

99
00:10:22.780 --> 00:10:29.040
So, over here, let me switch over the view options. I'm going to turn on the meters, and we can see the

100
00:10:29.040 --> 00:10:35.520
force that the cart is being pulled on, and I'm going to take the cart, and you can hold it with

101
00:10:35.520 --> 00:10:42.200
the, you can hold the cart. I'll show you a picture of this in just a second, but I'm going to, I'm

102
00:10:42.200 --> 00:10:49.860
holding it up with rubber band so that it doesn't, it's vertical, and I get 2.7. Let's go with 2.7

103
00:10:49.860 --> 00:10:56.380
newtons. So, here's what that looks like. I'll show you that. 2.7 is a, so I'm just holding up the

104
00:10:56.380 --> 00:10:59.980
cart like that, and I'm using its own force sensor to determine the weight, and then we can use that

105
00:10:59.980 --> 00:11:11.840
to determine the mass. So, I'm going to write over here, mg, 2.7 newtons. Okay. Now, I'm going to take

106
00:11:11.840 --> 00:11:17.380
my rubber band and put it back. It, for future use, if you use this method to determine the spring

107
00:11:17.380 --> 00:11:21.540
constant with the rubber band, you see that it's not a spring, and it's pretty awesome. So, the

108
00:11:21.540 --> 00:11:26.860
stretching and the unstretching are different spring constants effectively, and it depends on how fast

109
00:11:26.860 --> 00:11:30.480
you do it. Great experiment to do with the rubber band with that one, but we're going to look at

110
00:11:30.480 --> 00:11:37.120
simple harmonic motion. So, in simple harmonic motion, we have a cart, and the cart, the spring

111
00:11:37.120 --> 00:11:43.140
pulls it one way, but as it moves, the spring force changes. So, that makes it a very complicated

112
00:11:43.140 --> 00:11:49.060
situation since we have a non-constant force. The force changes the velocity, the velocity changes

113
00:11:49.060 --> 00:11:54.800
the position, the position changes the force, and so forth. It is a solvable problem, but we want to

114
00:11:54.800 --> 00:12:04.060
numerically model it. The best thing about science is building a model that agrees with real data,

115
00:12:04.280 --> 00:12:08.140
and so that's the stuff that we want here. We want to use the cart to get the real data,

116
00:12:08.140 --> 00:12:14.160
and then we can do the magic of making a model that agrees with the data. That's the real win

117
00:12:14.160 --> 00:12:19.140
right there. Okay, so I'm going to show you how I put the cart on the track, and then we're going to

118
00:12:19.140 --> 00:12:24.320
come back to graphical analysis and collect data, and then we have to do some tricks in order to get

119
00:12:24.320 --> 00:12:31.380
this in Python, and then the fun cert stuff in Python. So, what I'm going to do, let me put this on

120
00:12:31.380 --> 00:12:42.480
the track, and I'll move the camera again. Okay, let's move the camera. So, here's my track. Now,

121
00:12:43.080 --> 00:12:49.860
it doesn't want to oscillate back and forth because we have a spring that only gets pulled,

122
00:12:49.940 --> 00:12:54.360
and it doesn't compress, so you can't make it oscillate back and forth like this. However,

123
00:12:54.360 --> 00:13:01.320
you can use a trick. You can incline your track, and here I'm just going to use a textbook

124
00:13:01.320 --> 00:13:10.260
that I have. I'm going to put it under here like that. Now, there is a component of force

125
00:13:10.260 --> 00:13:15.660
in the direction down the track, and so the equilibrium position of the cart has the spring

126
00:13:15.660 --> 00:13:21.260
already stretched. Now, when I displace it a little bit like that, it will oscillate up back and forth,

127
00:13:21.260 --> 00:13:27.520
and that's what I want. Now, the steeper your track, the greater the amplitude of oscillation. If I

128
00:13:27.520 --> 00:13:31.300
pull this back too much, you can see I get slack in my spring, and I don't want that.

129
00:13:31.320 --> 00:13:38.910
There. Okay. So, I'm going to do just a really tiny oscillation. So, what I want to do is collect

130
00:13:38.910 --> 00:13:43.370
data for the position as the function of time right here, and then we're going to use that in

131
00:13:43.370 --> 00:13:49.870
our model. Okay, so let's go back to, I'm going to show you how to set this up in graphical analysis

132
00:13:49.870 --> 00:13:55.550
because there is a trick that we need. We want that position time data, and we want to export it.

133
00:13:55.550 --> 00:14:07.120
Okay. So, if I just look at the data right now, let's switch to graphical analysis. We already have

134
00:14:07.120 --> 00:14:12.680
position time data there. Okay. We use it to plot this force. If I go over here to show the data

135
00:14:12.680 --> 00:14:18.460
table, I don't want the meters. I want the data table. There is an issue that I have these time

136
00:14:18.460 --> 00:14:23.600
values right here, and the data rate for the position sensor is different than the data rate

137
00:14:23.600 --> 00:14:32.340
for the force sensor. And so, I don't want to have these spaces in between my position datas.

138
00:14:32.580 --> 00:14:36.640
So, I'm going to start over, and I'm going to not use the force sensor, and maybe there's a better

139
00:14:36.640 --> 00:14:41.620
way to do that, but it's okay to not do things the best way. We can just do it the way we want.

140
00:14:41.620 --> 00:14:47.360
So, I don't really care about saving that. And now, I'm going to do sensor collection again.

141
00:14:49.060 --> 00:14:54.240
But this time, actually, I'm going to go over here, and I'm going to turn off the force sensor.

142
00:14:56.040 --> 00:15:02.260
So, I have the sensors. I'm going to turn that off. Okay. And then, I want one graph,

143
00:15:02.760 --> 00:15:08.820
and I do want position versus time. Okay. But now, when I collect data, it won't have skipped

144
00:15:08.820 --> 00:15:15.180
all my times. It won't have time position, time position like that. And I can use it in a better

145
00:15:15.180 --> 00:15:20.960
way. Okay. So, we're ready to collect data. What I'm going to do is, let's see, this is,

146
00:15:21.960 --> 00:15:28.460
let's do eight seconds. I don't need too much time. And I'm going to leave it like that. I'm going to,

147
00:15:28.520 --> 00:15:34.740
oh, I don't, I can reset the position to zero. I can reverse the direction. It doesn't really matter

148
00:15:34.740 --> 00:15:40.600
like I had before. Now, what I'm going to do is displace a little bit and collect data. And then,

149
00:15:40.600 --> 00:15:45.140
we can move this to Python, where we can do our work. Okay. So, I'm going to click,

150
00:15:45.960 --> 00:15:55.480
I'm going to pull it down a tiny little bit, collect, collect, let go. And then, that's good

151
00:15:55.480 --> 00:16:00.860
enough. Stop. And then, let me zoom in so you can see that. So, there's two really important things

152
00:16:00.860 --> 00:16:06.280
here. One, this is simple harmonic motion, and that's pretty awesome. Number two, we don't have a

153
00:16:06.280 --> 00:16:10.900
constant amplitude, because it's not a perfect system. We can take care of that later, and that's

154
00:16:10.900 --> 00:16:17.460
part of the magic of the whole thing. So, but what we want to do here is to get this data into

155
00:16:17.460 --> 00:16:24.000
Python. And I'm going to be using web v Python. Okay. So, how do we do that? I'm going to go back over

156
00:16:24.000 --> 00:16:29.480
here. I'm going to click data table. And now, you see, I have a data table that has time and position,

157
00:16:29.480 --> 00:16:39.040
and that's exactly what I want. It starts at 0.2. That's fine. Okay. So, I don't, I know that I

158
00:16:39.040 --> 00:16:45.600
have a time interval of 0.04 seconds. So, I don't really need to copy the time data. You can if you

159
00:16:45.600 --> 00:16:50.440
want to, but I'm just going to copy the position data. So, if I click on the top up here, it will

160
00:16:50.440 --> 00:16:56.360
highlight the whole thing, and I'm just going to copy it. Now, it's a list of numbers, but in Python,

161
00:16:56.360 --> 00:17:05.080
I need it as a comma separated list, so I can, I can use it. So, how do we do that? So, I'm going

162
00:17:05.080 --> 00:17:12.320
to, this is my trick. I'm going to go to use Google Spreadsheets. So, let me switch my window over

163
00:17:12.320 --> 00:17:29.800
here. Window, is this it? I think this is it. Yeah. Okay. So, I'm in Google Spreadsheets,

164
00:17:29.800 --> 00:17:35.380
and I'm going to paste my data right here. And I already put it in the formula because I would

165
00:17:35.380 --> 00:17:42.980
forget it. But there's a formula in Spreadsheets right up here. It says equals text join, and I want

166
00:17:42.980 --> 00:17:48.040
to join all the text right here with a comma space in between them. And then, I don't know what the

167
00:17:48.040 --> 00:17:54.200
true means, but then A, A means just use the whole comma of A. So, in this one cell, I have all of my

168
00:17:54.200 --> 00:18:01.980
data as a comma separated list. So, if I click this and copy it, I have all my data. Okay. Let's

169
00:18:01.980 --> 00:18:08.540
go over to Python, and let's plot this thing and see what happens. Okay. Now, if you haven't done

170
00:18:08.540 --> 00:18:16.220
anything in Python before, it's not scary. Okay. There's some stuff to do, but it's not that bad.

171
00:18:16.620 --> 00:18:23.700
The worst part is going to be plotting this data. But I think you could do it. So, this is, there's

172
00:18:23.700 --> 00:18:32.240
several versions of Web v Python that you can use. There's GlowScript.org. There's Trinket.gopickup.org.

173
00:18:32.240 --> 00:18:40.920
This is Web v Python sponsored by GoPickup. I mean, Pickup. They're a physics integrating

174
00:18:40.920 --> 00:18:46.700
computation and physics group. This one's the one I like to use. There's also one, there's a

175
00:18:46.700 --> 00:18:51.060
Mandarin interaction server that has it too, but this is the one I always go to. GlowScript works

176
00:18:51.060 --> 00:18:55.600
just fine too. You can also run it locally, but then you have to install stuff, and I don't want

177
00:18:55.600 --> 00:19:00.760
to install stuff. So, this is, I'm logged in as Trinket, and the first thing I'm going to do is click

178
00:19:00.760 --> 00:19:06.320
right here, and then go to my name, and then click new Trinket. So, they're called Trinkets, and in

179
00:19:06.320 --> 00:19:11.620
fact, we have two kinds of Trinkets. You can just do plain Python, but we want to do Web v Python. It has

180
00:19:11.620 --> 00:19:18.480
all the stuff that we want in there. And you can see right now that we have a website with code in it.

181
00:19:18.540 --> 00:19:23.360
We can run it. We can edit it, and that's great. The other nice thing about Trinkets is that if you

182
00:19:23.360 --> 00:19:28.740
write code and you share it with your students, they can edit it, and it won't change your code, and it

183
00:19:28.740 --> 00:19:35.400
works really well that way. Okay. So, let's just add our data in here. We're going to call this X,

184
00:19:35.720 --> 00:19:43.240
and I'm going to call it XV since it's from for near, and it's going to be a list of numbers. So,

185
00:19:43.300 --> 00:19:47.900
we define lists in Python with these square brackets, and I'm just going to paste my numbers

186
00:19:47.900 --> 00:19:55.740
in there. It's a huge thing, right? And that's fine. Okay. So, now, how do I plot this, though?

187
00:19:55.740 --> 00:20:03.140
That's the question. How do I plot this? Let's go ahead and make a graph. So, in Web v Python,

188
00:20:03.300 --> 00:20:09.540
there's an object called a graph, and it makes the axes for your graph, and it doesn't make the

189
00:20:09.540 --> 00:20:14.340
function a plot. So, it's a built-in object. So, let's give it a name. You don't have to give it a

190
00:20:14.340 --> 00:20:20.680
name. I'm going to call it G1. It's an object of type graph. Now, there's a lot of properties to the

191
00:20:20.680 --> 00:20:26.240
object, the graph object. I'm going to give it, I'm going to define some of the properties.

192
00:20:26.680 --> 00:20:32.660
There's X title, which tells you your X axis. There's Y title, your Y axis, and then there's

193
00:20:32.660 --> 00:20:38.740
the size. So, I'm going to say, I want to plot position versus time. X title equals T. You can

194
00:20:38.740 --> 00:20:45.820
type whatever you want in the quotes. You could call it Bob or whatever. Y title is X. I'm giving

195
00:20:45.820 --> 00:20:52.220
it units. I put my units in square brackets. Now, because I'm zoomed in a lot on my browser,

196
00:20:52.380 --> 00:20:57.760
I'm going to change the size of my graph so that it looks better. So, I'm going to give

197
00:20:57.760 --> 00:21:03.640
it a width that's a built-in property of 500. So, that's 500 pixels wide, and then give it

198
00:21:03.640 --> 00:21:08.080
a height of 250. You don't have to do that. It'll do the default size, which is too big

199
00:21:08.080 --> 00:21:12.840
for me. Now, if I run this, nothing happens because it's just the axis. I need a function

200
00:21:12.840 --> 00:21:18.940
to plot. So, let's call this function that we plot in the graph. It's a type called G

201
00:21:18.940 --> 00:21:25.260
curve. I'm going to give it the name FV for the Vernier function, and it's a G curve. And

202
00:21:25.260 --> 00:21:32.000
again, this has properties to it. This will connect, I mean, plot the points that you want

203
00:21:32.000 --> 00:21:37.160
and connect them by a line. It won't show the points, though. I always like to give it

204
00:21:37.160 --> 00:21:43.260
a color because color is fun. So, I'm going to say color is color dot blue. There's, you

205
00:21:43.260 --> 00:21:50.240
know, blue, red, green, purple, magenta, cyan, yellow, yellow, yellow. You can think of different

206
00:21:50.240 --> 00:21:54.660
colors that you want. If you go to the help site, it tells you all the different built-in

207
00:21:54.660 --> 00:22:01.080
colors. Okay. Now, so, I have my X values. I don't have my time values. So, I'm going to

208
00:22:01.080 --> 00:22:08.060
need to plot time, too. So, in fact, I think I am going to just copy the time. I changed

209
00:22:08.060 --> 00:22:13.000
my mind. So, let's switch back over here. I'm going to go to, you can't see this. I'm

210
00:22:13.000 --> 00:22:18.040
just going to highlight my time. And now, okay, now I'm back over here. I'm just going

211
00:22:18.040 --> 00:22:23.500
to paste in my time values right there and then copy them. So, then I don't have to rebuild

212
00:22:23.500 --> 00:22:28.960
my time. You could do it either way. So, I'm going to call this TV is equal to all that

213
00:22:28.960 --> 00:22:34.900
stuff. Okay. So, now I have all my time values, I have all my position values. I can go through

214
00:22:34.900 --> 00:22:40.240
and plot them. So, let me show you how this works. I'm going to use a for loop. So, I'm

215
00:22:40.240 --> 00:22:45.560
going to say for I, and now let me type it out and then tell you what it means. In range

216
00:22:45.560 --> 00:22:52.720
length of XV. And I'm going to just to show you how it works. I'm going to print I. So,

217
00:22:52.720 --> 00:23:01.060
this goes through the list XV and calls each element the number that it is. So,

218
00:23:01.060 --> 00:23:05.080
it'll go from the first one to be zero, then one, then two, and three. So, this will go

219
00:23:05.080 --> 00:23:11.600
through the whole list and call each one I. So, you see, I have 151 elements in my

220
00:23:11.600 --> 00:23:16.660
list, which I don't really care about. But I do want to reference each element in my

221
00:23:16.660 --> 00:23:21.120
list. So, if I wanted to print out the first one, it would be XV zero. So, I can

222
00:23:21.120 --> 00:23:28.180
print XV zero. So, you square brackets and now print the first one. I can print the

223
00:23:28.180 --> 00:23:35.720
second one print as XV one and so forth. So, if I want to do that, I can and it'll

224
00:23:35.720 --> 00:23:41.080
print out that numbers. I don't want to print them. I want to plot them. So, to plot in

225
00:23:41.080 --> 00:23:47.900
Web v Python, we're just going to use our function name here, FV dot plot, and I need

226
00:23:47.900 --> 00:23:52.740
to give it my X value coordinate and my Y value coordinate. So, in this case, my X value

227
00:23:52.740 --> 00:23:59.580
is TV and my Y value is XV. And then that's going to plot it. Now, I don't need to do

228
00:23:59.580 --> 00:24:03.620
anything else because I'm already going through all these I values. This should plot what we

229
00:24:03.620 --> 00:24:11.040
have. And there you go. So, that's the data from graphical analysis. That's the

230
00:24:11.040 --> 00:24:16.860
real data that we collected. And we want to use that to make a model and compare with

231
00:24:16.860 --> 00:24:26.360
it. Now, we're going to need initial conditions. But let's just go through how we model, how

232
00:24:26.360 --> 00:24:31.300
we make a numerical model for a mouse on a spring without friction. So, it won't match

233
00:24:31.300 --> 00:24:35.140
perfectly, but we can fix that later. Okay. So, I'm going to the board and we're going to

234
00:24:35.140 --> 00:24:40.320
talk about numerical models. I should save that code if I didn't because I like to live

235
00:24:40.320 --> 00:24:45.260
dangerously. So, stop sharing. There we go. Okay. Now, we're on the board. So, I have over

236
00:24:45.260 --> 00:24:53.210
here the two things I want to save. I want to save the mass and spring constant because

237
00:24:53.210 --> 00:24:57.750
we're going to need that. Over here, let's just draw a little picture of what's going

238
00:24:57.750 --> 00:25:06.370
on. I saved that because I thought I'd forget it. So, imagine that I have my spring and this

239
00:25:06.370 --> 00:25:11.930
is x equals zero. And I pull it over here. So, now there's a force. And I'm going to use

240
00:25:11.930 --> 00:25:16.870
one-dimensional notation because we don't need two-dimensional stuff here. So, this will

241
00:25:16.870 --> 00:25:21.990
just make it a little bit easier. So, that's my spring force. And I'm assuming that it is

242
00:25:21.990 --> 00:25:26.610
horizontal. We can show later that it doesn't matter that it's vertical or horizontal. It's

243
00:25:26.610 --> 00:25:32.030
going to work out the same way, which is easy to do in Python, not easy to do in real life.

244
00:25:32.030 --> 00:25:39.430
I know the value of this force. I'm going to write it here. F net is going to be equal

245
00:25:39.430 --> 00:25:47.110
to Fs. And that's negative Kx. So, if my x is positive, the force is in the negative

246
00:25:47.110 --> 00:25:52.050
x direction. Once I get over here and I have negative x, my force is in the positive direction.

247
00:25:52.170 --> 00:25:56.250
And that's what makes it all straight back and forth. And we can set, since that's the

248
00:25:56.250 --> 00:26:00.330
only force acting on it in the system, I can set that equal to mass times acceleration.

249
00:26:00.330 --> 00:26:06.490
But, as we said before, the acceleration depends on x, and the x depends on the

250
00:26:06.490 --> 00:26:09.790
velocity, which changes with acceleration. So, that's why it's a hard problem.

251
00:26:11.110 --> 00:26:14.450
The first thing I want to do is to just solve for the value of acceleration.

252
00:26:14.990 --> 00:26:21.730
So, the acceleration is going to be negative K over M times x. And I'm going to put a box

253
00:26:21.730 --> 00:26:32.750
around that. So, the trick to numerical calculations is that if I break my motion into short time

254
00:26:32.750 --> 00:26:43.090
intervals, so let's say delta T is 0.01 seconds, then during that time interval, I can assume

255
00:26:43.090 --> 00:26:49.110
that this acceleration is constant. It's not, but it's kind of. So, I can assume that it is.

256
00:26:49.490 --> 00:26:54.490
And if I do that, then I can use the following definition for acceleration.

257
00:26:54.490 --> 00:27:04.310
I can say the acceleration is a change in velocity with respect to time. Now, imagine that I have a

258
00:27:04.310 --> 00:27:10.270
velocity right here, V1, and a little bit later, I have a velocity right here, V2. I can write this

259
00:27:10.270 --> 00:27:21.290
as V2 minus V1 over delta T. And that's true if the acceleration is constant, and it's kind of true

260
00:27:21.290 --> 00:27:26.290
if my time interval is small. But I can use this. I can multiply both sides by delta T.

261
00:27:26.630 --> 00:27:38.510
I get V2 minus V1 is A delta T. I can add V1 to both sides, and I get V2 is V1 plus A delta T.

262
00:27:38.990 --> 00:27:43.490
I'm going to put a green box around this one because I bought this colored chalk, so I've got to use it.

263
00:27:45.520 --> 00:27:50.920
This is a really important equation, too, right? Here, I can calculate the acceleration for that short

264
00:27:50.920 --> 00:27:56.180
time interval. Here, if I know the velocity at the beginning of the time interval, I can find it at

265
00:27:56.180 --> 00:28:01.260
the end of the time interval. So, this tells me something I do need to know the very, very first

266
00:28:01.260 --> 00:28:08.200
velocity. But now, let's go one step further. The definition of velocity, let's assume the velocity

267
00:28:08.200 --> 00:28:14.680
is constant, which is crazy because we just said we change it. But crazy is only a little crazy with

268
00:28:14.680 --> 00:28:21.940
little time steps. So, here I can say V is the change in X over the change in time, and that's going to be

269
00:28:21.940 --> 00:28:33.080
X2 minus X1 over delta T. And I'm going to solve this for X2, and I get X2 is X1 plus V delta T.

270
00:28:33.080 --> 00:28:41.570
What color? How about yellow? Box that one. So, here's what we're going to do. We're going to,

271
00:28:42.130 --> 00:28:49.670
one, calculate the acceleration. Two, use that acceleration to update the velocity. And then,

272
00:28:49.750 --> 00:28:58.500
oh, yellow. Three, use that velocity to update the position. Now, if I have a time interval of 0.01

273
00:28:58.500 --> 00:29:04.720
seconds, I just found out where the mass is and how fast it's going after 0.01 seconds. But we have data

274
00:29:04.720 --> 00:29:10.280
for five seconds. So, that means I need to go back up here and do it again. Now, after I move my

275
00:29:10.280 --> 00:29:14.820
position, I'm going to have a new acceleration. So, I'm going to recalculate that. And then, I have a

276
00:29:14.820 --> 00:29:20.320
new acceleration. I'm going to re-update my new velocity, update my new position, do it again and

277
00:29:20.320 --> 00:29:27.440
again and again. And this is the idea of a numerical calculation. Yes, there are much more complicated

278
00:29:27.440 --> 00:29:35.160
recipes. But this one is the easiest for students to understand. And it's very straightforward. And

279
00:29:35.160 --> 00:29:41.780
it works. Okay. So, we don't need to worry about, you know, higher order calculations here. So, this

280
00:29:41.780 --> 00:29:47.720
works really well. Spoiler alert, the order does matter. Okay. You always want to calculate the

281
00:29:47.720 --> 00:29:53.720
highest derivative things first. Acceleration, then velocity, and then position. And then, just do it

282
00:29:53.720 --> 00:29:58.660
again and again. But, like I said, in order to update the velocity to the, after that first time

283
00:29:58.660 --> 00:30:02.720
interval, I need to find the first velocity. In order to update the position, I need the first

284
00:30:02.720 --> 00:30:09.180
position. So, we need to find those first values. And the easiest thing to do is to start when the

285
00:30:09.180 --> 00:30:14.400
velocity is equal to 0. But our data doesn't have velocity is equal to 0. So, we need to, we need to

286
00:30:14.400 --> 00:30:18.960
cheat. But we're going to, this is what we're going to do in Python. We know the spring constant.

287
00:30:18.960 --> 00:30:24.240
I can calculate the mass so that I can calculate the acceleration, update velocity, update position.

288
00:30:24.900 --> 00:30:34.850
And we're going to go for it. Okay. So, let's go, let's go for it. Right here. Okay. Here's where we

289
00:30:34.850 --> 00:30:41.280
were. Now, let's run this because I want to show you something, a little trick that we're going to do.

290
00:30:43.900 --> 00:30:50.140
This is our real data. Notice up here, the way I collected data, it was already moving. It's not,

291
00:30:50.140 --> 00:30:56.120
it's not at, it's close, but it's not released from rest. That's fine. I want to use data where

292
00:30:56.120 --> 00:31:00.560
it's released from rest. So, I could use either one of these, these down here, but let's just go

293
00:31:00.560 --> 00:31:07.380
down here to this one. So, right down here at this position, at the bottom point, the slope of the line

294
00:31:07.380 --> 00:31:12.480
is zero. So, it's released from rest. So, I know the velocity of that point is zero. And now what I

295
00:31:12.480 --> 00:31:19.460
want to do is just look at the time, 0.533, and the position, negative 0.0.

296
00:31:20.140 --> 00:31:30.640
Point, is that 0.019? Yes. So, almost, almost two. Hey, Rhett. Yeah. So, we had a question.

297
00:31:31.460 --> 00:31:38.940
Could you do this using energy instead of kinematics? Yes. You can do it with energy, but the problem is

298
00:31:38.940 --> 00:31:45.900
that the energy, since energy is a scalar, it doesn't really give you the oscillation in the same way.

299
00:31:45.900 --> 00:31:50.600
One of the things that's really useful later that you can do for homework, and I'll talk

300
00:31:50.600 --> 00:31:56.560
about this at the end, is calculating the loss, the energy loss due to friction. And that will tell

301
00:31:56.560 --> 00:32:01.980
you why this thing decays like that. But if you want to do a numerical calculation and you start

302
00:32:01.980 --> 00:32:08.940
from energy, you're not going to, it's not going to work. Also, energy is a change in, deals with change

303
00:32:08.940 --> 00:32:19.440
in position instead of change in time. Is that good? He says thanks. Okay, great. Thanks for the

304
00:32:19.440 --> 00:32:24.100
question. So, right down here, I want to look at these points on my graph. It doesn't have to be

305
00:32:24.100 --> 00:32:29.920
perfect, but I do want to write them down. I'm going to write them down on the board. So, I have x1

306
00:32:29.920 --> 00:32:48.660
is negative 1.98 times 10 to negative 2. And t1 is 0.533. So, those are the values I want to start

307
00:32:48.660 --> 00:32:53.860
with when I start my numerical calculation. And again, because I know the velocity there,

308
00:32:54.180 --> 00:32:58.340
because I need to know both the velocity and the position. You could take anywhere. If I pick this

309
00:32:58.340 --> 00:33:03.700
point right here, then, oh, I say the position is 0. Maybe I'm very close to 0. But now I have

310
00:33:03.700 --> 00:33:07.640
to calculate the velocity. And I don't have that from this data. You could get it, but it's just

311
00:33:07.640 --> 00:33:13.960
easier to do it this way. Okay. So, back over here, all this did was plot our real data. What we're

312
00:33:13.960 --> 00:33:19.840
going to do now is make our numerical model. So, the first thing that I want to do is to make a graph

313
00:33:19.840 --> 00:33:25.220
to plot the numerical model. So, up here, I'm going to add a second curve. I'm going to call this

314
00:33:25.220 --> 00:33:32.420
fr for real. And I'm going to make it red. If you want, you can give it labels and stuff too,

315
00:33:32.440 --> 00:33:37.760
but I'm not going to do that. Now, down here, I need to start off with my initial conditions. So,

316
00:33:37.960 --> 00:33:44.540
I'm going to say t is 0.533. That's what I got from my data. That's the time I want to start it at.

317
00:33:44.980 --> 00:33:49.140
Okay. And then, I need to give it my initial x position, which I just said was, what did I say?

318
00:33:49.260 --> 00:33:54.020
Negative. I wrote on the board. That's why I write on the board. Negative 1.98 times 10 to negative 2.

319
00:33:54.020 --> 00:34:00.840
And I need my initial velocity. Notice that I didn't give indices here. It's just x.

320
00:34:01.320 --> 00:34:05.720
Because we're going to change the value of these variables. We're not going to keep up with all the

321
00:34:05.720 --> 00:34:12.160
different variables. Same thing. So, we need to change velocity, k, and t. Now, I do need a couple

322
00:34:12.160 --> 00:34:19.860
other things. I need my spring constant, which I said from before, 7.612. And I need my mass,

323
00:34:19.860 --> 00:34:27.860
which is going to be equal to 2.7 divided by 9.8. Now, if you're familiar with Python,

324
00:34:28.020 --> 00:34:34.940
you know this. But if you're not, we need to deal with numbers, right? So, we don't have units up here.

325
00:34:36.320 --> 00:34:41.880
Units are the job of the human. Numbers are the job of the computer. If you want to put your units

326
00:34:41.880 --> 00:34:47.020
here because it makes you uncomfortable to not have it, you can put it in as a comment like that.

327
00:34:47.020 --> 00:34:51.960
Anything after the number sign is ignored by Python. And you can put them all down here.

328
00:34:52.880 --> 00:34:56.740
But I don't normally do that. It does make the code look a little bit more cluttered.

329
00:34:56.820 --> 00:35:01.100
And for students, you know, it's more difficult to understand. If you just measured the mass of the

330
00:35:01.100 --> 00:35:05.680
cart, you could type it here. But we had 2.7 newtons divided by 9.8 newtons per kilogram.

331
00:35:07.180 --> 00:35:13.260
Finally, we need one more thing. And that's our time step. So, we have the time step from our data.

332
00:35:13.260 --> 00:35:17.340
But we don't have to have the same time step. We can use a different time step. So, I'm going to

333
00:35:17.340 --> 00:35:26.240
use, like I said, time step of 0.01 seconds. Now, what we want to do is to create a loop. We want

334
00:35:26.240 --> 00:35:35.480
to loop through the time. So, I'm going to say while t is less than 5. So, this will do in Python.

335
00:35:35.480 --> 00:35:43.680
We make a loop. It starts with a colon. And then everything that's tab indented underneath that

336
00:35:43.680 --> 00:35:49.220
is part of the loop. Once you de-dent, it's no longer in the loop. That's what we did up here.

337
00:35:49.600 --> 00:35:55.400
So, in this for loop, I have the colon. Everything that's tab indented below that's part of the loop.

338
00:35:55.400 --> 00:36:02.620
And then this is not part of the loop because it's de-dented. So, I want to do this while the value

339
00:36:02.620 --> 00:36:09.300
of t is less than 5. And so, I'm going to do this weird. What I'm going to do is just print t just so

340
00:36:09.300 --> 00:36:15.660
you can see how it works. Let's do it until it's 1. And the most important thing for a loop like this

341
00:36:15.660 --> 00:36:22.180
is that I have to update the value of time. If you do not update time, you will be stuck in an infinite

342
00:36:22.180 --> 00:36:28.500
loop, which seems fun, but it's in fact not fun. Okay. So, here's how you update time.

343
00:36:29.900 --> 00:36:34.780
There's more than one way to do it. This way, I always do it. So, this is not – I always point

344
00:36:34.780 --> 00:36:41.160
out to students that this is not an algebraic equation. This does not say t equals t plus dt

345
00:36:41.160 --> 00:36:49.700
because the t's would cancel. This says make the value of t this – what it was before – plus this dt.

346
00:36:49.700 --> 00:36:56.380
So, this changes the value of our time, our t variable. And so, now we don't have to keep track of all

347
00:36:56.380 --> 00:36:59.940
the different variables. We just change it. So, I'm going to run this. We're going to print out tons

348
00:36:59.940 --> 00:37:06.480
of numbers. I'm going to show you that it does indeed work. Let's do this. Print. Finished. Just so you can

349
00:37:06.480 --> 00:37:14.480
see that we did finish the loop. So, you see it went through all those time values. It printed them out.

350
00:37:14.480 --> 00:37:19.140
And then, when I de-dented, it said finished. Okay. So, that's how we're going to go through

351
00:37:19.140 --> 00:37:26.440
our list of calculations. I always like to put that t equals t plus dt in there right away

352
00:37:26.440 --> 00:37:32.700
because if you're typing stuff and you forget to put it – infinite loop. Awkward. Really awkward

353
00:37:32.700 --> 00:37:39.180
when you're teaching a class. Fortunately, they did add – at least in this version of Trinket – the

354
00:37:39.180 --> 00:37:44.260
play button to run it turns into a stop button. So, you actually can stop it. That's actually new and

355
00:37:44.260 --> 00:37:50.760
I like it a lot. Okay. So, what we want to do, just like we said on the board, is to first calculate

356
00:37:50.760 --> 00:37:52.940
the acceleration. So, I'm going to say –

357
00:37:52.940 --> 00:37:53.180
Pause.

358
00:37:53.180 --> 00:38:00.000
Pause. Yep. I got another question. I'm ready. In line 16, did we just tell Python to use

359
00:38:00.000 --> 00:38:04.640
interpolated values instead of the real data? Aren't we using one model to generate another?

360
00:38:05.320 --> 00:38:13.060
Right. So, this is – well, this dt is our numerical time step and it doesn't have to be the same as

361
00:38:13.060 --> 00:38:21.040
our real data. We're still going to plot them together and the data from Vernier sensor cart

362
00:38:21.040 --> 00:38:26.260
has a lower rate and we actually want to increase the rate. We can change that later and you can see

363
00:38:26.260 --> 00:38:31.140
what happens and we will do that. But these are two different – one's not a calculation. One's just

364
00:38:31.140 --> 00:38:37.000
data. And the other one is our calculation time step. So, they don't have to be the same.

365
00:38:38.360 --> 00:38:38.760
Thanks.

366
00:38:39.380 --> 00:38:45.880
Yep. Thank you. So, here's our acceleration. Actually, I should write it like this. Negative k

367
00:38:45.880 --> 00:38:52.240
times x over m. So, notice that we start off with the value of x up here. So, we start off with an

368
00:38:52.240 --> 00:38:57.060
acceleration in the positive direction because that's a negative number. That's the way we picked

369
00:38:57.060 --> 00:39:04.440
it. Now, I'm going to update the velocity. The velocity starts at zero and then I'm going to do

370
00:39:04.440 --> 00:39:12.430
this. So, just like the time down here when we're updating the value of time, this is again not an

371
00:39:12.430 --> 00:39:18.050
algebraic equal sign. It's a make equal to sign. Make equal to sign. It says take the value of the

372
00:39:18.050 --> 00:39:23.370
acceleration times dt, add that to v, and make that your velocity. Okay. And then finally, we need

373
00:39:23.370 --> 00:39:30.610
to update the position just like we did it before. And I'm using dt instead of delta v because I don't

374
00:39:30.610 --> 00:39:39.570
want to type delta. So, we're done except for the plotting. So, now I'm just going to – I'm going to

375
00:39:39.570 --> 00:39:44.830
plot this. One of the – you know, you can argue about whether you should plot before or after you

376
00:39:44.830 --> 00:39:51.670
update the time. It should probably be before. But the beauty of Python is with small time steps,

377
00:39:52.050 --> 00:39:56.690
it's not really wrong where you put this. And that's good. So, I'm going to call – I said this

378
00:39:56.690 --> 00:40:03.170
graph was called fr. And now here, I'm going to plot t on the horizontal axis and x because I'm

379
00:40:03.170 --> 00:40:08.030
generating those values. I'm not getting them from a list. I'm generating them each time. So, let's run

380
00:40:08.030 --> 00:40:14.650
this and hopefully we don't make a disaster of the whole thing and see what happens. That's

381
00:40:14.650 --> 00:40:21.630
actually pretty good. Okay. It's not exactly the same. It's not. But it's still – you get that

382
00:40:21.630 --> 00:40:28.390
cosine function or sine function depending where you put your origin, which is awesome because it's

383
00:40:28.390 --> 00:40:35.590
not in the code anywhere. And it's not perfectly the same because of this friction that we have over

384
00:40:35.590 --> 00:40:43.330
here. But it turns out that you can actually add the frictional force and make it much more the same.

385
00:40:43.790 --> 00:40:53.830
So, let's go to the board for a second and show how to do that. So, here's my net force I just have

386
00:40:53.830 --> 00:41:00.470
as a spring force. But what if I say the net force is the spring force plus some frictional force?

387
00:41:00.470 --> 00:41:15.820
So, I'm going to delete that. So, the net force is the spring force plus friction. And that's equal to

388
00:41:15.820 --> 00:41:23.420
mass times acceleration. Now, we do have a problem with the friction force because as the cart's moving

389
00:41:23.420 --> 00:41:28.720
this way, friction's that way. And the cart's moving this way, friction's that way. So, we need to

390
00:41:28.720 --> 00:41:35.740
determine the value, the direction of the frictional force based on the direction of the cart. But we

391
00:41:35.740 --> 00:41:41.160
can do that. Okay. And I'm just going to – you can measure the coefficient of kinetic friction for

392
00:41:41.160 --> 00:41:44.880
the cart, but we're just going to guess. Okay. We're just going to guess at a value and see if we can

393
00:41:44.880 --> 00:41:56.700
get it to work. So, let's switch back to the Python and my code right here. So, what I want to do

394
00:41:56.700 --> 00:42:06.180
is let's just say that if V is greater than zero, okay, if the value of V is greater than zero,

395
00:42:06.280 --> 00:42:13.580
then it's positive, then my acceleration is going to be this. And I want the friction force to be in

396
00:42:13.580 --> 00:42:20.420
the negative X direction. So, I'm going to say negative, let's say 0.001 times M times G. So,

397
00:42:20.580 --> 00:42:25.160
that'd be a coefficient of friction of 0.001. I'm just guessing here. We're going to change it.

398
00:42:25.160 --> 00:42:33.640
Okay. And if it's not greater than zero, I'm going to say else A equals negative K times X over M

399
00:42:33.640 --> 00:42:41.160
plus 0.001 times M times G. Okay. So, now I have a friction that changes direction. Let's just run

400
00:42:41.160 --> 00:42:49.600
it and see what kind of damage we did. Oh, I have an error. Good. G is not defined. I can fix that.

401
00:42:49.600 --> 00:43:05.260
G equals 9.8. Okay. So, it looks like it didn't have enough friction maybe. That's fine. Let's change

402
00:43:05.260 --> 00:43:17.440
this to five. Let's see what happens there. Okay. Now, it's starting to look better. You can see that

403
00:43:17.440 --> 00:43:24.660
the amplitude is decreasing. This red curve is my calculation. Notice that the amplitude is larger,

404
00:43:24.660 --> 00:43:29.480
so I need a little bit more friction. So, more friction. I'm just going to, I'm just manually

405
00:43:29.480 --> 00:43:36.950
changing this. I'm just guessing numbers. You could call it a variable if you want. We're getting

406
00:43:36.950 --> 00:43:43.890
really close. Okay. I think my period of oscillation is a little off. I think that's the best I can do.

407
00:43:44.790 --> 00:43:50.090
Maybe my spring constant is off a little bit or my mass is off a little bit. Let's just mainly adjust

408
00:43:50.090 --> 00:43:56.760
that spring constant. I'll make it a little bit. Which way do I want to go? Got another question?

409
00:43:57.240 --> 00:44:04.840
I'm ready. Is there a reason to use if then rather than sine of v or something similar?

410
00:44:06.280 --> 00:44:14.850
I mean, if else? You could say, yeah, you could say if v is greater than zero, do this. And you could

411
00:44:14.850 --> 00:44:19.550
say if v is less than zero, do this. But in this case, we're going to do one or the other. We're going

412
00:44:19.550 --> 00:44:25.250
to either make it a positive x component friction or negative x component friction. So, in that case,

413
00:44:25.330 --> 00:44:31.650
an if else works a little bit better. It's less cumbersome. You could just say if it's greater than

414
00:44:31.650 --> 00:44:39.330
zero, do this. If it's less than zero, do that. And that would work the same. Thanks. Okay. I'm not

415
00:44:39.330 --> 00:44:45.030
going to try to make this match perfectly. I'm happy enough with it where it is, especially doing it

416
00:44:45.030 --> 00:44:54.130
live. So, I think maybe we could stop there and if you have any questions. But I do want to point out

417
00:44:54.130 --> 00:45:01.210
one important thing. We did what we wanted, right? We have real data and we can show, even if you play

418
00:45:01.210 --> 00:45:06.870
with a little bit more, that you can make that data fit a numerical model. And then that's the win

419
00:45:06.870 --> 00:45:11.570
right there. That's the scientific process. Getting data, building a model, ensuring that

420
00:45:11.570 --> 00:45:16.650
they agree. Even if there's some messing around with it, we can make it look a little bit better.

421
00:45:17.230 --> 00:45:23.610
So, do we have any other questions? Or I think that'd probably be the best place to stop for the

422
00:45:23.610 --> 00:45:28.470
code. I'll put it back on the code. And I'll give you a link to the code, too, if you want to.

423
00:45:28.470 --> 00:45:39.210
Yeah. So, the previous question was a mistype. There's a reason to use if then rather than if

424
00:45:39.210 --> 00:45:41.690
else, or if else rather than if then.

425
00:45:43.430 --> 00:45:44.270
If then.

426
00:45:45.310 --> 00:45:49.270
Oops. No, I'm doing it wrong. Robert, could you please retype the question then?

427
00:45:49.270 --> 00:46:09.170
If we could just use one statement with

428
00:46:09.170 --> 00:46:15.090
the sine of V. So, positive or negative V instead of the if else.

429
00:46:15.650 --> 00:46:22.290
Yeah. What you could do is you could put, if you put this right here, let's just copy that

430
00:46:22.290 --> 00:46:26.970
temporarily. I just didn't think of it this way. Here, I go through and I set the acceleration.

431
00:46:27.850 --> 00:46:32.070
And then I could down here say, well, if the velocity is the other way, change it to this.

432
00:46:32.070 --> 00:46:37.270
And that would work. So, it automatically put the acceleration with a positive frictional

433
00:46:37.270 --> 00:46:42.630
force. And then it would change it to negative only if the velocity is positive. That would do

434
00:46:42.630 --> 00:46:49.510
the same thing. You know, either way is fine. I'm not a Python programmer. I just use Python

435
00:46:49.510 --> 00:46:53.930
to do physics. So, everyone does things differently. And that's fine. If you have students that come

436
00:46:53.930 --> 00:46:59.230
in that are programming, they're like, oh, I don't like this. This V equals V plus. They like

437
00:46:59.230 --> 00:47:04.270
to use equals plus sign. And that's fine if you want to do it that way. I like this way just because

438
00:47:04.270 --> 00:47:08.510
it matches what we do on the board the best. So, again, all those little things like that.

439
00:47:08.910 --> 00:47:15.050
There's a lot of different ways to get this to work. And I try to do the simplest way that makes

440
00:47:15.050 --> 00:47:22.970
the most sense to students. And really, the test is, does it match what actually happens, right?

441
00:47:23.290 --> 00:47:28.730
Like, if it's matching the actual data or not. So, another question was, does Python give better

442
00:47:28.730 --> 00:47:33.530
results than Desmos, which is more intuitive for my high school students? Well, not mine.

443
00:47:33.530 --> 00:47:38.890
I don't use, I mean, if you do, if you could do the same thing in the spreadsheet. And I remember

444
00:47:38.890 --> 00:47:44.090
a long time ago, I used to use a spreadsheet to do this exact same thing. You could do it on paper,

445
00:47:44.090 --> 00:47:48.730
right? It does, what gives the best results is your time step. And so, if you change your time step,

446
00:47:48.730 --> 00:47:52.890
let's just change the time step to 0.1. And I'm going to run this and you can see what happens.

447
00:47:54.730 --> 00:48:00.730
So, now you can see a lot blockier code, right? And the calculation isn't nearly as good.

448
00:48:00.730 --> 00:48:07.370
The smaller the time step, the better. And so, it's not Desmos versus a spreadsheet versus

449
00:48:07.370 --> 00:48:12.970
Python versus Java. It's the recipe. It's the numerical recipe that tells you whether it's good

450
00:48:12.970 --> 00:48:18.730
or not. And as long, as well as the time step, I'm going to make it even smaller. And there you

451
00:48:18.730 --> 00:48:25.130
get even better values. I don't know what Desmos does. I've just never really played with that too

452
00:48:25.130 --> 00:48:35.580
much. But if you use the same recipe, you'd get the same data. Great.

453
00:48:35.580 --> 00:48:41.510
So, then we got another question. I think we are

454
00:48:44.630 --> 00:48:50.470
not trying to discuss this model, but could you try with a drag force for friction?

455
00:48:50.470 --> 00:48:55.510
So, like a velocity-dependent force. I think you don't need that,

456
00:48:56.310 --> 00:49:00.470
based on my small amplitude. But yeah, you can put any forces that you want in here. And that's

457
00:49:00.470 --> 00:49:05.670
another thing that you can try, right? I have it at an angle. You can add a gravitational force in

458
00:49:05.670 --> 00:49:11.110
here and see what happens. And if you have a constant force added to this, it doesn't change

459
00:49:11.110 --> 00:49:17.670
the period of oscillation, which is really good. But if you want to have like, let's say, C equals

460
00:49:17.670 --> 00:49:24.150
0.001. There's my drag coefficient. All I need to do is add it in my acceleration down here. Oh,

461
00:49:24.150 --> 00:49:29.030
you know what I did wrong? I didn't divide this by the mass. That was my problem. See,

462
00:49:29.030 --> 00:49:33.350
because I have the acceleration. I put it in the force. Let's see if that makes a big difference.

463
00:49:33.350 --> 00:49:38.310
Well, anyway, I'm going to add in... Again, it depends on the velocity. Actually,

464
00:49:38.310 --> 00:49:42.710
this one doesn't depend on the velocity, because if the velocity is positive, then the drag force

465
00:49:42.710 --> 00:49:50.790
would be negative. So, negative C times V over M. I'll put it down here. Negative C times V over M.

466
00:49:50.790 --> 00:49:55.830
So, that's a linear drag force, not a quadratic drag force. But you can add anything in there

467
00:49:55.830 --> 00:50:01.910
that you want. So, that one died down really quickly and just stopped. Okay? Too much drag.

468
00:50:01.910 --> 00:50:07.590
That's in oil. But you can change this drag coefficient to something small and run it.

469
00:50:09.030 --> 00:50:15.270
It's still too small. I don't know what I did wrong there. Oh, did I... Okay, I'm just going to delete

470
00:50:15.270 --> 00:50:21.590
that stuff. You could do it. How about that? The answer is you could do it. Another question is,

471
00:50:21.590 --> 00:50:25.830
would you ever have your students calculate the normal force and attempt to determine the friction

472
00:50:25.830 --> 00:50:40.390
from that? Oh, I did mess something up. Would the... So, what I would do is to measure the angle of the

473
00:50:40.390 --> 00:50:46.150
incline. You do a normal free body diagram and calculate the normal force, calculate the frictional

474
00:50:46.150 --> 00:50:50.070
force, measure the frictional coefficient experimentally, which you could do by just

475
00:50:50.070 --> 00:50:54.630
pushing the card on the track and measuring the acceleration as it rolls down the track,

476
00:50:54.630 --> 00:50:57.430
and then use that value. That would work just fine.

477
00:51:01.130 --> 00:51:06.730
And then, do students ask why you use the spring force without gravity? What happened to the gravitational

478
00:51:06.730 --> 00:51:14.330
force? Yeah. So, you can add that in there, and it works just fine. And I typically do. I don't

479
00:51:14.330 --> 00:51:20.410
normally... Normally, what I would do is have them just oscillate the spring up and down because it's way

480
00:51:20.410 --> 00:51:26.010
easier to do. But you don't get position versus time data like you do with the cart. So, you just get

481
00:51:26.010 --> 00:51:31.130
period data. And then, when I have them model it horizontally, they don't even see the spring

482
00:51:31.130 --> 00:51:35.690
or gravity, and it makes a little bit easier. But you can add that in. It works just fine if you add

483
00:51:35.690 --> 00:51:47.260
in the gravitational force. Does anyone else have any questions they want to type into the chat?

484
00:52:04.980 --> 00:52:09.380
I'm not seeing any other questions, Rhett. Okay. Well, that's fine. I mean, ask questions,

485
00:52:09.380 --> 00:52:15.140
not ask questions. It's all good with me. I have a fun time doing Python, so that's all that matters.

486
00:52:15.140 --> 00:52:22.260
Yeah. So, a question. I've used the position sensors to find force and position data on a spring.

487
00:52:22.260 --> 00:52:30.740
Could we use this with that data? So, force and position data, and then model it in Python.

488
00:52:31.380 --> 00:52:37.380
So, I mean, that's... You could plot the force as a function of position in Python for sure,

489
00:52:37.380 --> 00:52:41.940
but you don't really gain anything more than the data straight from

490
00:52:42.820 --> 00:52:46.740
graphical analysis, because you'd just be taking that data and plotting it in Python.

491
00:52:49.140 --> 00:52:57.460
We essentially did model the force of the function of distance by assuming the acceleration right here

492
00:52:57.460 --> 00:53:02.740
is negative K times X divided by the mass. So, that is this... That's using that model. That's

493
00:53:02.740 --> 00:53:05.940
choosing Hooke's Law and assuming that's the model for our spring force.

494
00:53:05.940 --> 00:53:17.080
All right. There is a question about an easy or automated way to export a CSV from the Vernier

495
00:53:17.080 --> 00:53:22.600
software. And so, I was answering that in the chat. But basically, if you show the data table

496
00:53:22.600 --> 00:53:29.640
in graphical analysis, it has to be showing. Then go up to the top left and there's that little icon

497
00:53:29.640 --> 00:53:37.080
with the dog-eared page. You'll find export there. And then from... If you click on export,

498
00:53:37.080 --> 00:53:44.360
you'll have the opportunity to export a CSV. It's pretty easy. You can also do what Rhett did

499
00:53:44.360 --> 00:53:53.240
and click at the top... Top left. Oh, yeah. Right there. Yeah. Yeah. So, you can see one of those

500
00:53:53.240 --> 00:53:59.400
choices is the CSV. But you can also just double click at the top of the column and that should

501
00:53:59.400 --> 00:54:04.360
select the entire column. And then you can use your keyboard commands to do copy and paste or your

502
00:54:04.360 --> 00:54:10.440
mouse left click or whatever. Right click, rather. The one thing that I like to do with

503
00:54:10.440 --> 00:54:17.000
the way I did it is because I want... If you have the CSV data file, it's got both of them in there.

504
00:54:17.000 --> 00:54:21.000
So, it's a little bit more work to separate them in Python in terms of time and position,

505
00:54:22.040 --> 00:54:27.640
whereas the way I did it, it already gives... We just have position. We just did position. And we just

506
00:54:27.640 --> 00:54:32.200
did time. So, it's a little bit easier to put it into Python. You can do it this way, too. There's a little

507
00:54:32.200 --> 00:54:44.020
bit more stuff that you would need to do to get that to work, though. All right. We got it. Thanks for

508
00:54:44.020 --> 00:54:52.980
that. I think Dylan has something to say. Yes. Yeah. Well, first, thank you so much, Rhett

509
00:54:52.980 --> 00:55:02.340
and Fran. What an amazing presentation. Really good conversations. So, as we were going through the

510
00:55:02.340 --> 00:55:07.940
presentation, I actually entered everyone's names into a random name generator. This is not influenced by

511
00:55:07.940 --> 00:55:15.540
the very kind compliment that was just dropped in the chat. The winner of $100 gift card to Vernier is

512
00:55:15.540 --> 00:55:24.100
Stuart F. So, congratulations, Stuart. That is what the internet decided today. I have your information

513
00:55:24.100 --> 00:55:29.300
from when you registered for the webinar. So, I'm going to email you. If you don't see an email from

514
00:55:29.300 --> 00:55:35.940
someone with an at Vernier domain, it might be in your spam. But, otherwise, congratulations.

515
00:55:35.940 --> 00:55:39.220
Congratulations, Stuart. Yes.

516
00:55:39.220 --> 00:55:51.380
All right, my friends. Any last-minute questions that anyone has for you? Let's see.

517
00:55:52.180 --> 00:55:55.060
I hope you're reading the chat, Rhett, because you're getting some compliments.

518
00:55:55.060 --> 00:55:58.980
Oh, let's see. I'm only on that. See, I need to do all chat. I don't know how to do all

519
00:56:00.660 --> 00:56:07.400
how to get that. Live view. So, it should be on the right-hand side. It might be under more.

520
00:56:09.000 --> 00:56:10.520
And it says attendee chat.

521
00:56:15.850 --> 00:56:17.850
More. There's more. Attendees.

522
00:56:17.850 --> 00:56:22.410
No, that's not the chat. And then under attendees, it should say attendee chat.

523
00:56:24.650 --> 00:56:27.690
There it is. Got it. Awesome. Thank you.

524
00:56:29.690 --> 00:56:36.010
Thank you very much. See, where am I typed in there? I think my things are big enough.

525
00:56:38.860 --> 00:56:47.750
There we go. All right. Well, I see no further questions. So,

526
00:56:47.750 --> 00:56:51.910
oh, great. Rhett popped a link to the code in there. So, you should be able to grab that.

527
00:56:52.710 --> 00:56:59.030
And then we are good. Thank you all so much for attending. And I hope you have a great rest of

528
00:56:59.030 --> 00:57:04.390
your Thursday. And wherever you are, stay warm or cool. Whatever weather would be optimal for you.

529
00:57:07.190 --> 00:57:09.350
And dry if it's wet where you are. Yes.
