1 00:00:00,000 --> 00:00:00,030 2 00:00:00,030 --> 00:00:02,400 The following content is provided under a Creative 3 00:00:02,400 --> 00:00:03,780 Commons license. 4 00:00:03,780 --> 00:00:06,020 Your support will help MIT OpenCourseWare 5 00:00:06,020 --> 00:00:10,100 continue to offer high quality educational resources for free. 6 00:00:10,100 --> 00:00:12,670 To make a donation or to view additional materials 7 00:00:12,670 --> 00:00:16,405 from hundreds of MIT courses, visit MIT OpenCourseWare 8 00:00:16,405 --> 00:00:17,030 at osw.mit.edu. 9 00:00:17,030 --> 00:00:31,710 10 00:00:31,710 --> 00:00:35,600 QIQI WANG: So today, we're going to be continuing finite volume. 11 00:00:35,600 --> 00:00:38,410 We started on finite volume on Monday. 12 00:00:38,410 --> 00:00:41,010 And just a very quick recap, finite volume 13 00:00:41,010 --> 00:00:43,630 doesn't solve all the differential equations, 14 00:00:43,630 --> 00:00:46,270 but it solves a class of differential equations 15 00:00:46,270 --> 00:00:51,420 that we care most, that is conservation laws. 16 00:00:51,420 --> 00:00:55,430 Conservation laws are differential equations that 17 00:00:55,430 --> 00:00:57,820 can be returned in this form. 18 00:00:57,820 --> 00:01:00,640 And today, I'm just going to be more specific. 19 00:01:00,640 --> 00:01:07,440 Let's say, rho is the density of a conservative quantity. 20 00:01:07,440 --> 00:01:15,470 The time derivative of rho plus the divergence of a flux, 21 00:01:15,470 --> 00:01:18,530 which is a function of rho, is equal to 0. 22 00:01:18,530 --> 00:01:22,560 So this is a general conservation law 23 00:01:22,560 --> 00:01:25,650 when there is no [INAUDIBLE], when there is no generation 24 00:01:25,650 --> 00:01:31,575 or it's appearing off any material within the control 25 00:01:31,575 --> 00:01:32,860 volume. 26 00:01:32,860 --> 00:01:35,980 Everything that increases has to come from outside the control 27 00:01:35,980 --> 00:01:36,540 volume. 28 00:01:36,540 --> 00:01:42,460 Anything that decreases has to go out of the control volume. 29 00:01:42,460 --> 00:01:49,460 And this is the differential form. 30 00:01:49,460 --> 00:01:51,910 And in one dimension of cos, the divergence 31 00:01:51,910 --> 00:01:54,210 is just spatial derivative. 32 00:01:54,210 --> 00:01:58,080 It's just a partial x of F of rho. 33 00:01:58,080 --> 00:01:59,720 And today we have going to be solving 34 00:01:59,720 --> 00:02:03,650 one of the equations like this. 35 00:02:03,650 --> 00:02:07,210 And in order to apply finite volume, 36 00:02:07,210 --> 00:02:11,690 we need to make it an integral form. 37 00:02:11,690 --> 00:02:18,220 We have to really integrate this in space. 38 00:02:18,220 --> 00:02:26,220 And instead of a divergence operating space, 39 00:02:26,220 --> 00:02:31,831 we get this-- d dt of an integral over any control 40 00:02:31,831 --> 00:02:32,330 volume. 41 00:02:32,330 --> 00:02:35,280 Let me describe it as omega. 42 00:02:35,280 --> 00:02:38,630 Omega is a control volume. 43 00:02:38,630 --> 00:02:43,110 So we are basically integrating this whole thing in omega. 44 00:02:43,110 --> 00:02:44,930 And this is the first thing we get. 45 00:02:44,930 --> 00:02:47,783 And the second thing we get is that now we 46 00:02:47,783 --> 00:02:50,788 are doing this in impossibly multiple dimensions, 47 00:02:50,788 --> 00:02:53,650 like last week [INAUDIBLE]. 48 00:02:53,650 --> 00:02:58,862 Now if you integrate the divergence of something-- 49 00:02:58,862 --> 00:03:01,658 you're integrating a divergence of a vector 50 00:03:01,658 --> 00:03:04,210 field-- in a control volume, what do you get? 51 00:03:04,210 --> 00:03:07,010 52 00:03:07,010 --> 00:03:10,120 A listing something like the integral 53 00:03:10,120 --> 00:03:12,670 of a divergence of a vector in a control volume 54 00:03:12,670 --> 00:03:14,023 equal to something [INAUDIBLE]. 55 00:03:14,023 --> 00:03:24,166 56 00:03:24,166 --> 00:03:25,607 Something can relate a divergence. 57 00:03:25,607 --> 00:03:29,086 58 00:03:29,086 --> 00:03:30,760 [INAUDIBLE] the divergence 0. 59 00:03:30,760 --> 00:03:34,536 60 00:03:34,536 --> 00:03:39,290 [INAUDIBLE] is so cool. 61 00:03:39,290 --> 00:03:42,925 There are two theorems in method popular that I 62 00:03:42,925 --> 00:03:45,660 can see that are very important, both 63 00:03:45,660 --> 00:03:51,470 relating a spatial derivative to a spatial integral. 64 00:03:51,470 --> 00:03:56,650 And the divergence theorem is the more fundamental one. 65 00:03:56,650 --> 00:03:58,070 I can feel a more fundamental one, 66 00:03:58,070 --> 00:04:04,060 because it basically tells you the spatial integral 67 00:04:04,060 --> 00:04:09,880 of a divergence can be expressed with something that doesn't 68 00:04:09,880 --> 00:04:12,530 involve derivative at all. 69 00:04:12,530 --> 00:04:17,140 It can be represented as the integral over the surface 70 00:04:17,140 --> 00:04:18,920 of the control volume. 71 00:04:18,920 --> 00:04:25,030 The surface normal starts with just the flux vector 72 00:04:25,030 --> 00:04:27,710 is equal to 0. 73 00:04:27,710 --> 00:04:32,480 So divergence theorem says that the integral of this 74 00:04:32,480 --> 00:04:36,582 is equal to this-- divergence theorem. 75 00:04:36,582 --> 00:04:39,110 76 00:04:39,110 --> 00:04:42,740 So what you see is that this is the 2D or 3D version 77 00:04:42,740 --> 00:04:47,390 of the integral form of the conservation law. 78 00:04:47,390 --> 00:04:50,630 What we are saying is that now, again, this 79 00:04:50,630 --> 00:04:55,658 is the total amount of mass, or stuff, within the control 80 00:04:55,658 --> 00:04:56,336 volume. 81 00:04:56,336 --> 00:04:58,400 And today we're going to be doing half. 82 00:04:58,400 --> 00:05:00,210 We see that the total [INAUDIBLE] 83 00:05:00,210 --> 00:05:02,600 half within a control volume. 84 00:05:02,600 --> 00:05:09,230 And this is the flux through anywhere in the surface. 85 00:05:09,230 --> 00:05:12,090 So there is a normal. 86 00:05:12,090 --> 00:05:16,540 And this normal is also at normal of the control volume. 87 00:05:16,540 --> 00:05:18,776 So n points towards the outset. 88 00:05:18,776 --> 00:05:23,855 So this F of rho is the flux towards the outset. 89 00:05:23,855 --> 00:05:30,157 That makes sense, because if F points outward-- 90 00:05:30,157 --> 00:05:33,510 if the flux is towards the outside-- then 91 00:05:33,510 --> 00:05:36,880 this term would be positive, because F 92 00:05:36,880 --> 00:05:38,240 is going to be aligned with n. 93 00:05:38,240 --> 00:05:39,890 This term is positive. 94 00:05:39,890 --> 00:05:42,260 And the time derivative will be negative 95 00:05:42,260 --> 00:05:46,340 because things are going out, the stuff should decrease. 96 00:05:46,340 --> 00:05:49,468 If asked if the flux vector points inward, then 97 00:05:49,468 --> 00:05:54,040 it is going opposite to the outward point of normal, 98 00:05:54,040 --> 00:05:55,264 opposite to n. 99 00:05:55,264 --> 00:05:58,420 And this integral would be negative. 100 00:05:58,420 --> 00:06:01,120 So if this thing is negative, then we have to add to 0 101 00:06:01,120 --> 00:06:04,490 so this can have some positive, which means the amount of stuff 102 00:06:04,490 --> 00:06:08,218 is going to increase as a function of time. 103 00:06:08,218 --> 00:06:09,600 Is it clear? 104 00:06:09,600 --> 00:06:13,450 This is now generalizing that in 2D or 3D. 105 00:06:13,450 --> 00:06:16,910 And of course, we can still write that in 1D. 106 00:06:16,910 --> 00:06:20,710 In the one dimensional special case, 107 00:06:20,710 --> 00:06:24,980 what is this partial omega? 108 00:06:24,980 --> 00:06:27,860 Partial omega is the boundary of omega. 109 00:06:27,860 --> 00:06:31,152 What is the boundary of the one dimensional control volume? 110 00:06:31,152 --> 00:06:34,100 111 00:06:34,100 --> 00:06:38,680 The point, or two points-- two points, right? 112 00:06:38,680 --> 00:06:45,500 And the two points, I have R and L. And outward pointing normal 113 00:06:45,500 --> 00:06:49,170 is going to be just a 1 at the right hand side at R, 114 00:06:49,170 --> 00:06:51,830 is going to be minus 1 at L. So I'm just 115 00:06:51,830 --> 00:06:59,040 going to be saying this is F of rho at R minus F of rho at L 116 00:06:59,040 --> 00:07:00,688 is equal to 0. 117 00:07:00,688 --> 00:07:05,960 Or as we said on Monday, the time derivative of total stuff 118 00:07:05,960 --> 00:07:10,942 is equal to the stuff coming in from the left minus the stuff 119 00:07:10,942 --> 00:07:14,344 coming out from the right, if you moved both of this stuff 120 00:07:14,344 --> 00:07:18,850 [INAUDIBLE] side by side. 121 00:07:18,850 --> 00:07:23,690 So this is the kind of differential equations 122 00:07:23,690 --> 00:07:29,630 we are solving, and the scheme is finite volume. 123 00:07:29,630 --> 00:07:37,120 And finite volume basically follows exactly this formula. 124 00:07:37,120 --> 00:07:40,300 Instead of integral over control volume, 125 00:07:40,300 --> 00:07:44,760 we are storing the average of the control volume, which 126 00:07:44,760 --> 00:07:47,650 is simply the integral divided by the size of the control 127 00:07:47,650 --> 00:07:50,030 volume. 128 00:07:50,030 --> 00:07:53,870 It could modify the cell average with the size of the cell, 129 00:07:53,870 --> 00:07:56,360 with the integral. 130 00:07:56,360 --> 00:07:59,420 And in order to think of the DDP of the cell average, 131 00:07:59,420 --> 00:08:06,025 you just divide this also by the cell volume, or cell size. 132 00:08:06,025 --> 00:08:08,662 So you get the evolution equation 133 00:08:08,662 --> 00:08:14,010 that allows you to control using finite volume. 134 00:08:14,010 --> 00:08:19,030 Now this equation is not approximate This is exact. 135 00:08:19,030 --> 00:08:23,290 What we need to approximate in finite volume is this flux. 136 00:08:23,290 --> 00:08:27,230 This flux is a flux evaluated after the cell boundaries 137 00:08:27,230 --> 00:08:29,428 or cell [INAUDIBLE]. 138 00:08:29,428 --> 00:08:32,260 And the finite volume is [INAUDIBLE]. 139 00:08:32,260 --> 00:08:33,924 You only have the cell average. 140 00:08:33,924 --> 00:08:38,324 So you need to approximate the interface value from the cell 141 00:08:38,324 --> 00:08:38,990 average. 142 00:08:38,990 --> 00:08:42,030 And that is the approximation we have been talking about. 143 00:08:42,030 --> 00:08:45,460 144 00:08:45,460 --> 00:08:47,400 So that's kind of a review. 145 00:08:47,400 --> 00:08:49,810 The first new thing we're going to talk about 146 00:08:49,810 --> 00:08:53,960 is, actually, why do we use finite volume. 147 00:08:53,960 --> 00:08:59,670 We use finite volume because it captures shock waves, 148 00:08:59,670 --> 00:09:03,360 because if there is discontinuity in the solution, 149 00:09:03,360 --> 00:09:05,440 finite difference doesn't work. 150 00:09:05,440 --> 00:09:08,530 I'm going to show you with a-- what? 151 00:09:08,530 --> 00:09:10,790 Cancel. 152 00:09:10,790 --> 00:09:17,522 I'm still testing around with the code you wrote. 153 00:09:17,522 --> 00:09:20,261 But let me go to today's directory, 154 00:09:20,261 --> 00:09:21,760 and I'm going to show you two demos. 155 00:09:21,760 --> 00:09:24,290 156 00:09:24,290 --> 00:09:29,490 I'm going to show you a simulate-- so first, 157 00:09:29,490 --> 00:09:31,920 I'm going to tell you what this is doing. 158 00:09:31,920 --> 00:09:36,730 So I have two functions, one is simulate fv, 159 00:09:36,730 --> 00:09:39,420 and one is simulate fd. 160 00:09:39,420 --> 00:09:44,850 So these two functions are identical, 161 00:09:44,850 --> 00:09:48,510 except for this single letter. 162 00:09:48,510 --> 00:09:50,276 One is fd, one's fv. 163 00:09:50,276 --> 00:09:51,900 But otherwise, I'm just doing the same. 164 00:09:51,900 --> 00:09:54,300 I'm using [INAUDIBLE] 45 to integrate in time. 165 00:09:54,300 --> 00:09:56,980 166 00:09:56,980 --> 00:09:59,550 Conditions on that I'm [INAUDIBLE] 167 00:09:59,550 --> 00:10:01,900 having space, using either finite volume 168 00:10:01,900 --> 00:10:03,920 or finite difference. 169 00:10:03,920 --> 00:10:07,870 I see there is a question on what this ''at'' do. 170 00:10:07,870 --> 00:10:12,860 This "at" is basically take a function I wrote, 171 00:10:12,860 --> 00:10:19,550 which is either du dp fv or du dp fd 172 00:10:19,550 --> 00:10:24,340 and feed that into the ODE 45. 173 00:10:24,340 --> 00:10:28,489 Anytime you use ODE 45 you need this "at" to make it work. 174 00:10:28,489 --> 00:10:30,655 Now the difference between finding fd and finding fv 175 00:10:30,655 --> 00:10:34,444 is that in this we're using the standard finite difference 176 00:10:34,444 --> 00:10:37,369 to solve the differential form of the Burger's equation. 177 00:10:37,369 --> 00:10:41,536 178 00:10:41,536 --> 00:10:47,869 So du dp is equal to minus u times du dx. 179 00:10:47,869 --> 00:10:48,855 This is du dx. 180 00:10:48,855 --> 00:10:50,827 Now you should be familiar with this. 181 00:10:50,827 --> 00:10:55,530 I'm taking u minus a specific version of u-- 182 00:10:55,530 --> 00:11:00,270 this is assuming [INAUDIBLE] conditions-- divided by dx. 183 00:11:00,270 --> 00:11:08,400 So this is a [INAUDIBLE] space on a difference of du dx. 184 00:11:08,400 --> 00:11:10,570 So here I am solving the differential form 185 00:11:10,570 --> 00:11:13,620 of the equation of the finite difference. 186 00:11:13,620 --> 00:11:18,790 In finite volume-- let's review what we do in finite volume. 187 00:11:18,790 --> 00:11:20,950 du dx [INAUDIBLE] flux. 188 00:11:20,950 --> 00:11:23,386 Now, this is not using the differential form, 189 00:11:23,386 --> 00:11:25,102 but using the [INAUDIBLE] form because we 190 00:11:25,102 --> 00:11:26,670 are computing the flux. 191 00:11:26,670 --> 00:11:31,520 And here, I'm assuming the opposite direction 192 00:11:31,520 --> 00:11:34,410 is always the left. 193 00:11:34,410 --> 00:11:37,230 Here, I'm assuming like I have an initial condition that 194 00:11:37,230 --> 00:11:41,648 is opposite, and it's easy to illustrate 195 00:11:41,648 --> 00:11:43,620 using a case like that. 196 00:11:43,620 --> 00:11:47,010 So the wind always come from the left, u is always positive. 197 00:11:47,010 --> 00:11:59,080 That means when [INAUDIBLE] it is a minus [INAUDIBLE]. 198 00:11:59,080 --> 00:12:04,825 And I'm doing du dt equal to flux at the left minus flux 199 00:12:04,825 --> 00:12:06,290 at the right divided by dx. 200 00:12:06,290 --> 00:12:07,990 So this is finite volume. 201 00:12:07,990 --> 00:12:12,070 So let's see, what is the key difference between the results 202 00:12:12,070 --> 00:12:13,790 of these two schemes. 203 00:12:13,790 --> 00:12:16,737 And in either one, I'm starting with something positive, 204 00:12:16,737 --> 00:12:20,535 so sine x plus 1 over 2 because I'm assuming also 205 00:12:20,535 --> 00:12:22,170 in finite difference and finite volume, 206 00:12:22,170 --> 00:12:23,622 the wind comes from the left. 207 00:12:23,622 --> 00:12:25,080 So that I'm doing [? backwarding ?] 208 00:12:25,080 --> 00:12:30,614 space is a finite difference or finite volume. 209 00:12:30,614 --> 00:12:32,506 So I have a positive solution. 210 00:12:32,506 --> 00:12:35,390 I told them to see how it does. 211 00:12:35,390 --> 00:12:37,912 So I'm going to [INAUDIBLE] on a different sort, 212 00:12:37,912 --> 00:12:39,370 and somebody new will tell me, what 213 00:12:39,370 --> 00:12:42,520 is wrong with a finite difference solution. 214 00:12:42,520 --> 00:12:43,570 Watch carefully. 215 00:12:43,570 --> 00:12:44,750 I'm going to start. 216 00:12:44,750 --> 00:12:48,390 You need to tell me what's going wrong. 217 00:12:48,390 --> 00:12:50,670 So it looks like any Burger's equation. 218 00:12:50,670 --> 00:12:52,236 I mean, we have a shock wave. 219 00:12:52,236 --> 00:12:54,110 Things are going. 220 00:12:54,110 --> 00:12:58,994 So what's wrong with this? 221 00:12:58,994 --> 00:13:01,410 Is anything wrong? 222 00:13:01,410 --> 00:13:04,100 Solution [INAUDIBLE]. 223 00:13:04,100 --> 00:13:04,870 Let me run again. 224 00:13:04,870 --> 00:13:13,952 225 00:13:13,952 --> 00:13:15,300 Anything looks wrong? 226 00:13:15,300 --> 00:13:18,910 227 00:13:18,910 --> 00:13:21,994 Many different circles it'd be tracing, but it's not. 228 00:13:21,994 --> 00:13:22,946 AUDIENCE: [INAUDIBLE] 229 00:13:22,946 --> 00:13:27,699 230 00:13:27,699 --> 00:13:28,990 QIQI WANG: You have sharp eyes. 231 00:13:28,990 --> 00:13:32,110 Now, let's look at the finite volume solution. 232 00:13:32,110 --> 00:13:34,977 Exactly the same, but using finite volume. 233 00:13:34,977 --> 00:13:38,260 234 00:13:38,260 --> 00:13:39,320 What's the difference? 235 00:13:39,320 --> 00:13:42,380 236 00:13:42,380 --> 00:13:45,900 This [INAUDIBLE] the shock wave is correct in this case. 237 00:13:45,900 --> 00:13:48,800 While the shock just [INAUDIBLE] it forms, 238 00:13:48,800 --> 00:13:51,760 the finite difference just stands there. 239 00:13:51,760 --> 00:13:55,170 The speed of the shock wave is finite difference, 240 00:13:55,170 --> 00:13:58,310 is wrong in finite difference. 241 00:13:58,310 --> 00:14:03,700 So by using the differential form of the equation 242 00:14:03,700 --> 00:14:09,410 and disregarding the conservative form, 243 00:14:09,410 --> 00:14:13,913 you are not guaranteed to have the correct speed of the shock 244 00:14:13,913 --> 00:14:14,918 wave. 245 00:14:14,918 --> 00:14:18,540 It actually solves the other part correctly. 246 00:14:18,540 --> 00:14:20,940 The only part that it doesn't capture correctly 247 00:14:20,940 --> 00:14:24,460 is how the shock wave is supposed to behave. 248 00:14:24,460 --> 00:14:27,670 And if we use finite volume, because we 249 00:14:27,670 --> 00:14:31,190 are looking at the conservative form of the differential 250 00:14:31,190 --> 00:14:36,920 equation of this form, the other integral form. 251 00:14:36,920 --> 00:14:42,460 252 00:14:42,460 --> 00:14:46,980 This form of [INAUDIBLE] is to have shock waves. 253 00:14:46,980 --> 00:14:52,450 Solve this one, and you take the divergence of the [INAUDIBLE] 254 00:14:52,450 --> 00:14:57,460 that is discontinuous, for it acts derivative of something 255 00:14:57,460 --> 00:14:59,010 that is discontinuous. 256 00:14:59,010 --> 00:15:03,760 That is no longer a correct thing to do. 257 00:15:03,760 --> 00:15:06,522 And therefore, you get wrong behavior 258 00:15:06,522 --> 00:15:09,360 when there is discontinuity like shock waves. 259 00:15:09,360 --> 00:15:13,710 260 00:15:13,710 --> 00:15:14,360 Any questions? 261 00:15:14,360 --> 00:15:20,180 262 00:15:20,180 --> 00:15:25,726 Oh, and by the way, another thing is this. 263 00:15:25,726 --> 00:15:30,290 264 00:15:30,290 --> 00:15:31,531 I should let you look. 265 00:15:31,531 --> 00:15:33,030 In addition to the shock wave, there 266 00:15:33,030 --> 00:15:36,506 is another thing that is not right in the finite difference. 267 00:15:36,506 --> 00:15:39,390 268 00:15:39,390 --> 00:15:42,281 Lets look again at the finite volume. 269 00:15:42,281 --> 00:15:45,150 The Burger's equation's a conservation law, 270 00:15:45,150 --> 00:15:48,522 which means that [INAUDIBLE] under the curve should be 271 00:15:48,522 --> 00:15:50,960 [INAUDIBLE]. 272 00:15:50,960 --> 00:15:54,540 The integral of the solution u, of course, the whole domain, 273 00:15:54,540 --> 00:15:59,650 should be the same, because anything that comes out of here 274 00:15:59,650 --> 00:16:00,880 should come back into here. 275 00:16:00,880 --> 00:16:03,380 It's like when you step out of the door, you come back. 276 00:16:03,380 --> 00:16:05,170 You're not disappearing. 277 00:16:05,170 --> 00:16:10,341 But if you look at the finite difference, 278 00:16:10,341 --> 00:16:14,130 at this point, it [INAUDIBLE]. 279 00:16:14,130 --> 00:16:17,580 Things just disappear out of nowhere. 280 00:16:17,580 --> 00:16:22,060 The solution is not conserved. 281 00:16:22,060 --> 00:16:26,540 So two things that finite difference is missing. 282 00:16:26,540 --> 00:16:30,420 One is, it doesn't have to behave as a shock wave. 283 00:16:30,420 --> 00:16:36,430 Two, it is the solution is not conservative. 284 00:16:36,430 --> 00:16:39,252 Any question on why we do finite volume? 285 00:16:39,252 --> 00:16:46,020 286 00:16:46,020 --> 00:16:48,100 So this is why we do finite volume. 287 00:16:48,100 --> 00:16:53,660 And the next question is another question, 288 00:16:53,660 --> 00:16:58,710 probably, you have when you are going through the last lecture 289 00:16:58,710 --> 00:17:02,110 and reading through the material is, why the hell 290 00:17:02,110 --> 00:17:04,092 do we do upwind? 291 00:17:04,092 --> 00:17:07,839 Why do we look at the upwind direction? 292 00:17:07,839 --> 00:17:11,200 So the upwind of flux is this. 293 00:17:11,200 --> 00:17:14,690 So we look at a few volumes. 294 00:17:14,690 --> 00:17:17,990 k minus 1, k plus 1. 295 00:17:17,990 --> 00:17:22,750 The finite volume, we store the average value in the volumes. 296 00:17:22,750 --> 00:17:25,680 So we have k minus 1/2 and k plus 1/2 297 00:17:25,680 --> 00:17:31,430 as the volume interfaces or the cell interfaces. 298 00:17:31,430 --> 00:17:37,930 And the upwind flux is basically saying F at k minus 1/2 299 00:17:37,930 --> 00:17:48,740 is either the F of rho at k minus 1 or F of rho at k, 300 00:17:48,740 --> 00:17:58,224 depending on where the wind comes from, depending on if, 301 00:17:58,224 --> 00:18:08,100 should say-- let me use C as the speed of the wind. 302 00:18:08,100 --> 00:18:11,040 So if c is greater than zero, the winds 303 00:18:11,040 --> 00:18:15,710 have positive speed, which means the wind goes 304 00:18:15,710 --> 00:18:16,807 towards the right. 305 00:18:16,807 --> 00:18:18,755 And then you look at the upwind direction, 306 00:18:18,755 --> 00:18:23,280 you should be looking at when you are computing 307 00:18:23,280 --> 00:18:27,186 the upwind value of the plus [INAUDIBLE] minus 2, 308 00:18:27,186 --> 00:18:30,994 you should look towards the left, [INAUDIBLE]. 309 00:18:30,994 --> 00:18:40,470 So when k is greater-- so when C is less than 0, 310 00:18:40,470 --> 00:18:44,824 that means the speed of the wing is negative, 311 00:18:44,824 --> 00:18:46,490 opposite direction is towards the right. 312 00:18:46,490 --> 00:18:52,322 The winds are [INAUDIBLE] opposite direction for this, 313 00:18:52,322 --> 00:18:53,780 you should be looking at the right 314 00:18:53,780 --> 00:18:58,480 and use the k value instead. 315 00:18:58,480 --> 00:19:00,830 And here, c is what? 316 00:19:00,830 --> 00:19:05,250 c is this. 317 00:19:05,250 --> 00:19:09,550 c is the c that appears in this. 318 00:19:09,550 --> 00:19:16,430 319 00:19:16,430 --> 00:19:22,440 c is the value that appears in the differential form 320 00:19:22,440 --> 00:19:26,580 of the equation, over here. 321 00:19:26,580 --> 00:19:29,560 So as you can imagine, if we have 322 00:19:29,560 --> 00:19:34,000 [INAUDIBLE] like the [INAUDIBLE] vacuum equation we have, 323 00:19:34,000 --> 00:19:37,480 this c exactly determines whether your solution 324 00:19:37,480 --> 00:19:40,302 moves towards the left or moves towards the right. 325 00:19:40,302 --> 00:19:43,770 So if this c is positive, the solution will go to the right 326 00:19:43,770 --> 00:19:45,792 and winds go towards the right. 327 00:19:45,792 --> 00:19:49,830 If c is negative, it goes the opposite direction. 328 00:19:49,830 --> 00:19:52,320 But in general, in a conservation law, 329 00:19:52,320 --> 00:19:56,400 how do we convert our conservation law, 330 00:19:56,400 --> 00:20:01,910 which is partial F rho partial x equal to 0, into to that form? 331 00:20:01,910 --> 00:20:05,263 But if we convert this into this one, what is c? 332 00:20:05,263 --> 00:20:09,430 333 00:20:09,430 --> 00:20:15,080 Can we always convert the conservative form 334 00:20:15,080 --> 00:20:19,730 into this, like a vacuum scheme looks like, leaving 335 00:20:19,730 --> 00:20:23,523 a vacuum looking like form? 336 00:20:23,523 --> 00:20:25,020 AUDIENCE: Just take the derivative. 337 00:20:25,020 --> 00:20:27,440 QIQI WANG: I just take the derivative, exactly. 338 00:20:27,440 --> 00:20:31,750 If I take c equal to partial-- not partial. 339 00:20:31,750 --> 00:20:34,480 I do too many pd's. 340 00:20:34,480 --> 00:20:41,670 dF d rho, then I get my C. In the Burger's equations, 341 00:20:41,670 --> 00:20:47,330 c is [INAUDIBLE] rho because F is equal to half of rho square, 342 00:20:47,330 --> 00:20:48,590 right? 343 00:20:48,590 --> 00:20:51,445 So when I take derivative, I just get [INAUDIBLE]. 344 00:20:51,445 --> 00:20:53,970 As you see if you're looking at all the equations, 345 00:20:53,970 --> 00:20:57,530 you'll see what we did [INAUDIBLE]. 346 00:20:57,530 --> 00:20:59,368 And by the way, you may be thinking 347 00:20:59,368 --> 00:21:01,758 of why did I use these here. 348 00:21:01,758 --> 00:21:07,210 Because if you look at a gas dynamic equation, the C you get 349 00:21:07,210 --> 00:21:11,340 is going to be the speed of sound. 350 00:21:11,340 --> 00:21:13,370 OK. 351 00:21:13,370 --> 00:21:13,870 OK. 352 00:21:13,870 --> 00:21:18,140 Why do we need do upwind? 353 00:21:18,140 --> 00:21:21,280 I mean, the real mathematical reason 354 00:21:21,280 --> 00:21:24,750 is something I'm going to talk about [INAUDIBLE]. 355 00:21:24,750 --> 00:21:29,160 But, like, I think Dr. [? Vikram ?] [? Dag ?] is going 356 00:21:29,160 --> 00:21:31,590 to be giving the lecture right after the midterm. 357 00:21:31,590 --> 00:21:33,710 But he's going to talking about stability. 358 00:21:33,710 --> 00:21:35,630 And this is for stability. 359 00:21:35,630 --> 00:21:43,010 I'm just going to demonstrate it empirically 360 00:21:43,010 --> 00:21:49,780 in the shared folder we had-- not this one-- 361 00:21:49,780 --> 00:21:51,460 we had from last lecture. 362 00:21:51,460 --> 00:21:52,250 OK. 363 00:21:52,250 --> 00:21:54,500 So I had a driver here. 364 00:21:54,500 --> 00:21:57,232 And I have a bunch of people's schemes. 365 00:21:57,232 --> 00:21:59,420 Who's scheme is working by the way? 366 00:21:59,420 --> 00:22:00,629 Who knows? 367 00:22:00,629 --> 00:22:01,920 Which one of them should I use? 368 00:22:01,920 --> 00:22:04,920 369 00:22:04,920 --> 00:22:09,610 Who kind of knows more or less your script is working? 370 00:22:09,610 --> 00:22:10,140 OK. 371 00:22:10,140 --> 00:22:10,639 Yours? 372 00:22:10,639 --> 00:22:11,778 OK. 373 00:22:11,778 --> 00:22:12,385 [INAUDIBLE] 374 00:22:12,385 --> 00:22:13,260 AUDIENCE: [INAUDIBLE] 375 00:22:13,260 --> 00:22:16,718 376 00:22:16,718 --> 00:22:17,570 QIQI WANG: OK. 377 00:22:17,570 --> 00:22:18,070 All right. 378 00:22:18,070 --> 00:22:25,790 So I'm going to change this to-- OK. 379 00:22:25,790 --> 00:22:27,200 Thanks. 380 00:22:27,200 --> 00:22:28,650 So I can run it here. 381 00:22:28,650 --> 00:22:31,290 382 00:22:31,290 --> 00:22:34,527 And I get a solution. 383 00:22:34,527 --> 00:22:36,860 I mean, you probably didn't treat the boundary condition 384 00:22:36,860 --> 00:22:38,760 correctly, but that's fine. 385 00:22:38,760 --> 00:22:40,550 So there is something on the boundary 386 00:22:40,550 --> 00:22:45,420 that is not working correctly. 387 00:22:45,420 --> 00:22:50,073 I think that you might have set the [INAUDIBLE] here to be 0. 388 00:22:50,073 --> 00:22:51,636 So you just set the [INAUDIBLE] here 389 00:22:51,636 --> 00:22:54,765 to be 0 instead of [INAUDIBLE] the [INAUDIBLE] 390 00:22:54,765 --> 00:22:57,980 blowing with the [INAUDIBLE]. 391 00:22:57,980 --> 00:23:02,450 Because I'm having a [INAUDIBLE] find the word, so [INAUDIBLE], 392 00:23:02,450 --> 00:23:03,450 right? 393 00:23:03,450 --> 00:23:04,950 [INAUDIBLE] 394 00:23:04,950 --> 00:23:07,540 But that's fine. 395 00:23:07,540 --> 00:23:09,710 OK. 396 00:23:09,710 --> 00:23:15,480 So I think it should be relatively easy to modify. 397 00:23:15,480 --> 00:23:19,190 F-- yeah, yeah, yeah. 398 00:23:19,190 --> 00:23:19,690 OK. 399 00:23:19,690 --> 00:23:22,000 So I just need to treat the last one. 400 00:23:22,000 --> 00:23:28,620 So F_k_plus_half(and), right? 401 00:23:28,620 --> 00:23:33,130 The last one is equal to-- OK. 402 00:23:33,130 --> 00:23:38,060 I will just cheat here, F_bad_k(and). 403 00:23:38,060 --> 00:23:39,700 Because I know my solution is positive, 404 00:23:39,700 --> 00:23:42,710 so I just take the left one. 405 00:23:42,710 --> 00:23:46,740 406 00:23:46,740 --> 00:23:47,240 OK. 407 00:23:47,240 --> 00:23:49,820 So here is k_plus_half. 408 00:23:49,820 --> 00:23:51,570 AUDIENCE: That should have taken care of-- 409 00:23:51,570 --> 00:23:54,189 QIQI WANG: Oh, that should have taken care of that. 410 00:23:54,189 --> 00:23:55,064 AUDIENCE: [INAUDIBLE] 411 00:23:55,064 --> 00:24:08,631 412 00:24:08,631 --> 00:24:09,506 AUDIENCE: [INAUDIBLE] 413 00:24:09,506 --> 00:24:12,312 414 00:24:12,312 --> 00:24:13,020 QIQI WANG: Sorry? 415 00:24:13,020 --> 00:24:16,520 416 00:24:16,520 --> 00:24:20,702 k_plus_half of i minus-- that is end, right? 417 00:24:20,702 --> 00:24:21,327 AUDIENCE: Yeah. 418 00:24:21,327 --> 00:24:24,670 That's [INAUDIBLE]. 419 00:24:24,670 --> 00:24:30,050 QIQI WANG: I think you shouldn't be-- F_bar_k, right? 420 00:24:30,050 --> 00:24:32,650 421 00:24:32,650 --> 00:24:33,500 OK. 422 00:24:33,500 --> 00:24:43,794 And else it is equal to F_bar_k(1), right? 423 00:24:43,794 --> 00:24:46,601 424 00:24:46,601 --> 00:24:47,100 OK. 425 00:24:47,100 --> 00:24:48,340 So let's see if that works. 426 00:24:48,340 --> 00:24:51,450 427 00:24:51,450 --> 00:24:52,110 Oh, that works. 428 00:24:52,110 --> 00:24:53,350 OK, nice. 429 00:24:53,350 --> 00:24:53,910 OK. 430 00:24:53,910 --> 00:24:55,750 So we have this scheme over here. 431 00:24:55,750 --> 00:24:57,860 We have an upwinding scheme. 432 00:24:57,860 --> 00:25:01,620 So as we did in finite [INAUDIBLE], 433 00:25:01,620 --> 00:25:06,530 will know that backward in space or forward in space anything 434 00:25:06,530 --> 00:25:09,380 you [INAUDIBLE] have a one-sided [INAUDIBLE], 435 00:25:09,380 --> 00:25:12,990 you get first order accuracy. 436 00:25:12,990 --> 00:25:15,250 But if you take essential difference 437 00:25:15,250 --> 00:25:18,380 or take the average of left and right, 438 00:25:18,380 --> 00:25:20,410 you get secondary accuracy. 439 00:25:20,410 --> 00:25:23,050 So why don't we use that? 440 00:25:23,050 --> 00:25:28,020 I'm going to change your code to do exactly that. 441 00:25:28,020 --> 00:25:31,590 I'm going to instead of doing all this conditional thing, 442 00:25:31,590 --> 00:25:42,180 I'm just going to do this is equal to half of F_bar_k 443 00:25:42,180 --> 00:25:43,940 and F_bar_k plus 1. 444 00:25:43,940 --> 00:25:48,040 445 00:25:48,040 --> 00:25:49,960 This thing's divided by 2. 446 00:25:49,960 --> 00:25:53,100 So I'm not going to be using your conditions. 447 00:25:53,100 --> 00:25:58,280 I'm just going to do k_plus_half equal to actually k_plus_half, 448 00:25:58,280 --> 00:26:02,550 k_plus k_plus over 2. 449 00:26:02,550 --> 00:26:07,500 And instead of doing this condition-- 450 00:26:07,500 --> 00:26:11,940 apologize first for going to make the [INAUDIBLE] unstable. 451 00:26:11,940 --> 00:26:24,000 But k_plus_half(and) is going to be F_bar_k(and) plus F_bar_k(1) 452 00:26:24,000 --> 00:26:25,200 divide by 2. 453 00:26:25,200 --> 00:26:30,690 So now if I do this, I always set the interface value 454 00:26:30,690 --> 00:26:33,810 to be the average between the two [INAUDIBLE]. 455 00:26:33,810 --> 00:26:34,675 What do I get? 456 00:26:34,675 --> 00:26:38,240 457 00:26:38,240 --> 00:26:39,860 Now, it looks like correct. 458 00:26:39,860 --> 00:26:40,360 Oh. 459 00:26:40,360 --> 00:26:43,162 460 00:26:43,162 --> 00:26:44,650 All right. 461 00:26:44,650 --> 00:26:45,920 So what we see here? 462 00:26:45,920 --> 00:26:49,130 We see here in the beginning, it looks fine. 463 00:26:49,130 --> 00:26:54,690 Let's look more carefully what actually happens. 464 00:26:54,690 --> 00:26:59,285 Let's set dt equal to 0.001 to be more-- let's see 465 00:26:59,285 --> 00:27:00,130 what happens. 466 00:27:00,130 --> 00:27:00,770 OK. 467 00:27:00,770 --> 00:27:04,040 Usually, the evolution- let me [INAUDIBLE] 468 00:27:04,040 --> 00:27:05,290 it, so it doesn't [INAUDIBLE]. 469 00:27:05,290 --> 00:27:08,100 470 00:27:08,100 --> 00:27:13,620 [INAUDIBLE] I'm going to do ylim(0,2), 471 00:27:13,620 --> 00:27:16,530 so that doesn't [INAUDIBLE]. 472 00:27:16,530 --> 00:27:17,980 OK. 473 00:27:17,980 --> 00:27:21,270 In the beginning, we see it is behaving correctly. 474 00:27:21,270 --> 00:27:23,710 And I am probably getting secondary accuracy, right? 475 00:27:23,710 --> 00:27:26,345 476 00:27:26,345 --> 00:27:29,810 But as soon as the [INAUDIBLE] is formed, 477 00:27:29,810 --> 00:27:33,100 something bad is going to happen. 478 00:27:33,100 --> 00:27:34,040 Now, [INAUDIBLE]. 479 00:27:34,040 --> 00:27:36,838 480 00:27:36,838 --> 00:27:38,326 All right. 481 00:27:38,326 --> 00:27:38,826 [INAUDIBLE] 482 00:27:38,826 --> 00:27:44,293 483 00:27:44,293 --> 00:27:46,300 So, yeah. 484 00:27:46,300 --> 00:27:49,214 So we've got these calculations. 485 00:27:49,214 --> 00:27:53,211 And it looks pretty much like in [INAUDIBLE] analysis 486 00:27:53,211 --> 00:27:59,156 you get this [INAUDIBLE] phenomenon, like right or wrong 487 00:27:59,156 --> 00:28:01,700 [INAUDIBLE]. 488 00:28:01,700 --> 00:28:11,390 So this is actually why we need to take an upwinding scheme, 489 00:28:11,390 --> 00:28:15,600 especially if you have a nonlinear differential equation 490 00:28:15,600 --> 00:28:17,439 with potentially shock waves. 491 00:28:17,439 --> 00:28:22,260 492 00:28:22,260 --> 00:28:24,150 I mean, if you go to math class, I 493 00:28:24,150 --> 00:28:28,400 can probably talk more about shock waves being 494 00:28:28,400 --> 00:28:33,100 a dissipated phenomenon and a second order scheme, 495 00:28:33,100 --> 00:28:35,773 like essential difference that has no numerical dissipation. 496 00:28:35,773 --> 00:28:40,350 And you need the numerical dissipation [INAUDIBLE]. 497 00:28:40,350 --> 00:28:42,550 I'm just going to demonstrate numerically. 498 00:28:42,550 --> 00:28:45,970 This type of thing is going to happen if we don't do upwinding 499 00:28:45,970 --> 00:28:47,155 and you have shock wave. 500 00:28:47,155 --> 00:28:49,750 501 00:28:49,750 --> 00:28:52,020 So for something that doesn't have shock wave 502 00:28:52,020 --> 00:28:56,890 it's probably fine as long as you use an appropriate time 503 00:28:56,890 --> 00:28:58,650 integrator. 504 00:28:58,650 --> 00:28:59,365 OK. 505 00:28:59,365 --> 00:29:04,342 So today-- I mean, this is why upwinding-- we 506 00:29:04,342 --> 00:29:06,092 are going to be doing something like this. 507 00:29:06,092 --> 00:29:08,576 508 00:29:08,576 --> 00:29:09,950 So I tried to stimulate distance. 509 00:29:09,950 --> 00:29:13,976 510 00:29:13,976 --> 00:29:16,880 This is a lot of parts, right? 511 00:29:16,880 --> 00:29:19,598 And if you do a simulation of individual parts, 512 00:29:19,598 --> 00:29:21,005 yeah, you can do this. 513 00:29:21,005 --> 00:29:24,260 But [INAUDIBLE] this [INAUDIBLE] it really 514 00:29:24,260 --> 00:29:26,390 looks like-- I mean, each [INAUDIBLE] more 515 00:29:26,390 --> 00:29:29,086 looks more or less like a molecule. 516 00:29:29,086 --> 00:29:33,810 So you really get a continuum of cars or [INAUDIBLE]. 517 00:29:33,810 --> 00:29:38,000 And one of the ideas is to instead of treating each car 518 00:29:38,000 --> 00:29:43,030 as an individual agent and simulate that, we just 519 00:29:43,030 --> 00:29:47,030 look at from a macroscopic point of view 520 00:29:47,030 --> 00:29:51,030 and simulate this like gas dynamics, 521 00:29:51,030 --> 00:29:54,850 where each car is like a molecule. 522 00:29:54,850 --> 00:29:55,780 OK. 523 00:29:55,780 --> 00:30:01,020 And so a macroscopic description of the cars on a highway 524 00:30:01,020 --> 00:30:06,570 is just P as a function of x and t, right? 525 00:30:06,570 --> 00:30:08,290 So x is space. 526 00:30:08,290 --> 00:30:09,385 t is time. 527 00:30:09,385 --> 00:30:18,790 And P is the number of cars per length of the highway. 528 00:30:18,790 --> 00:30:21,739 So P is a converse quantity, because cars are converse, 529 00:30:21,739 --> 00:30:22,239 right? 530 00:30:22,239 --> 00:30:26,780 Cars are not disappearing into [INAUDIBLE]. 531 00:30:26,780 --> 00:30:29,255 Yeah. 532 00:30:29,255 --> 00:30:32,491 Cars are not disappearing as airlines sometimes do. 533 00:30:32,491 --> 00:30:35,544 534 00:30:35,544 --> 00:30:36,419 AUDIENCE: [INAUDIBLE] 535 00:30:36,419 --> 00:30:41,478 536 00:30:41,478 --> 00:30:42,311 [INTERPOSING VOICES] 537 00:30:42,311 --> 00:30:46,147 538 00:30:46,147 --> 00:30:46,730 QIQI WANG: OK. 539 00:30:46,730 --> 00:30:51,450 540 00:30:51,450 --> 00:30:57,060 So we are also assuming the velocity of cars 541 00:30:57,060 --> 00:30:59,420 depends on the density. 542 00:30:59,420 --> 00:31:05,940 Well, let's first say so P equal to 0 is an empty highway. 543 00:31:05,940 --> 00:31:09,170 P equal to 1 is this. 544 00:31:09,170 --> 00:31:09,960 OK. 545 00:31:09,960 --> 00:31:13,112 P equal to 1 is like a parking lot. 546 00:31:13,112 --> 00:31:16,660 P equal to 1 is like the maximum density 547 00:31:16,660 --> 00:31:19,230 you can pack onto a highway. 548 00:31:19,230 --> 00:31:19,730 OK. 549 00:31:19,730 --> 00:31:23,330 So this is P. And we are assuming the velocity 550 00:31:23,330 --> 00:31:26,990 of the cars is a functional P. 551 00:31:26,990 --> 00:31:31,840 So again, a velocity equal to 0 is like this. 552 00:31:31,840 --> 00:31:38,760 So this car cannot move when the density is at [INAUDIBLE]. 553 00:31:38,760 --> 00:31:44,600 And let's pick the unit of velocity, 554 00:31:44,600 --> 00:31:46,940 so that velocity equal to 1 is something 555 00:31:46,940 --> 00:31:55,990 like 65 miles per hour, where you would have-- or 80-- 556 00:31:55,990 --> 00:32:01,360 where you would be driving if there is no other cars. 557 00:32:01,360 --> 00:32:02,300 Or 85. 558 00:32:02,300 --> 00:32:04,570 OK. 559 00:32:04,570 --> 00:32:06,690 OK. 560 00:32:06,690 --> 00:32:09,550 So what would be an easy way or intuitive 561 00:32:09,550 --> 00:32:14,565 way you would model u as a function P? 562 00:32:14,565 --> 00:32:15,440 AUDIENCE: [INAUDIBLE] 563 00:32:15,440 --> 00:32:19,954 564 00:32:19,954 --> 00:32:20,620 QIQI WANG: Yeah. 565 00:32:20,620 --> 00:32:21,740 It can be more curved. 566 00:32:21,740 --> 00:32:23,800 But let's make it simple. 567 00:32:23,800 --> 00:32:25,400 Did you want to [INAUDIBLE]? 568 00:32:25,400 --> 00:32:27,720 So would you [INAUDIBLE] code [INAUDIBLE] 569 00:32:27,720 --> 00:32:28,920 like something like this? 570 00:32:28,920 --> 00:32:32,220 Or would you [INAUDIBLE] coding [INAUDIBLE] like U(P)= 1 minus 571 00:32:32,220 --> 00:32:32,720 P? 572 00:32:32,720 --> 00:32:38,600 573 00:32:38,600 --> 00:32:41,110 This captures the right behavior. 574 00:32:41,110 --> 00:32:45,500 So when P is equal to 0, you drive at 85 miles per hour. 575 00:32:45,500 --> 00:32:49,926 When P is equal to 1, even if you want to drive faster, 576 00:32:49,926 --> 00:32:52,460 you're stuck, right? 577 00:32:52,460 --> 00:32:53,350 OK. 578 00:32:53,350 --> 00:32:55,280 Now, here's my first question. 579 00:32:55,280 --> 00:32:56,187 What is the flux? 580 00:32:56,187 --> 00:33:02,900 581 00:33:02,900 --> 00:33:03,695 What's F(P)? 582 00:33:03,695 --> 00:33:10,688 583 00:33:10,688 --> 00:33:13,511 AUDIENCE: [INAUDIBLE] 584 00:33:13,511 --> 00:33:14,386 QIQI WANG: Integral-- 585 00:33:14,386 --> 00:33:15,261 AUDIENCE: [INAUDIBLE] 586 00:33:15,261 --> 00:33:17,934 587 00:33:17,934 --> 00:33:18,600 QIQI WANG: Yeah. 588 00:33:18,600 --> 00:33:19,766 I know what you're thinking. 589 00:33:19,766 --> 00:33:25,070 You are thinking about U being the d f in P, right? 590 00:33:25,070 --> 00:33:26,340 So it has to be the integral. 591 00:33:26,340 --> 00:33:30,360 But that's not true. 592 00:33:30,360 --> 00:33:31,610 It's easier than that. 593 00:33:31,610 --> 00:33:35,085 You are thinking more-- you're too smart. 594 00:33:35,085 --> 00:33:36,379 AUDIENCE: [INAUDIBLE] 595 00:33:36,379 --> 00:33:38,420 QIQI WANG: P times U. That's that correct answer. 596 00:33:38,420 --> 00:33:41,372 Can you say why that is this case? 597 00:33:41,372 --> 00:33:43,268 AUDIENCE: [INAUDIBLE] 598 00:33:43,268 --> 00:33:44,841 QIQI WANG: That's [INAUDIBLE]. 599 00:33:44,841 --> 00:33:45,340 Yeah. 600 00:33:45,340 --> 00:33:51,990 Because flux is number of cars, the amount of converse quantity 601 00:33:51,990 --> 00:33:56,906 that flows through a point per unit amount of time, right? 602 00:33:56,906 --> 00:34:01,855 So if you just [INAUDIBLE] the control volume like this, 603 00:34:01,855 --> 00:34:06,010 this is my-- oh, I shouldn't use green, because you can't see. 604 00:34:06,010 --> 00:34:10,882 If you true the control volume like this-- 605 00:34:10,882 --> 00:34:13,960 and the flux of this [INAUDIBLE] is the number 606 00:34:13,960 --> 00:34:17,929 of cars that goes through this line per unit amount of time. 607 00:34:17,929 --> 00:34:20,010 So this is cars that have density of rho 608 00:34:20,010 --> 00:34:23,409 goes through the [INAUDIBLE] U. Of course, the flux is 609 00:34:23,409 --> 00:34:26,530 going to be P times U. 610 00:34:26,530 --> 00:34:32,440 The flux is going to be P times U, which is 611 00:34:32,440 --> 00:34:34,479 P minus P squared in this case. 612 00:34:34,479 --> 00:34:38,645 Because U is 1 minus P. P times U is P minus P squared. 613 00:34:38,645 --> 00:34:41,909 614 00:34:41,909 --> 00:34:44,270 Is it clear? 615 00:34:44,270 --> 00:34:46,699 Any questions? 616 00:34:46,699 --> 00:34:51,564 So we derived our differential equation, dP dt 617 00:34:51,564 --> 00:34:57,670 plus d of P-- I'm just going to write F(P), it's easier. 618 00:34:57,670 --> 00:35:08,230 F(P) dx is equal to 0 where F(P) is equal to P minus P squared. 619 00:35:08,230 --> 00:35:08,730 OK. 620 00:35:08,730 --> 00:35:11,290 Now, what is C? 621 00:35:11,290 --> 00:35:15,070 What is the [INAUDIBLE] characteristic C? 622 00:35:15,070 --> 00:35:19,471 623 00:35:19,471 --> 00:35:23,840 Now, this becomes highly [INAUDIBLE]. 624 00:35:23,840 --> 00:35:25,901 What is C? 625 00:35:25,901 --> 00:35:27,650 AUDIENCE: 1 minus [INAUDIBLE]. 626 00:35:27,650 --> 00:35:29,530 QIQI WANG: It's 1 minus 2P. 627 00:35:29,530 --> 00:35:32,980 It is equal to dF dP, right? 628 00:35:32,980 --> 00:35:37,710 So derivative of P is 1 [INAUDIBLE]. 629 00:35:37,710 --> 00:35:38,610 OK. 630 00:35:38,610 --> 00:35:43,360 So we have a relation like this. 631 00:35:43,360 --> 00:35:46,770 We have a relation of F versus P. 632 00:35:46,770 --> 00:35:49,210 P is all the way from 0 to 1. 633 00:35:49,210 --> 00:35:57,060 F is something like this, where the maximum takes 1/4. 634 00:35:57,060 --> 00:35:57,720 OK. 635 00:35:57,720 --> 00:36:02,460 And we have a C that looks like this. 636 00:36:02,460 --> 00:36:06,440 We have C that is equal to 1 when there is no cars 637 00:36:06,440 --> 00:36:09,080 and goes all the way to minus 1 when 638 00:36:09,080 --> 00:36:13,100 there is a parking lot of cars. 639 00:36:13,100 --> 00:36:18,090 This is 1 and minus 1. 640 00:36:18,090 --> 00:36:19,300 OK. 641 00:36:19,300 --> 00:36:22,716 So what is happening? 642 00:36:22,716 --> 00:36:28,360 C, again, is the speed of the local solution. 643 00:36:28,360 --> 00:36:31,330 It is intuitive that when there are no cars, 644 00:36:31,330 --> 00:36:34,096 things move at 85 miles per hour. 645 00:36:34,096 --> 00:36:37,350 So the [INAUDIBLE] should be 1. 646 00:36:37,350 --> 00:36:38,560 What happens here? 647 00:36:38,560 --> 00:36:40,360 When there is a parking lot of cars, 648 00:36:40,360 --> 00:36:43,236 things move backwards at 85 miles an hour? 649 00:36:43,236 --> 00:36:47,637 650 00:36:47,637 --> 00:36:48,946 AUDIENCE: [INAUDIBLE] 651 00:36:48,946 --> 00:36:49,570 QIQI WANG: Yes. 652 00:36:49,570 --> 00:36:53,220 It's kind of the-- so this C here 653 00:36:53,220 --> 00:36:56,965 is not-- I mean, if you look into physics 654 00:36:56,965 --> 00:36:59,006 you've got two kind of speeds, like a group speed 655 00:36:59,006 --> 00:37:00,860 and a [INAUDIBLE] speed, right? 656 00:37:00,860 --> 00:37:05,520 So here, the cars move forward always have a positive speed. 657 00:37:05,520 --> 00:37:09,940 But it doesn't mean if you look at cars in the backwards 658 00:37:09,940 --> 00:37:11,910 [INAUDIBLE] point of view, it doesn't 659 00:37:11,910 --> 00:37:16,950 mean the wave that appears in the flow of traffic 660 00:37:16,950 --> 00:37:18,910 is going to move forward. 661 00:37:18,910 --> 00:37:21,020 Sometimes you are going to see waves actually 662 00:37:21,020 --> 00:37:22,752 moving backwards. 663 00:37:22,752 --> 00:37:25,210 I mean, we're waiting to see some examples when it actually 664 00:37:25,210 --> 00:37:26,209 solves that numerically. 665 00:37:26,209 --> 00:37:29,110 666 00:37:29,110 --> 00:37:30,550 OK. 667 00:37:30,550 --> 00:37:35,200 So the task for you is to hold up 668 00:37:35,200 --> 00:37:39,540 a simulation of this thing in a periodic [INAUDIBLE] solution. 669 00:37:39,540 --> 00:37:43,290 So let's say this is our highway. 670 00:37:43,290 --> 00:37:46,280 This is our highway. 671 00:37:46,280 --> 00:37:48,380 It just goes in circles, right? 672 00:37:48,380 --> 00:37:51,380 Assuming you have a bunch of cars driving in circles. 673 00:37:51,380 --> 00:37:53,380 AUDIENCE: I could never get off the [INAUDIBLE]. 674 00:37:53,380 --> 00:37:54,255 AUDIENCE: [INAUDIBLE] 675 00:37:54,255 --> 00:37:54,880 QIQI WANG: Huh? 676 00:37:54,880 --> 00:37:55,653 AUDIENCE: NASCAR. 677 00:37:55,653 --> 00:37:57,545 QIQI WANG: NASCAR, yeah, yeah, right. 678 00:37:57,545 --> 00:37:59,910 Yeah. 679 00:37:59,910 --> 00:38:02,320 We have a lot of cars driving in home circles. 680 00:38:02,320 --> 00:38:05,850 And let's just [INAUDIBLE] how these work. 681 00:38:05,850 --> 00:38:07,690 And then at sometime, we are going 682 00:38:07,690 --> 00:38:10,530 to put a red light over here. 683 00:38:10,530 --> 00:38:14,774 And say, OK, the cars stop here. 684 00:38:14,774 --> 00:38:16,774 What is the right way to model that numerically? 685 00:38:16,774 --> 00:38:21,040 686 00:38:21,040 --> 00:38:23,610 You can set the flux [INAUDIBLE] to 0, right? 687 00:38:23,610 --> 00:38:26,243 I mean, at some point, that's a [INAUDIBLE] simulation. 688 00:38:26,243 --> 00:38:28,168 And for example, time equal to 1, 689 00:38:28,168 --> 00:38:34,130 that's [INAUDIBLE] 0 [INAUDIBLE] before the red light. 690 00:38:34,130 --> 00:38:39,370 And at some point, let's set the light [INAUDIBLE]. 691 00:38:39,370 --> 00:38:42,306 But let's do something simple in the beginning. 692 00:38:42,306 --> 00:38:45,150 Let's just [INAUDIBLE] the solution 693 00:38:45,150 --> 00:38:48,110 of [INAUDIBLE] with no red lights or anything like that. 694 00:38:48,110 --> 00:38:50,675 I'm going to give you the initial position. 695 00:38:50,675 --> 00:38:53,650 And we'll see how it evolves. 696 00:38:53,650 --> 00:38:57,590 And then we are using final volume. 697 00:38:57,590 --> 00:39:01,770 And you are free to take-- the [INAUDIBLE] case 698 00:39:01,770 --> 00:39:15,050 we had in the last lecture is in the shared folder. 699 00:39:15,050 --> 00:39:17,900 And I'm just going to make another shared folder here. 700 00:39:17,900 --> 00:39:23,780 701 00:39:23,780 --> 00:39:24,700 OK. 702 00:39:24,700 --> 00:39:32,210 I'm just going to take a [INAUDIBLE] and the du dt. 703 00:39:32,210 --> 00:39:40,356 I'm just going to take the [INAUDIBLE] stamp [INAUDIBLE] 704 00:39:40,356 --> 00:39:41,160 to this. 705 00:39:41,160 --> 00:39:43,182 Because I know it's working. 706 00:39:43,182 --> 00:39:52,004 And [INAUDIBLE] start by modifying [INAUDIBLE]. 707 00:39:52,004 --> 00:39:58,470 708 00:39:58,470 --> 00:40:01,210 So instead of u_bar, you're going to solving for P_bar. 709 00:40:01,210 --> 00:40:05,270 710 00:40:05,270 --> 00:40:14,843 And what is the first thing you would want changed in this? 711 00:40:14,843 --> 00:40:15,718 AUDIENCE: [INAUDIBLE] 712 00:40:15,718 --> 00:40:21,027 713 00:40:21,027 --> 00:40:21,860 QIQI WANG: Oh, yeah. 714 00:40:21,860 --> 00:40:22,790 Yeah, make it upwind. 715 00:40:22,790 --> 00:40:23,580 Yeah, right. 716 00:40:23,580 --> 00:40:27,478 To make it upwind there are [INAUDIBLE]. 717 00:40:27,478 --> 00:40:28,464 Huh? 718 00:40:28,464 --> 00:40:30,484 AUDIENCE: [INAUDIBLE] 719 00:40:30,484 --> 00:40:32,150 QIQI WANG: It's no longer that equation. 720 00:40:32,150 --> 00:40:33,370 The equation is [INAUDIBLE]. 721 00:40:33,370 --> 00:40:35,600 But there is only one line we can 722 00:40:35,600 --> 00:40:39,030 change to solve for a different equation and find the volume. 723 00:40:39,030 --> 00:40:40,041 What line is that? 724 00:40:40,041 --> 00:40:40,916 AUDIENCE: [INAUDIBLE] 725 00:40:40,916 --> 00:40:44,820 726 00:40:44,820 --> 00:40:47,290 QIQI WANG: Second line. 727 00:40:47,290 --> 00:40:53,640 The only thing that satisfies a different equation is the flux. 728 00:40:53,640 --> 00:40:58,150 You change the flux, you are now solving a different equation. 729 00:40:58,150 --> 00:40:59,790 OK. 730 00:40:59,790 --> 00:41:01,710 Of course, another thing is what is 731 00:41:01,710 --> 00:41:05,310 upwind direction [INAUDIBLE]. 732 00:41:05,310 --> 00:41:09,155 In [INAUDIBLE] equation, we know U is positive plus [INAUDIBLE] 733 00:41:09,155 --> 00:41:10,010 the right. 734 00:41:10,010 --> 00:41:11,940 U is negative [INAUDIBLE]. 735 00:41:11,940 --> 00:41:15,260 Now, this is different. 736 00:41:15,260 --> 00:41:19,150 Now, this is different, because we have [INAUDIBLE]. 737 00:41:19,150 --> 00:41:21,265 What is left and what is right all 738 00:41:21,265 --> 00:41:25,456 depends on the [INAUDIBLE] instead of the [INAUDIBLE]. 739 00:41:25,456 --> 00:41:31,865 740 00:41:31,865 --> 00:41:33,946 So any questions? 741 00:41:33,946 --> 00:41:34,446 OK. 742 00:41:34,446 --> 00:41:39,220 If you are done with the-- If you get the solution going, 743 00:41:39,220 --> 00:41:43,810 try to put a red light somewhere. 744 00:41:43,810 --> 00:41:48,855 Let me kind of illustrate how I should modify the driver. 745 00:41:48,855 --> 00:41:53,460 746 00:41:53,460 --> 00:41:55,746 So I have this here. 747 00:41:55,746 --> 00:41:58,590 748 00:41:58,590 --> 00:42:00,110 That, I didn't call it [INAUDIBLE]. 749 00:42:00,110 --> 00:42:02,890 Because it's no longer [INAUDIBLE]. 750 00:42:02,890 --> 00:42:03,830 Let me [INAUDIBLE]. 751 00:42:03,830 --> 00:42:07,120 752 00:42:07,120 --> 00:42:08,140 trafficDriver. 753 00:42:08,140 --> 00:42:09,122 OK, trafficDriver. 754 00:42:09,122 --> 00:42:12,070 755 00:42:12,070 --> 00:42:14,230 And let me see. 756 00:42:14,230 --> 00:42:25,777 So in this ODE 45, I'm going to set t0=(i-1) times dt and t1=i 757 00:42:25,777 --> 00:42:26,910 times dt. 758 00:42:26,910 --> 00:42:30,460 So this is like the beginning and end of this interval. 759 00:42:30,460 --> 00:42:32,560 And when I'm solving it, I'm going 760 00:42:32,560 --> 00:42:35,570 to be solving it from t0 to t1. 761 00:42:35,570 --> 00:42:49,800 So now the difference is if I look at-- so let me do this. 762 00:42:49,800 --> 00:42:57,336 763 00:42:57,336 --> 00:42:59,220 OK. 764 00:42:59,220 --> 00:43:05,170 So I just want to be able to passing the actual time. 765 00:43:05,170 --> 00:43:09,870 So I'm just going to be passing also time into this. 766 00:43:09,870 --> 00:43:12,820 So I also have a time into this. 767 00:43:12,820 --> 00:43:17,670 And then now if-- OK, so let me just 768 00:43:17,670 --> 00:43:21,090 go through what you need to modify. 769 00:43:21,090 --> 00:43:26,340 So first of all, I'm going to modify this, 770 00:43:26,340 --> 00:43:28,980 which is the different flux. 771 00:43:28,980 --> 00:43:30,360 Right? 772 00:43:30,360 --> 00:43:34,670 Instead of half of u squared, I have u minus u squared. 773 00:43:34,670 --> 00:43:35,210 OK. 774 00:43:35,210 --> 00:43:37,360 k_plus_half is still the same. 775 00:43:37,360 --> 00:43:42,840 I'm going to-- so if I don't modify anything, 776 00:43:42,840 --> 00:43:44,110 I think it all wrong. 777 00:43:44,110 --> 00:43:47,430 But like once a shock wave forms, it'll go unstable. 778 00:43:47,430 --> 00:43:50,022 So let me try it. 779 00:43:50,022 --> 00:43:51,190 I doesn't even wrong. 780 00:43:51,190 --> 00:43:55,380 781 00:43:55,380 --> 00:43:58,930 [INAUDIBLE] dimension matrices being concatenated 782 00:43:58,930 --> 00:43:59,859 are not consistent. 783 00:43:59,859 --> 00:44:08,002 784 00:44:08,002 --> 00:44:10,260 AUDIENCE: [INAUDIBLE] 785 00:44:10,260 --> 00:44:11,010 QIQI WANG: Oh, OK. 786 00:44:11,010 --> 00:44:12,070 I'm [INAUDIBLE] different [INAUDIBLE]. 787 00:44:12,070 --> 00:44:13,070 Yes, thank you. 788 00:44:13,070 --> 00:44:23,846 789 00:44:23,846 --> 00:44:24,794 I save this. 790 00:44:24,794 --> 00:44:27,578 791 00:44:27,578 --> 00:44:30,370 AUDIENCE: [INAUDIBLE] 792 00:44:30,370 --> 00:44:33,150 QIQI WANG: Oh, i'm solving-- yeah-- from t0 to t1. 793 00:44:33,150 --> 00:44:34,470 Yeah, thank you. 794 00:44:34,470 --> 00:44:35,000 OK. 795 00:44:35,000 --> 00:44:37,050 So this thing goes. 796 00:44:37,050 --> 00:44:42,380 And we're going to see [INAUDIBLE]-- wait. 797 00:44:42,380 --> 00:44:44,710 I shouldn't initialize it to 2, right? 798 00:44:44,710 --> 00:44:46,300 Because 1 is parking lot. 799 00:44:46,300 --> 00:44:47,440 What is 2? 800 00:44:47,440 --> 00:44:47,940 OK. 801 00:44:47,940 --> 00:44:50,690 So I need to also modify the initial condition. 802 00:44:50,690 --> 00:44:55,120 So what I can do is I can set this, let's say, divide by 4. 803 00:44:55,120 --> 00:44:55,620 OK. 804 00:44:55,620 --> 00:44:59,820 So this is going to be my initial condition [INAUDIBLE]. 805 00:44:59,820 --> 00:45:00,320 OK. 806 00:45:00,320 --> 00:45:06,180 I also want to-- my ylim, when I show my solution, 807 00:45:06,180 --> 00:45:09,780 I just want to go from 0 to 1, right? 808 00:45:09,780 --> 00:45:10,280 OK. 809 00:45:10,280 --> 00:45:12,450 So let me run again. 810 00:45:12,450 --> 00:45:12,950 OK. 811 00:45:12,950 --> 00:45:15,374 So this is how my solution looks like. 812 00:45:15,374 --> 00:45:17,968 This part goes really fast. 813 00:45:17,968 --> 00:45:21,700 [INAUDIBLE] unstable. 814 00:45:21,700 --> 00:45:23,890 And I need to change this to upwinding. 815 00:45:23,890 --> 00:45:27,230 But we have the [INAUDIBLE] part of the solution correct. 816 00:45:27,230 --> 00:45:30,355 Every [INAUDIBLE] towards a positive direction when 817 00:45:30,355 --> 00:45:32,746 the [INAUDIBLE] move faster. 818 00:45:32,746 --> 00:45:34,910 That's [INAUDIBLE] car density, cars move slower. 819 00:45:34,910 --> 00:45:39,032 So sometimes, a shock wave is going to form. 820 00:45:39,032 --> 00:45:41,362 Because the faster parts is going 821 00:45:41,362 --> 00:45:46,752 to [INAUDIBLE] to the slower parts and decelerate. 822 00:45:46,752 --> 00:45:48,690 So it becomes a shock wave. 823 00:45:48,690 --> 00:45:51,270 824 00:45:51,270 --> 00:45:54,790 So let's start to modify this to an upwinding scheme. 825 00:45:54,790 --> 00:45:57,640 826 00:45:57,640 --> 00:45:59,620 We computed F_bar. 827 00:45:59,620 --> 00:46:01,130 And we have a c. 828 00:46:01,130 --> 00:46:02,380 c is equal to 1-u_bar times 2. 829 00:46:02,380 --> 00:46:07,730 830 00:46:07,730 --> 00:46:08,760 OK. 831 00:46:08,760 --> 00:46:21,720 And the c at k_plus_half is equal to c plus-- OK. 832 00:46:21,720 --> 00:46:24,150 Let me do like this. 833 00:46:24,150 --> 00:46:32,280 So in the condition, instead of u_bar, I'm going to put c. 834 00:46:32,280 --> 00:46:38,640 835 00:46:38,640 --> 00:46:39,140 OK. 836 00:46:39,140 --> 00:46:40,490 Here, too. 837 00:46:40,490 --> 00:46:43,783 Instead of the u_bar, I'm going to put c. 838 00:46:43,783 --> 00:46:47,170 839 00:46:47,170 --> 00:46:48,930 OK. 840 00:46:48,930 --> 00:46:51,220 So this completes my upwinding. 841 00:46:51,220 --> 00:46:53,180 And let's try it again. 842 00:46:53,180 --> 00:46:56,400 843 00:46:56,400 --> 00:46:58,275 We still have the solution. 844 00:46:58,275 --> 00:47:01,110 But the lower density goes faster. 845 00:47:01,110 --> 00:47:06,370 High density goes slower [INAUDIBLE] high density, 846 00:47:06,370 --> 00:47:09,844 but now it's [INAUDIBLE] stability. 847 00:47:09,844 --> 00:47:10,792 So that's good. 848 00:47:10,792 --> 00:47:13,640 849 00:47:13,640 --> 00:47:15,830 And if you want to get better solution, 850 00:47:15,830 --> 00:47:18,124 I can change this to 256. 851 00:47:18,124 --> 00:47:20,630 And I round this. 852 00:47:20,630 --> 00:47:22,884 And I [INAUDIBLE] the top [INAUDIBLE]. 853 00:47:22,884 --> 00:47:31,841 854 00:47:31,841 --> 00:47:32,340 OK. 855 00:47:32,340 --> 00:47:38,330 So now, let's say at this point, so at either the beginning 856 00:47:38,330 --> 00:47:44,190 [INAUDIBLE], I have time equal to 1, we get a red light. 857 00:47:44,190 --> 00:47:47,900 And at time equal to 2, we turn the light to green. 858 00:47:47,900 --> 00:47:49,860 [INAUDIBLE] there. 859 00:47:49,860 --> 00:47:51,820 OK. 860 00:47:51,820 --> 00:47:54,130 So we do that. 861 00:47:54,130 --> 00:47:56,670 [INAUDIBLE] then that [INAUDIBLE] 862 00:47:56,670 --> 00:48:01,530 what we need to do to make that happen. 863 00:48:01,530 --> 00:48:04,750 The key thing is now you have time. 864 00:48:04,750 --> 00:48:07,130 You have t available to you. 865 00:48:07,130 --> 00:48:12,950 So you can basically do a conditional statement on t. 866 00:48:12,950 --> 00:48:18,932 If t is greater than 1 and t is less than 2, set the red light. 867 00:48:18,932 --> 00:48:22,916 868 00:48:22,916 --> 00:48:23,533 [INAUDIBLE] 869 00:48:23,533 --> 00:48:24,908 AUDIENCE: What about [INAUDIBLE]? 870 00:48:24,908 --> 00:48:29,400 871 00:48:29,400 --> 00:48:31,600 QIQI WANG: Oh. 872 00:48:31,600 --> 00:48:32,290 Thank you. 873 00:48:32,290 --> 00:48:33,050 That is wrong. 874 00:48:33,050 --> 00:48:34,070 So it should be F_bar_k. 875 00:48:34,070 --> 00:48:38,690 876 00:48:38,690 --> 00:48:39,876 Yeah, it should be F_bar_k. 877 00:48:39,876 --> 00:48:43,620 878 00:48:43,620 --> 00:48:46,350 Thanks. 879 00:48:46,350 --> 00:48:47,420 Yeah. 880 00:48:47,420 --> 00:48:49,720 I should just rename it to something else, 881 00:48:49,720 --> 00:48:58,335 so that-- I'm just going to rename it as 2t. 882 00:48:58,335 --> 00:49:02,290 883 00:49:02,290 --> 00:49:02,790 All right. 884 00:49:02,790 --> 00:49:05,380 885 00:49:05,380 --> 00:49:06,255 AUDIENCE: [INAUDIBLE] 886 00:49:06,255 --> 00:49:11,700 887 00:49:11,700 --> 00:49:14,290 QIQI WANG: Which one [INAUDIBLE]? 888 00:49:14,290 --> 00:49:15,165 AUDIENCE: [INAUDIBLE] 889 00:49:15,165 --> 00:49:19,150 890 00:49:19,150 --> 00:49:19,900 QIQI WANG: Sorry? 891 00:49:19,900 --> 00:49:22,067 AUDIENCE: [INAUDIBLE] 892 00:49:22,067 --> 00:49:22,900 QIQI WANG: This one? 893 00:49:22,900 --> 00:49:26,160 AUDIENCE: Yeah. [INAUDIBLE] 894 00:49:26,160 --> 00:49:28,430 QIQI WANG: Yeah. [INAUDIBLE] plus 1, right? 895 00:49:28,430 --> 00:49:31,530 So because I'm looking, I [INAUDIBLE] the interface. 896 00:49:31,530 --> 00:49:33,800 I want to look at the interface [INAUDIBLE] 897 00:49:33,800 --> 00:49:38,878 decide which side I should upwind the flux at k_plus_half. 898 00:49:38,878 --> 00:49:42,200 899 00:49:42,200 --> 00:49:48,335 In order to make a decision, I want my [INAUDIBLE] speed 900 00:49:48,335 --> 00:49:50,440 at k_plus_half. 901 00:49:50,440 --> 00:49:53,120 And the right way to [INAUDIBLE] the other [INAUDIBLE] 902 00:49:53,120 --> 00:49:57,308 here k_plus_half is take the average of the [INAUDIBLE] 903 00:49:57,308 --> 00:50:00,100 speed [INAUDIBLE] at k(and) k plus 1. 904 00:50:00,100 --> 00:50:05,000 905 00:50:05,000 --> 00:50:07,120 Just to make the code easier to understand, 906 00:50:07,120 --> 00:50:19,680 I just want to change-- I think I want to replace-- oh. 907 00:50:19,680 --> 00:50:24,300 I think I want to replace my i with k. 908 00:50:24,300 --> 00:50:27,891 909 00:50:27,891 --> 00:50:28,390 [INAUDIBLE] 910 00:50:28,390 --> 00:50:32,910 911 00:50:32,910 --> 00:50:35,660 All right. 912 00:50:35,660 --> 00:50:36,160 Yeah. 913 00:50:36,160 --> 00:50:40,360 So instead of-- it's easier to replace [INAUDIBLE] 914 00:50:40,360 --> 00:50:41,884 k_plus_half than [INAUDIBLE]. 915 00:50:41,884 --> 00:50:46,132 916 00:50:46,132 --> 00:50:48,970 AUDIENCE: [INAUDIBLE] 917 00:50:48,970 --> 00:50:51,440 QIQI WANG: Why did I half t? 918 00:50:51,440 --> 00:50:55,800 I wanted to half t, because what I like you to do now 919 00:50:55,800 --> 00:51:00,390 is to set a [INAUDIBLE] when t is [INAUDIBLE]. 920 00:51:00,390 --> 00:51:18,210 921 00:51:18,210 --> 00:51:18,710 OK. 922 00:51:18,710 --> 00:51:22,180 So what happens on the red light? 923 00:51:22,180 --> 00:51:23,680 AUDIENCE: [INAUDIBLE] 924 00:51:23,680 --> 00:51:24,601 QIQI WANG: Huh? 925 00:51:24,601 --> 00:51:26,710 AUDIENCE: [INAUDIBLE] 926 00:51:26,710 --> 00:51:28,570 QIQI WANG: Yeah, the [INAUDIBLE] goes to 0. 927 00:51:28,570 --> 00:51:30,040 That's one way to say it. 928 00:51:30,040 --> 00:51:34,549 Another way to say it is no cars can pass, right? 929 00:51:34,549 --> 00:51:37,208 If no cars can pass, then the [INAUDIBLE] 930 00:51:37,208 --> 00:51:41,030 pass through the red light is what? 931 00:51:41,030 --> 00:51:41,966 0, right? 932 00:51:41,966 --> 00:51:44,880 933 00:51:44,880 --> 00:51:51,150 So what I can do here is that before I compute k minus half, 934 00:51:51,150 --> 00:51:54,870 I just want to say if k is greater 935 00:51:54,870 --> 00:52:04,430 than 1 t is less than 2, F_k_plus_half at the end-- 936 00:52:04,430 --> 00:52:07,820 so k_plus_half-- the last one is basically the right hand 937 00:52:07,820 --> 00:52:12,818 and also the left hand-- is equal to 0. 938 00:52:12,818 --> 00:52:16,500 I think I [INAUDIBLE]. 939 00:52:16,500 --> 00:52:17,000 OK. 940 00:52:17,000 --> 00:52:19,868 That's it. 941 00:52:19,868 --> 00:52:22,360 That's what I need to do. 942 00:52:22,360 --> 00:52:31,620 Now, in the trafficDriver, let me set it to-- ah, ah, ah. 943 00:52:31,620 --> 00:52:34,056 Let me copy this trafficDriver for the [INAUDIBLE]. 944 00:52:34,056 --> 00:52:39,020 945 00:52:39,020 --> 00:52:39,520 Yeah. 946 00:52:39,520 --> 00:52:41,690 I think we're overwriting [INAUDIBLE]. 947 00:52:41,690 --> 00:52:46,460 And it's going to save trafficDriver [INAUDIBLE]. 948 00:52:46,460 --> 00:52:54,270 949 00:52:54,270 --> 00:52:54,770 OK. 950 00:52:54,770 --> 00:52:58,290 951 00:52:58,290 --> 00:52:59,965 Now, instead of 1 over dt, I'm going 952 00:52:59,965 --> 00:53:03,840 to simulate it for five time units, 953 00:53:03,840 --> 00:53:07,542 so that I actually see the light. 954 00:53:07,542 --> 00:53:10,601 955 00:53:10,601 --> 00:53:11,100 OK. 956 00:53:11,100 --> 00:53:16,362 We see the same thing here [INAUDIBLE]. 957 00:53:16,362 --> 00:53:18,400 At sometimes, the light [INAUDIBLE]. 958 00:53:18,400 --> 00:53:22,450 959 00:53:22,450 --> 00:53:23,390 Yeah, OK. 960 00:53:23,390 --> 00:53:26,660 See, the lights is in effect here. 961 00:53:26,660 --> 00:53:28,590 All the [INAUDIBLE] simulates here. 962 00:53:28,590 --> 00:53:31,280 And then we have even [INAUDIBLE] 963 00:53:31,280 --> 00:53:34,490 that actually goes backward. 964 00:53:34,490 --> 00:53:34,990 OK. 965 00:53:34,990 --> 00:53:38,280 Now, there is no cars moving. 966 00:53:38,280 --> 00:53:40,116 All the cars are stopped over there. 967 00:53:40,116 --> 00:53:42,870 968 00:53:42,870 --> 00:53:46,680 So this is a parking lot while there is no cars here. 969 00:53:46,680 --> 00:53:48,690 And at [INAUDIBLE] equal to 2 or [INAUDIBLE]. 970 00:53:48,690 --> 00:53:51,308 971 00:53:51,308 --> 00:53:52,183 AUDIENCE: [INAUDIBLE] 972 00:53:52,183 --> 00:54:03,660 973 00:54:03,660 --> 00:54:15,960 QIQI WANG: Did I-- did I-- what's happening? 974 00:54:15,960 --> 00:54:16,460 OK. 975 00:54:16,460 --> 00:54:20,962 If t is greater than 1 and t is less than 2-- 976 00:54:20,962 --> 00:54:23,332 AUDIENCE: [INAUDIBLE] 977 00:54:23,332 --> 00:54:25,580 QIQI WANG: And never goes passed 2, are you sure? 978 00:54:25,580 --> 00:54:29,624 979 00:54:29,624 --> 00:54:30,499 AUDIENCE: [INAUDIBLE] 980 00:54:30,499 --> 00:54:53,797 981 00:54:53,797 --> 00:54:54,380 QIQI WANG: OK. 982 00:54:54,380 --> 00:54:58,028 I think I know what's happening. 983 00:54:58,028 --> 00:54:59,920 So I actually have come to a situation 984 00:54:59,920 --> 00:55:03,784 where-- hm, let me think. 985 00:55:03,784 --> 00:55:21,988 986 00:55:21,988 --> 00:55:24,450 AUDIENCE: [INAUDIBLE]. 987 00:55:24,450 --> 00:55:25,330 What 988 00:55:25,330 --> 00:55:26,896 QIQI WANG: Yeah. 989 00:55:26,896 --> 00:55:28,590 Let me do this. 990 00:55:28,590 --> 00:55:32,730 I'm actually encountering a situation that cannot be 991 00:55:32,730 --> 00:55:34,430 handled by this [INAUDIBLE]. 992 00:55:34,430 --> 00:55:39,610 993 00:55:39,610 --> 00:55:46,780 What is happening is that [INAUDIBLE]-- let me do this. 994 00:55:46,780 --> 00:55:51,252 I think I can change this around by doing this. 995 00:55:51,252 --> 00:55:54,450 996 00:55:54,450 --> 00:55:59,860 I can change this around by not letting the red light 997 00:55:59,860 --> 00:56:01,280 to stop for that long. 998 00:56:01,280 --> 00:56:11,040 So I only let the red light to-- if I only 999 00:56:11,040 --> 00:56:17,810 let the red light go from 0.2, I think 1000 00:56:17,810 --> 00:56:19,890 I'm going to get rid of the problem. 1001 00:56:19,890 --> 00:56:24,950 The problem is that when the red light happens here, 1002 00:56:24,950 --> 00:56:31,200 the flux-- the P at one side shock wave is 1. 1003 00:56:31,200 --> 00:56:34,470 At the other side of the shock wave, the P is equal to 0. 1004 00:56:34,470 --> 00:56:37,820 1005 00:56:37,820 --> 00:56:44,718 So both values of P [INAUDIBLE] equal to 0. 1006 00:56:44,718 --> 00:56:49,856 Because the flux is P times 1 minus P or P minus P squared. 1007 00:56:49,856 --> 00:56:52,640 So the other P is 1 or zero. 1008 00:56:52,640 --> 00:56:54,810 The flux is equal to 0. 1009 00:56:54,810 --> 00:56:58,138 That's why no matter if you take upwinding or downwinding, 1010 00:56:58,138 --> 00:56:59,840 you'll get 0 flux. 1011 00:56:59,840 --> 00:57:02,692 So this is a case where [INAUDIBLE] upwinding 1012 00:57:02,692 --> 00:57:04,960 wouldn't work. 1013 00:57:04,960 --> 00:57:07,894 It's like a singular case where [INAUDIBLE] upwinding 1014 00:57:07,894 --> 00:57:10,800 wouldn't work over here. 1015 00:57:10,800 --> 00:57:13,550 So what I'm going to do here is am going 1016 00:57:13,550 --> 00:57:16,670 to set something artificial. 1017 00:57:16,670 --> 00:57:23,445 And let's say when there is a red light, 1018 00:57:23,445 --> 00:57:26,880 I think I'm just going to set the flux equal to 0.01. 1019 00:57:26,880 --> 00:57:33,790 So that there is a small leakage of cars over the red light, 1020 00:57:33,790 --> 00:57:36,060 so that we actually want to see what 1021 00:57:36,060 --> 00:57:38,560 is going to happen [INAUDIBLE]. 1022 00:57:38,560 --> 00:57:41,589 1023 00:57:41,589 --> 00:57:42,464 AUDIENCE: [INAUDIBLE] 1024 00:57:42,464 --> 00:57:48,012 1025 00:57:48,012 --> 00:57:48,678 QIQI WANG: Yeah. 1026 00:57:48,678 --> 00:57:51,082 So if you take [INAUDIBLE], you're 1027 00:57:51,082 --> 00:57:58,040 going to learn about the entropy conditions of [INAUDIBLE]. 1028 00:57:58,040 --> 00:58:00,122 And the entropy condition tells you 1029 00:58:00,122 --> 00:58:04,800 that there is a physical solution. 1030 00:58:04,800 --> 00:58:07,072 There is a non-physical solution. 1031 00:58:07,072 --> 00:58:09,840 And over here [INAUDIBLE]. 1032 00:58:09,840 --> 00:58:12,264 But then over here it is a physical solution. 1033 00:58:12,264 --> 00:58:15,715 While this kind of an [INAUDIBLE] 1034 00:58:15,715 --> 00:58:17,623 is going to be a non-physical solution. 1035 00:58:17,623 --> 00:58:20,970 1036 00:58:20,970 --> 00:58:27,160 And that cannot be dealt with by the [INAUDIBLE] scheme. 1037 00:58:27,160 --> 00:58:31,480 And you nee a more complex flux scheme 1038 00:58:31,480 --> 00:58:34,990 to deal with situations like that. 1039 00:58:34,990 --> 00:58:35,865 AUDIENCE: [INAUDIBLE] 1040 00:58:35,865 --> 00:58:39,650 1041 00:58:39,650 --> 00:58:41,170 QIQI WANG: There is no downwinding. 1042 00:58:41,170 --> 00:58:45,050 And what you need to do is this. 1043 00:58:45,050 --> 00:58:47,860 1044 00:58:47,860 --> 00:58:51,490 What you need do is you need add something 1045 00:58:51,490 --> 00:58:55,340 called numerical dispositing into this. 1046 00:58:55,340 --> 00:59:00,413 So you need to do F_k_plus_half is 1047 00:59:00,413 --> 00:59:10,074 equal to F_k_plus_half plus 0.5 times absolute value of c. 1048 00:59:10,074 --> 00:59:13,790 1049 00:59:13,790 --> 00:59:21,480 So instead of taking the c's, you 1050 00:59:21,480 --> 00:59:26,170 want to take the absolute value of c's and divide by 2. 1051 00:59:26,170 --> 00:59:30,502 So this is like a very similar concept to upwinding. 1052 00:59:30,502 --> 00:59:33,080 But it operates differently. 1053 00:59:33,080 --> 00:59:37,265 You need to take the absolute value of c, 1054 00:59:37,265 --> 00:59:48,722 but multiply that with u_bar and plus_half. 1055 00:59:48,722 --> 00:59:58,045 So it's minus [INAUDIBLE] u_bar minus 1 0, minus 1. 1056 00:59:58,045 --> 01:00:00,910 1057 01:00:00,910 --> 01:00:05,910 So you need to kind of-- so instead of doing upwinding, 1058 01:00:05,910 --> 01:00:10,660 you need to use a numerical dispositive 1059 01:00:10,660 --> 01:00:18,930 or a numerical diffusion to basically achieve 1060 01:00:18,930 --> 01:00:22,680 the impact of upwinding, but do this a little bit differently. 1061 01:00:22,680 --> 01:00:26,680 But that's kind of beyond the scope of this class. 1062 01:00:26,680 --> 01:00:29,540 So, yeah, If you want to learn that, 1063 01:00:29,540 --> 01:00:32,110 you're welcome to take the [INAUDIBLE]. 1064 01:00:32,110 --> 01:00:36,675 We are going to be learning all about [INAUDIBLE] speed. 1065 01:00:36,675 --> 01:00:39,342 So let's see if this goes [INAUDIBLE]. 1066 01:00:39,342 --> 01:00:44,794 1067 01:00:44,794 --> 01:00:45,294 OK. 1068 01:00:45,294 --> 01:00:46,782 So we have the [INAUDIBLE]. 1069 01:00:46,782 --> 01:00:51,738 1070 01:00:51,738 --> 01:00:52,238 OK. 1071 01:00:52,238 --> 01:00:53,950 Now, the cars are starting to move. 1072 01:00:53,950 --> 01:00:57,282 1073 01:00:57,282 --> 01:01:05,104 [INAUDIBLE] the light goes green, the cars start to move. 1074 01:01:05,104 --> 01:01:12,000 1075 01:01:12,000 --> 01:01:15,110 To do it properly, you have to change this back 1076 01:01:15,110 --> 01:01:17,500 to the central average. 1077 01:01:17,500 --> 01:01:20,954 So you do upwinding or add numerical dispositive, 1078 01:01:20,954 --> 01:01:21,850 but don't do both. 1079 01:01:21,850 --> 01:01:26,050 And doing both, so the scheme works, 1080 01:01:26,050 --> 01:01:28,446 but it's not as accurate. 1081 01:01:28,446 --> 01:01:34,490 It's suffers from additional numerical dissipation. 1082 01:01:34,490 --> 01:01:35,130 OK. 1083 01:01:35,130 --> 01:01:43,230 So I hope you have fun playing with this small example here. 1084 01:01:43,230 --> 01:01:47,250 So starting from our next lecture, the next lecture 1085 01:01:47,250 --> 01:01:50,822 we're going to be doing a review for the midterm. 1086 01:01:50,822 --> 01:01:52,530 But starting from after the midterm, 1087 01:01:52,530 --> 01:01:56,150 we're going to be talking about first of all, stability 1088 01:01:56,150 --> 01:01:58,630 of solution of positive differential equations, 1089 01:01:58,630 --> 01:02:02,032 and then talk about finite [INAUDIBLE] method, which 1090 01:02:02,032 --> 01:02:03,740 is the third method we are going to start 1091 01:02:03,740 --> 01:02:04,965 in fall for [INAUDIBLE]. 1092 01:02:04,965 --> 01:02:08,430 1093 01:02:08,430 --> 01:02:09,330 All right. 1094 01:02:09,330 --> 01:02:11,480 We'll see you next week. 1095 01:02:11,480 --> 01:02:21,012