1
00:00:00,150 --> 00:00:07,710
So now let's go ahead and let's implement these equations, so we have no end coupled equations and

2
00:00:07,710 --> 00:00:12,540
it can be a bit tricky to really define the function.

3
00:00:12,540 --> 00:00:18,900
So we as as previously we must define a function that basically is an array with all the right hand

4
00:00:18,900 --> 00:00:20,220
sides of these equations.

5
00:00:20,370 --> 00:00:23,940
So it will be after what we could call it.

6
00:00:23,940 --> 00:00:28,830
And then as the arguments, we have to time and then the array, which is you in our case.

7
00:00:29,790 --> 00:00:37,800
So when you goes with the index from zero to and minus one in Python language, and of course, we must

8
00:00:37,800 --> 00:00:39,720
update now to you.

9
00:00:40,080 --> 00:00:43,650
So we must write to you and you is something and then return.

10
00:00:44,730 --> 00:00:47,310
You knew it, since this is a bit tricky.

11
00:00:47,430 --> 00:00:49,560
Let me start with a more simple example.

12
00:00:50,070 --> 00:00:55,350
So testing cell here, this is often quite useful if you don't really know how to proceed.

13
00:00:56,250 --> 00:01:00,960
You just start with a simple example, and as I said, you is an error rate.

14
00:01:01,920 --> 00:01:05,150
So let's just use some numbers, for example, the square numbers.

15
00:01:06,780 --> 00:01:13,710
And then what we do is we generate you knew which I just call you here.

16
00:01:13,860 --> 00:01:23,490
And first of all, we say it's given by MP dot zeros and the length is five.

17
00:01:24,810 --> 00:01:29,370
So when you run this, we have now to erase you.

18
00:01:30,030 --> 00:01:32,370
Or maybe let's let's do it like this.

19
00:01:33,660 --> 00:01:34,770
Sorry for the confusion.

20
00:01:34,770 --> 00:01:35,880
So let's do it like this.

21
00:01:35,880 --> 00:01:41,010
You as this array and you new is an array of zeros.

22
00:01:42,180 --> 00:01:51,060
So now we update you new starting from one, then going to minus one.

23
00:01:51,960 --> 00:01:56,040
So this means we do not consider you zero in next.

24
00:01:56,220 --> 00:02:01,950
So we leave out the very left element and we go to minus one, which is the last one.

25
00:02:02,310 --> 00:02:06,240
But in the Python syntax, this one will be excluded.

26
00:02:06,480 --> 00:02:08,919
So actually, we only go to here.

27
00:02:08,940 --> 00:02:15,780
So in this particular example, we only considered these three entries and not the left one, not the

28
00:02:15,780 --> 00:02:16,320
right one.

29
00:02:17,520 --> 00:02:24,750
And this one is, are these three elements are given or are calculated in the following way you.

30
00:02:27,520 --> 00:02:33,190
Starting from two going to the end, so we just write nothing minus two times.

31
00:02:34,810 --> 00:02:35,710
You.

32
00:02:39,940 --> 00:02:49,780
Going from one to minus one, so this would be exactly the same indices as here and then plus you starting

33
00:02:49,780 --> 00:02:51,190
from the very first one.

34
00:02:51,340 --> 00:02:53,560
So we're right nothing and going to minus two.

35
00:02:54,640 --> 00:02:57,430
So this is exactly what is written down here.

36
00:02:57,610 --> 00:03:02,830
So for every index, we basically shift a tier one upwards.

37
00:03:03,370 --> 00:03:08,560
Here we keep the indices, here we shift downwards, you could say.

38
00:03:09,430 --> 00:03:16,090
And so in this way, we have implemented these whole equations except for the very left and for the

39
00:03:16,090 --> 00:03:16,690
very right.

40
00:03:17,590 --> 00:03:26,410
So if I run this, we have now you knew, which basically is the the river tiff or the the second order

41
00:03:26,410 --> 00:03:27,040
derivative.

42
00:03:27,820 --> 00:03:29,710
So for left and right, it is zero.

43
00:03:30,010 --> 00:03:38,110
And then since we have to find a tier of zeros and then here for the middle elements it is given by

44
00:03:38,110 --> 00:03:44,890
justice critics, the equation and we have left out he and Delta X, which we won't just say is equal

45
00:03:44,890 --> 00:03:45,310
to one.

46
00:03:47,050 --> 00:03:50,740
OK, so now let's continue and apply this to our function.

47
00:03:52,120 --> 00:03:53,410
So of course we need the aid.

48
00:03:53,950 --> 00:03:56,500
But as I also said, we set it equal to one.

49
00:03:57,730 --> 00:03:58,300
So we're right.

50
00:03:58,300 --> 00:04:00,790
A is equal to one, the X is equal to one.

51
00:04:01,300 --> 00:04:03,910
And now we must write something very similar to here.

52
00:04:04,510 --> 00:04:08,920
So we write you new is equal to and p zeros.

53
00:04:10,390 --> 00:04:16,550
And the length will be the length of you because we must make it universal.

54
00:04:16,550 --> 00:04:18,310
We cannot just write down a number here.

55
00:04:19,390 --> 00:04:22,990
And then you knew with these indices.

56
00:04:23,200 --> 00:04:25,000
So basically, we can just copy this, I think.

57
00:04:26,170 --> 00:04:26,470
Yeah.

58
00:04:26,710 --> 00:04:33,100
So this will mean, except for the very first and the very last element, use this terms.

59
00:04:33,100 --> 00:04:39,190
These terms here with the shifted index, with the shifted index along the other direction to you with

60
00:04:39,190 --> 00:04:43,300
the same indices to express this discrete taste derivative.

61
00:04:43,960 --> 00:04:45,850
And then we return.

62
00:04:45,850 --> 00:04:46,600
You knew.

63
00:04:47,080 --> 00:04:51,160
And now we have to account for this prefecture, so I could add it here.

64
00:04:51,430 --> 00:04:53,110
But I can also just add it here.

65
00:04:53,110 --> 00:04:53,950
It doesn't matter.

66
00:04:54,070 --> 00:04:58,150
So I write a divided by D x square.

67
00:04:59,950 --> 00:05:00,430
All right.

68
00:05:01,040 --> 00:05:11,440
And now this gives me basically the right hand side of this equation, so it gives me this one.

69
00:05:12,610 --> 00:05:16,120
And it's an array of and coupled equations.

70
00:05:16,360 --> 00:05:19,720
So it's an yeah, it's just the array, basically this one here.

71
00:05:20,980 --> 00:05:21,370
OK.

72
00:05:21,490 --> 00:05:26,560
So now we have a equation and now we can go ahead and solve the system.

73
00:05:27,490 --> 00:05:40,120
So the right solution is equal to integrate, dot, solve, underscore IVP function, then the times

74
00:05:40,330 --> 00:05:52,330
T starts T and as is always the same as before and T start is zero and T and it takes something a bit

75
00:05:52,330 --> 00:05:52,830
larger.

76
00:05:52,840 --> 00:05:54,130
So I tested this before.

77
00:05:54,430 --> 00:05:55,660
Let's take a thousand.

78
00:05:56,440 --> 00:06:01,420
Then we use the starting conditions, so we just use zero you zero with it.

79
00:06:01,420 --> 00:06:02,740
We must define now.

80
00:06:04,090 --> 00:06:09,100
But first, let me write method is equal to our K 4.5.

81
00:06:09,790 --> 00:06:18,310
And then since we want to have all the time steps we write T evaluate is equal to NPI total in space

82
00:06:19,240 --> 00:06:26,470
to start comma, t and comma ten thousand one.

83
00:06:26,800 --> 00:06:29,050
So now we go in steps of zero point one.

84
00:06:29,050 --> 00:06:33,610
In this case, it's not the only thing left to do would be the starting conditions.

85
00:06:34,540 --> 00:06:42,100
And by defining the starting conditions, we also define the size of the array of the whole array of

86
00:06:42,100 --> 00:06:42,910
everything here.

87
00:06:44,050 --> 00:06:54,460
So to size, I want to make it here 100 somewhere and is now or 1000 is now 1000 and u zero will be

88
00:06:54,460 --> 00:06:57,340
basically in the beginning, just zeros.

89
00:06:58,900 --> 00:06:59,560
So

90
00:07:02,230 --> 00:07:02,770
like this?

91
00:07:05,050 --> 00:07:11,200
And only on the left, we will change these values.

92
00:07:11,590 --> 00:07:16,600
So basically, we could write you zero is equal to one.

93
00:07:17,860 --> 00:07:22,220
You know, we can run this and now we can plodded.

94
00:07:23,800 --> 00:07:37,000
So, for example, we can right now Pulte dots plot solution dots t comma solution thought to why?

95
00:07:39,070 --> 00:07:44,530
And now we write, for example.

96
00:07:45,230 --> 00:07:45,820
I don't know.

97
00:07:46,150 --> 00:07:46,720
Let's take.

98
00:07:46,990 --> 00:07:48,420
Let's take the middle coordinate.

99
00:07:48,880 --> 00:07:50,440
So this would be 500.

100
00:07:50,800 --> 00:07:54,730
So here we must specify now which of these elements we want.

101
00:07:54,880 --> 00:07:56,070
So do we want you want?

102
00:07:56,070 --> 00:07:56,710
Do we want you?

103
00:07:56,710 --> 00:07:58,300
And do we want something in between?

104
00:07:58,750 --> 00:08:04,450
And I take here 5000, which we can also write as size divided by two.

105
00:08:05,020 --> 00:08:12,850
And I want to take it into three divisions so that we really have an index here and oh, we get basically

106
00:08:12,850 --> 00:08:13,570
zero.

107
00:08:15,620 --> 00:08:25,030
You know, maybe this is because the time was too small and because the size or the size was too large,

108
00:08:25,030 --> 00:08:26,470
maybe to make the size a bit smaller?

109
00:08:27,580 --> 00:08:30,190
OK, yeah, this is more like I wanted it to be.

110
00:08:30,640 --> 00:08:40,720
So what we see here is on the x axis, the time and on the y axis.

111
00:08:44,490 --> 00:08:46,620
The temperature

112
00:08:49,260 --> 00:08:58,560
for whom you could say sell no more than

113
00:09:01,080 --> 00:09:02,760
the number would be.

114
00:09:04,750 --> 00:09:05,260
This one.

115
00:09:08,110 --> 00:09:13,480
So we could right index is equal to size.

116
00:09:14,350 --> 00:09:16,900
Divide it by two and then we can just write like this.

117
00:09:22,190 --> 00:09:22,560
Yeah.

118
00:09:23,630 --> 00:09:31,130
Temperature for cell number 50 and the time and you see in the beginning, the temperature is zero.

119
00:09:31,680 --> 00:09:37,700
Just because we have basically specified sarin or something, I changed later on.

120
00:09:39,170 --> 00:09:45,290
We have specified that all of the U-values would be zero, except for the very left one, which was

121
00:09:45,300 --> 00:09:45,770
one.

122
00:09:46,370 --> 00:09:54,770
And since we did not define any updates to the very left one, it will be one the whole time.

123
00:09:54,770 --> 00:09:58,670
So it will be a constant heat bath with a temperature of one.

124
00:09:59,270 --> 00:10:01,340
And it will heat the remaining sample.

125
00:10:01,340 --> 00:10:07,070
And you see, after some time, the bar or the sample, which is one dimensional, will heat up.

126
00:10:07,070 --> 00:10:12,740
And even in the middle, the cell number 50, which is exactly in the middle, will heat up after some

127
00:10:12,740 --> 00:10:14,540
time and then it will increase.

128
00:10:15,410 --> 00:10:23,810
So of course, we can now increase the time, the simulation time, and you see it will heat up to approximately

129
00:10:23,810 --> 00:10:24,950
zero point five.

130
00:10:24,980 --> 00:10:27,350
Let's see if we go to 10000.

131
00:10:29,190 --> 00:10:34,620
Yeah, exactly, it will heat up pretty briefly until it is at zero point five.

132
00:10:35,070 --> 00:10:41,220
This is because at the right point, we also do not update the function here.

133
00:10:41,700 --> 00:10:45,270
So this means there is a constant heat, both with the temperature zero.

134
00:10:46,020 --> 00:10:51,210
So when we look at the very middle after everything has relaxed after a very long time, the the temperature

135
00:10:51,300 --> 00:10:58,170
in the middle will be just between the high and the low temperature, so it will exactly be zero point

136
00:10:58,170 --> 00:10:58,530
five.

137
00:10:59,850 --> 00:11:01,530
So maybe that's decreased is a bit more.

138
00:11:02,400 --> 00:11:09,510
And let's let me show you another way to visualize this.

139
00:11:10,500 --> 00:11:16,110
So for this, I will plot this whole thing in a density plots.

140
00:11:16,560 --> 00:11:18,660
So let me show you how this works.

141
00:11:19,050 --> 00:11:21,090
T lists Color X list.

142
00:11:21,770 --> 00:11:23,520
This is something we did already.

143
00:11:23,520 --> 00:11:31,620
Previously, we used to mesh predicament to basically define all the pairs of X y coordinates that we

144
00:11:31,620 --> 00:11:32,850
will use now for the plot.

145
00:11:33,540 --> 00:11:42,840
So we righthere solution dots T and then here I just write ENPI dots per inch size.

146
00:11:42,840 --> 00:11:49,080
So this will be in the array counting from zero to size, which was one hundred in our case.

147
00:11:50,160 --> 00:11:50,670
All right.

148
00:11:50,850 --> 00:12:00,990
And then we writes Peel T Dot Contour F, and then we have T least comma x list.

149
00:12:01,680 --> 00:12:05,310
And then the solution thought Y.

150
00:12:07,440 --> 00:12:07,800
All right.

151
00:12:08,610 --> 00:12:13,470
So now we can add Colaba peeled C dot Calabar.

152
00:12:14,400 --> 00:12:19,800
And we can also, of course, at the labels, which in this case will be

153
00:12:22,350 --> 00:12:30,780
here the time T and here it will, of course, now be oops, the coordinate.

154
00:12:31,530 --> 00:12:34,170
Or you could also say the cell index.

155
00:12:35,670 --> 00:12:40,420
Okay, so you see ad time equal to zero.

156
00:12:40,440 --> 00:12:42,860
We have basically everywhere zeros.

157
00:12:42,870 --> 00:12:49,770
Everything is blue here, which corresponds to zero, and only at this point we have something that

158
00:12:49,770 --> 00:12:52,830
heats up where the temperature is held constant at one.

159
00:12:53,790 --> 00:12:59,100
And since we don't update the left and the right end of the bar, this will always be one and this will

160
00:12:59,100 --> 00:13:00,150
always be zero.

161
00:13:01,110 --> 00:13:06,870
And since this is not a nice temperature gradient, according to the heat equation, after some time

162
00:13:06,870 --> 00:13:10,350
where everything has relaxed, we get this nice homogeneous gradient.

163
00:13:11,070 --> 00:13:16,970
And this is also why, after some time, exactly in the middle, the temperature will be zero point

164
00:13:16,980 --> 00:13:22,380
five, which is exactly between one and zero at the left and and the right end.

165
00:13:23,790 --> 00:13:29,490
So now we can, of course, go ahead and use some other starting parameters.

166
00:13:30,180 --> 00:13:34,680
So I will just, yeah, basically copy this one.

167
00:13:37,190 --> 00:13:40,550
And copy this one.

168
00:13:42,630 --> 00:13:50,790
And also this one, and for the starting parameters, I will now use another starting condition where

169
00:13:50,790 --> 00:13:56,010
I say also the right end of the bar should not be zero, but should be one.

170
00:13:56,880 --> 00:14:06,030
Now if I run this, you see that the middle temperature will turn to one and the whole temperature of

171
00:14:06,030 --> 00:14:08,670
the whole bar when we plotted at the beginning.

172
00:14:09,060 --> 00:14:13,020
It will be at one and one at the left and right.

173
00:14:13,030 --> 00:14:18,540
And so here at zero and 100 and everywhere else, it will be zero as we have to find it.

174
00:14:18,990 --> 00:14:23,760
But then after some time, of course, the whole bar will have heated up.

175
00:14:24,900 --> 00:14:28,230
So maybe here it's a bit better to just go to one thousand.

176
00:14:31,870 --> 00:14:34,810
Or we could also go to maybe 2000.

177
00:14:37,390 --> 00:14:38,860
Yeah, that's much better.

178
00:14:38,890 --> 00:14:45,700
So you see here, everything remains cold, but then since we have here some heat bath and here some

179
00:14:45,700 --> 00:14:48,730
heat bath, the whole sample will be heated up.

180
00:14:49,000 --> 00:14:51,520
And this heating effect will increase over time.

181
00:14:51,520 --> 00:14:56,470
And then at some point, everything will be hot and the temperature will be equal to one.

