1
00:00:00,330 --> 00:00:04,080
So now we know how all of this works in one dimension.

2
00:00:04,860 --> 00:00:09,960
But to be honest, mathematically speaking, it wasn't really a one dimensional problem.

3
00:00:10,200 --> 00:00:16,590
It was already an end dimensional problem because we had these and coupled differential equations.

4
00:00:17,820 --> 00:00:23,730
So now we'll go into the two dimensions in the physical sense.

5
00:00:24,120 --> 00:00:26,940
And so here the equation will change a bit.

6
00:00:27,510 --> 00:00:32,910
So we will now, instead of using the Second Order special derivative, we used a La Plus operator,

7
00:00:33,270 --> 00:00:34,930
which gives us now two terms.

8
00:00:34,950 --> 00:00:36,700
So we have the X derivative.

9
00:00:36,720 --> 00:00:40,830
Second Order and the wider relative second order acting on you.

10
00:00:42,000 --> 00:00:48,090
And so if we dis criticize the both of these terms here, we get something like this.

11
00:00:48,750 --> 00:00:55,680
So this time, or you will of course, still be spatial dependent, but it will be an array which is

12
00:00:55,680 --> 00:00:57,270
of ordered and my end.

13
00:00:57,660 --> 00:00:59,310
So it's a much larger array.

14
00:01:00,150 --> 00:01:06,210
And when we just read ties to derivative, when we go along the X direction, we have to change the

15
00:01:06,210 --> 00:01:07,100
first index.

16
00:01:07,110 --> 00:01:13,650
And when we split ties to the derivative in the y direction, we go along the second index.

17
00:01:14,490 --> 00:01:19,740
And this is basically all we have to change from a fundamental point of view.

18
00:01:20,640 --> 00:01:25,920
So here I have copied from previously our function, which was here still one dimensional.

19
00:01:26,280 --> 00:01:31,970
And then the command where we have called integrate dots of underscore IBP and we have to change this

20
00:01:32,010 --> 00:01:32,790
now in just a bit.

21
00:01:33,900 --> 00:01:38,520
So when we change it here to the two dimensional case, we have to of course change it here as well.

22
00:01:39,600 --> 00:01:46,350
And we have to write that this is not anymore, just an array of length you.

23
00:01:46,890 --> 00:01:57,000
But instead, it's an array of length, u times length you so we can write down like this, for example.

24
00:02:01,140 --> 00:02:08,850
OK, so now we have an array when when the length of you is 100, now it's an array of 100 times 100.

25
00:02:09,270 --> 00:02:12,450
So we have 10000 entries that are zero here.

26
00:02:13,830 --> 00:02:18,040
And for the derivative, we can use this in the very cool.

27
00:02:18,060 --> 00:02:21,540
We can use the same approach basically in a very cool way.

28
00:02:22,140 --> 00:02:29,160
We go for the index, for the X coordinate and for the Y coordinate basically through the whole array,

29
00:02:29,160 --> 00:02:31,710
except for the first and the last index.

30
00:02:32,250 --> 00:02:34,140
And then we do the same thing here.

31
00:02:35,100 --> 00:02:39,810
So this time I will use this term already in this line.

32
00:02:40,200 --> 00:02:41,520
So I don't like this.

33
00:02:43,230 --> 00:02:48,330
So basically, here we change only the first index.

34
00:02:48,930 --> 00:02:59,520
So like this second index stays as it was, and then we multiply here a divided by x squared.

35
00:03:00,300 --> 00:03:08,730
And then we add here another term, which is the second term were basically the constant index will

36
00:03:08,730 --> 00:03:13,260
be the first one and only the second index will be changed.

37
00:03:14,700 --> 00:03:20,610
So like this and here we must write eight times D.I.Y. Square.

38
00:03:22,360 --> 00:03:27,370
So, of course, then we must define the why, which in our case, we will also choose to be one.

39
00:03:27,910 --> 00:03:30,130
And now we are basically done.

40
00:03:31,090 --> 00:03:35,230
So this means now we have a nice function that we can call.

41
00:03:36,830 --> 00:03:42,200
For example, we could see f 2d at some point of time, it doesn't matter because our function is not

42
00:03:42,200 --> 00:03:44,100
time dependent so we can write any time.

43
00:03:44,120 --> 00:03:44,960
For example, one.

44
00:03:45,500 --> 00:03:52,790
And then for you, we write an array and p towards Perry, and now we can write, for example, of one

45
00:03:52,790 --> 00:03:55,380
to three comma.

46
00:03:58,670 --> 00:04:04,340
Maybe like this four or five six seven eight nine.

47
00:04:06,860 --> 00:04:10,790
And then we run this and then this will be our output.

48
00:04:11,660 --> 00:04:15,230
So of course, this now looks a bit bit odd.

49
00:04:15,500 --> 00:04:18,620
This was because I've chosen these numbers in an odd way.

50
00:04:22,100 --> 00:04:23,780
So yeah, it must be quite dramatic.

51
00:04:24,230 --> 00:04:24,980
Maybe like this?

52
00:04:25,100 --> 00:04:25,400
Yeah.

53
00:04:26,000 --> 00:04:26,660
OK, good.

54
00:04:26,680 --> 00:04:28,910
Now we have a working example.

55
00:04:29,690 --> 00:04:35,080
So this means the uttermost values are still zero because we don't touch them.

56
00:04:35,090 --> 00:04:36,110
They are not updated.

57
00:04:36,110 --> 00:04:37,070
The remains, the euro.

58
00:04:37,080 --> 00:04:42,140
So basically, we have a heat bath along all the edges of the sample and just in the middle.

59
00:04:42,440 --> 00:04:47,840
It will be updated and Tier will calculate the second derivative, according to this term.

60
00:04:47,870 --> 00:04:53,630
So basically the Le Plus operator acting on the function you.

61
00:04:55,190 --> 00:05:02,510
OK, so now we know this works, but you have seen the input and the output are always arrays of the

62
00:05:02,580 --> 00:05:05,240
size, size, coma, size.

63
00:05:06,380 --> 00:05:10,810
And this is a problem because if we now run this, it will give us an error.

64
00:05:13,610 --> 00:05:15,200
Maybe the problem is here

65
00:05:18,950 --> 00:05:21,950
that the zero was not an array that is quadratic.

66
00:05:22,340 --> 00:05:26,390
So let's change this and here let's change, for example, to this one.

67
00:05:27,110 --> 00:05:28,760
But still, it's not working.

68
00:05:29,330 --> 00:05:32,180
And when we scroll down, we see what is the problem here?

69
00:05:32,750 --> 00:05:39,620
The problem is then use that y zero, which is in this case, the initial condition, which in our case

70
00:05:39,620 --> 00:05:42,860
is called u0, must be one dimensional.

71
00:05:44,000 --> 00:05:51,250
So if you remember previously in all the examples or starting condition was just a one dimensional array,

72
00:05:51,250 --> 00:05:52,580
it was basically a list.

73
00:05:53,450 --> 00:05:58,070
And now it is an array that is of size, size, time, size.

74
00:05:58,080 --> 00:06:00,920
So it's a 100 by 100 array.

75
00:06:01,880 --> 00:06:09,140
So it is not compatible with the integrate dot solve on the school IVP command, and we must change

76
00:06:09,140 --> 00:06:09,380
this.

77
00:06:09,390 --> 00:06:15,670
We must flatten disarray to be just a single array of the size 10000.

78
00:06:15,680 --> 00:06:17,960
So basically we just have to remove the brackets.

79
00:06:19,190 --> 00:06:25,490
So this is pretty easy when we just want to address here the starting conditions.

80
00:06:26,630 --> 00:06:30,140
For example, we could write you zero dot flatten.

81
00:06:31,580 --> 00:06:34,670
So then the starting condition is a flattened array.

82
00:06:35,870 --> 00:06:42,740
However, still we get the error, but this time it's not the error anymore that the y zero must be

83
00:06:42,740 --> 00:06:43,610
one dimensional.

84
00:06:44,240 --> 00:06:52,430
But here we see now that there is a problem with the EU new in our function, which appears to be one

85
00:06:52,430 --> 00:06:55,640
dimensional, but we expected to indices.

86
00:06:55,910 --> 00:07:02,840
So you see the use zero dot flattens or initial condition, which will then beat this value is now one

87
00:07:02,840 --> 00:07:03,560
dimensional.

88
00:07:03,920 --> 00:07:07,160
So it's basically of Rs 10000.

89
00:07:07,940 --> 00:07:12,860
But here we we give two indices, so it doesn't know how to apply this.

90
00:07:13,640 --> 00:07:16,970
So that's really a problem here, but we have to solve as well.

91
00:07:17,310 --> 00:07:26,000
There exists now many ways to solve this problem, but the very, very simple one is to just first flatten

92
00:07:26,570 --> 00:07:34,790
or so first reshape the array to be of size and timing size ends or 100 times 100.

93
00:07:35,180 --> 00:07:36,860
And then, in the end, flatten it again.

94
00:07:37,130 --> 00:07:38,420
So let me show you what I mean.

95
00:07:39,170 --> 00:07:44,210
It's a pretty straightforward solution, even though it's probably not the most elegant one.

96
00:07:44,390 --> 00:07:49,760
So as I said, in the end, we must flatten so that the shape fits.

97
00:07:50,300 --> 00:07:55,550
So I call this here flattened, so I could also change it directly here.

98
00:07:55,550 --> 00:08:00,890
But I just want to keep it for educational purposes so that you have the initial solution here.

99
00:08:01,760 --> 00:08:04,340
And then we must change here to flatten it.

100
00:08:05,930 --> 00:08:14,870
And now the only thing left to do, I think, is that we right here that this is of size.

101
00:08:18,480 --> 00:08:19,710
X come out.

102
00:08:22,020 --> 00:08:22,640
Size.

103
00:08:23,040 --> 00:08:23,520
Why?

104
00:08:24,090 --> 00:08:26,820
Because in general, it doesn't have to be quadratic here.

105
00:08:27,480 --> 00:08:29,910
So, for example, we can then change it here as well.

106
00:08:31,620 --> 00:08:38,090
And we must introduce this time the size X and size Y beforehand.

107
00:08:38,820 --> 00:08:39,750
So how it works.

108
00:08:40,320 --> 00:08:52,050
And now the only thing that's left to do is we must right you is you don't reshape size x color size

109
00:08:52,050 --> 00:08:52,500
Y.

110
00:08:53,250 --> 00:09:01,110
So we come here, we call you zero flatten, which is then just an array with a single bracket to you

111
00:09:01,890 --> 00:09:05,160
and then and therefore just a single index.

112
00:09:05,580 --> 00:09:07,260
And then we reshape it.

113
00:09:07,380 --> 00:09:13,200
So we introduce additional brackets and so that we can address two of these indices.

114
00:09:13,500 --> 00:09:19,530
Then we do the same thing as we did before where we check that worked and then to return the value we

115
00:09:19,530 --> 00:09:20,430
flatten out again.

116
00:09:20,550 --> 00:09:22,620
So that's a bit of a trick that we are using here.

117
00:09:23,290 --> 00:09:26,250
So let's see if I have any typo or with words.

118
00:09:26,790 --> 00:09:27,630
OK, looks good.

119
00:09:27,630 --> 00:09:29,640
So at least there is no around this time.

120
00:09:30,060 --> 00:09:35,400
So now we can go ahead and see what is the solution.

121
00:09:36,150 --> 00:09:39,150
But to be honest, since I have checked this before.

122
00:09:39,780 --> 00:09:46,440
Let me change a bit of the starting parameters here because in this example, only one of the corners

123
00:09:46,440 --> 00:09:49,280
will be heated to one and this is way too less.

124
00:09:49,290 --> 00:09:52,890
So we will not see anything if we just hit a single corner.

125
00:09:53,340 --> 00:09:56,550
We must, we must hit at least a single side.

126
00:09:57,190 --> 00:10:02,370
So, for example, we could write like this, then the whole left side is heated up to one.

127
00:10:04,330 --> 00:10:10,870
OK, so we could also hit the left side and the bottom side, then we would ride like this.

128
00:10:14,950 --> 00:10:15,310
Good.

129
00:10:15,970 --> 00:10:18,370
So now let's go ahead and let's plot this.

130
00:10:19,060 --> 00:10:25,330
And here is now a bit difficult because we have no two coordinates X and Y, and we have the time,

131
00:10:25,330 --> 00:10:27,820
so we have to think of a nice way to plot this.

132
00:10:28,330 --> 00:10:31,390
In any case, we must plot it using such a contour plot.

133
00:10:32,350 --> 00:10:34,750
So let me show you what you could do.

134
00:10:35,200 --> 00:10:37,870
So this time I call this text list and why lists?

135
00:10:38,470 --> 00:10:47,770
And I arranged these by using once again the NPR dot mesh grid, but with NPR range size X and size

136
00:10:47,770 --> 00:10:48,220
white.

137
00:10:49,300 --> 00:10:56,230
And then the X label will be coordinates X and the Y label will be coordinate y.

138
00:10:57,280 --> 00:11:00,220
And then here we have X list and wait lists.

139
00:11:01,570 --> 00:11:10,600
And now we want to plot the solution plot y and we want to plot all of the coordinates for one particular

140
00:11:10,600 --> 00:11:11,470
time index.

141
00:11:12,340 --> 00:11:22,750
So I call this T index and for example, we could call here T Index just to start just to see what happens

142
00:11:22,750 --> 00:11:23,560
at the very beginning.

143
00:11:25,700 --> 00:11:33,170
So when I run this, it gives me an aura, because the problem is that dizzy value.

144
00:11:33,410 --> 00:11:41,000
So basically the this one must be two dimensional and it is one dimensional because we have flattened

145
00:11:41,000 --> 00:11:41,300
here.

146
00:11:41,930 --> 00:11:43,670
So once again, we must reshape.

147
00:11:44,390 --> 00:11:45,440
So basically this one.

148
00:11:47,890 --> 00:11:50,170
Apply its to this one.

149
00:11:51,820 --> 00:11:59,950
And now it works, and you see this is the plot of the temperature for all of the X and Y coordinates

150
00:12:00,160 --> 00:12:02,410
at the time, Step T equals zero.

151
00:12:04,120 --> 00:12:11,290
So now let me make this just a bit nicer by adding here a label Pulte dots for the label of title.

152
00:12:11,290 --> 00:12:25,420
I mean, the title is time is equal to then people must turn this to a string solution dot t t index.

153
00:12:26,560 --> 00:12:29,590
So now we have a title here T is equal to zero.

154
00:12:30,910 --> 00:12:33,220
And now I want to plot several of these plots.

155
00:12:33,640 --> 00:12:40,780
And to do this, you could either copy this to individual cells because a single cell can only have

156
00:12:40,780 --> 00:12:44,620
a single output or you just write Peel T show.

157
00:12:45,250 --> 00:12:48,070
So no, nothing happens or nothing changes, but I to see.

158
00:12:48,880 --> 00:12:55,870
But now we can copy this several times and we can change it here to T and divided by two.

159
00:12:56,500 --> 00:12:59,800
And then the last one would be T end.

160
00:13:01,630 --> 00:13:05,140
And so we have no three plots at time equals zero.

161
00:13:05,590 --> 00:13:09,370
After half the time and after the total time.

162
00:13:12,190 --> 00:13:13,150
So it turns out.

163
00:13:15,000 --> 00:13:16,920
Here we are at 50.

164
00:13:16,950 --> 00:13:22,410
Here we are at 100, so there isn't that much of a difference, but you can see already how the left

165
00:13:22,410 --> 00:13:29,400
and the bottom really heat up the sample and how the heat or the temperature extends already far deeper

166
00:13:29,400 --> 00:13:30,420
into the sample.

167
00:13:30,990 --> 00:13:36,810
Compared to this one, we're only very, very left in the bottom were heated up to now to explore the

168
00:13:36,810 --> 00:13:38,080
physics a bit more.

169
00:13:38,100 --> 00:13:42,600
Let's increase the simulation time to 10000.

170
00:13:43,800 --> 00:13:49,980
So of course, now it takes much longer to simulate because this is now really already quite demanding

171
00:13:49,980 --> 00:14:00,390
because we have a system of 100 times 100 cell indices, so 10000 elements, 10000 equations that are

172
00:14:00,390 --> 00:14:02,860
propagated for 10000 timestamps.

173
00:14:02,880 --> 00:14:05,520
So of course, this is quite a demanding calculation.

174
00:14:06,210 --> 00:14:12,000
So especially if you have a bit of a weaker PC than maybe you shouldn't go to 10000 tier, but maybe

175
00:14:12,000 --> 00:14:15,480
stop at, I don't know, 2000 or so.

176
00:14:16,200 --> 00:14:17,430
But now it's finished for me.

177
00:14:17,430 --> 00:14:24,270
And you see here we have some nice gradient and maybe here I use like this.

178
00:14:24,390 --> 00:14:25,620
Now we can nicely compare.

179
00:14:28,710 --> 00:14:31,290
Yeah, or even like this.

180
00:14:32,840 --> 00:14:38,940
Now we have it at zero, at 50 and at 10000.

181
00:14:40,230 --> 00:14:48,570
So you see here we have some nice temperature change or some, some some some light heating up of the

182
00:14:48,570 --> 00:14:54,600
sample where you see the heat extends over a bit of into the interior.

183
00:14:54,870 --> 00:15:00,540
And here you see, we have a very nice gradient and the heat is equally distributed where these two

184
00:15:00,540 --> 00:15:04,230
edges are heat paths, where the temperature is always equal to one.

185
00:15:04,680 --> 00:15:09,960
And here we have heat paths that are always where the temperature is always equal to zero.

186
00:15:10,260 --> 00:15:14,220
So of course, in between, we have some nice homogenous gradients.

187
00:15:15,450 --> 00:15:21,150
So before I conclude, I want to just show you what happens when you change the starting conditions.

188
00:15:21,510 --> 00:15:25,830
So I've just copied these two cells from before, so nothing has changed here yet.

189
00:15:26,100 --> 00:15:27,990
This is just to your starting conditions.

190
00:15:28,380 --> 00:15:32,940
Calling the solve underscore IVP commands and then here to plot.

191
00:15:33,720 --> 00:15:42,430
And what I will change is I will also make the right and the upper edges heat bath with a temperature

192
00:15:42,430 --> 00:15:42,990
of four one.

193
00:15:43,650 --> 00:15:47,670
So for this, I have to write you minus one and you also minus one.

194
00:15:48,690 --> 00:15:52,500
And now we have heat buffs everywhere, except for the middle.

195
00:15:53,430 --> 00:15:59,790
So I run this and once again, it takes a few seconds because it's quite a difficult calculation.

196
00:16:00,840 --> 00:16:03,180
But once it's finished, we will see what happens.

197
00:16:03,630 --> 00:16:06,880
So you see here we have this nice gradient from hot to cold.

198
00:16:06,900 --> 00:16:09,000
What happens if we heat here as well?

199
00:16:09,510 --> 00:16:12,390
So probably everything will then heat up and get hot.

200
00:16:12,970 --> 00:16:14,190
But let's see what happens.

201
00:16:16,130 --> 00:16:18,080
Shouldn't take too long anymore.

202
00:16:25,660 --> 00:16:31,250
And now we're finally finished, and he said the results at T equals zero.

203
00:16:31,270 --> 00:16:36,700
We have only heated up areas at the edges and in the middle it's zero, as we have specified.

204
00:16:37,330 --> 00:16:43,270
And then you see, after 50 seconds, the heat really penetrates into the middle, where it starts to

205
00:16:43,270 --> 00:16:44,950
heat up more and more to sample.

206
00:16:45,730 --> 00:16:50,870
And yeah, here you see, basically, everything is very, very close to one.

207
00:16:51,130 --> 00:16:53,020
So it's a bit of an odd way to plot this.

208
00:16:53,020 --> 00:16:55,330
This means one plus the value here.

209
00:16:55,330 --> 00:17:02,380
So you see, it's pretty pretty close to one and you just have some very small distribution here of

210
00:17:02,500 --> 00:17:02,790
heat.

211
00:17:02,800 --> 00:17:09,690
But basically, you could say, OK, after such a long time, everything is heated up and equal to one

212
00:17:09,700 --> 00:17:13,260
because you heat up from everywhere and you cool from nowhere.

213
00:17:13,270 --> 00:17:17,470
So of course, the whole sample will heat up to the temperature of one.

214
00:17:19,000 --> 00:17:19,450
All right.

215
00:17:19,450 --> 00:17:27,790
So we have solved here the heat equation, which was a bit of a different class of problem because we

216
00:17:27,790 --> 00:17:35,050
did not simulate a single object with just a single or two or three coordinates, but we simulated really

217
00:17:35,050 --> 00:17:43,180
an array of multiple cells with which each contain individual values in this case for the temperature.

218
00:17:44,230 --> 00:17:50,320
And we have seen that this leads us to and coupled differential equations or in the two-dimensional

219
00:17:50,320 --> 00:17:53,520
case, even end times and coupled differential equations.

220
00:17:53,530 --> 00:18:01,510
We have seen that we are easily capable of solving a system consisting of 10000 cells, and so we have

221
00:18:01,510 --> 00:18:04,770
to propagate 10000 differential equations at the same time.

222
00:18:04,840 --> 00:18:13,000
And this was no problem for the for the command integrator to solve, underscore IVP that we have used

223
00:18:13,000 --> 00:18:13,660
previously.

224
00:18:14,200 --> 00:18:18,100
But once again, the method was quite similar as before.

225
00:18:18,130 --> 00:18:25,390
The only thing that we had to take care of was that the function and the input parameters, the starting

226
00:18:25,390 --> 00:18:31,660
parameters are all flattened, so it must just be a one dimensional list or an array of numbers.

227
00:18:32,020 --> 00:18:38,680
So we have to get rid of the brackets first and then we have to be clever and reorganize our data later

228
00:18:38,680 --> 00:18:42,790
on for the plotting, for example, to make it such a two dimensional system.

