1
00:00:00,690 --> 00:00:05,370
Now we are going to solve a 2D heat equation.

2
00:00:05,670 --> 00:00:11,910
The difference between 1D and 2D heat equation is simply in 2D.

3
00:00:11,940 --> 00:00:18,270
You have this additional parameter, which is the diffusion in the direction of Y.

4
00:00:18,780 --> 00:00:26,460
So the change of u with or the temperature with T will equal.

5
00:00:27,360 --> 00:00:38,460
If Alpha Square or let's say the whole thing is is just a factor that's going to be multiplied by the

6
00:00:38,460 --> 00:00:45,180
diffusion or the second derivative of U with respect to X and the second derivative of U with respect

7
00:00:45,180 --> 00:00:46,140
to Y.

8
00:00:46,560 --> 00:00:51,540
So again, this is the temporal form or the temporal.

9
00:00:52,500 --> 00:00:59,940
Well, you can say like component, which is a time based component or the change of U with respect

10
00:00:59,940 --> 00:01:02,640
to T and all of this.

11
00:01:02,640 --> 00:01:11,610
This one and this one is the spatial derivative or component, which is the derivative of U with respect

12
00:01:11,610 --> 00:01:17,250
to x and the second derivative of U with respect to x and the second derivative of U with respect to

13
00:01:17,250 --> 00:01:17,550
Y.

14
00:01:17,850 --> 00:01:25,440
Of course, U is the most the heat equation is usually the temperature, but it's it's basically describe

15
00:01:25,440 --> 00:01:30,340
a system that will have a diffusive property.

16
00:01:31,200 --> 00:01:32,270
So.

17
00:01:32,280 --> 00:01:33,900
So that's it.

18
00:01:33,900 --> 00:01:37,080
And this just the coefficient.

19
00:01:37,110 --> 00:01:39,750
Diffusion coefficient component.

20
00:01:39,900 --> 00:01:43,290
It can be different for every one of them.

21
00:01:43,290 --> 00:01:50,340
So we might have in the past I think it was K or A or V, I'm not sure.

22
00:01:50,340 --> 00:01:56,370
But basically this component can be different for the X and different for Y.

23
00:01:56,400 --> 00:02:05,020
Some materials will have a different coefficient regarding the diffusivity of or the heat transfer in

24
00:02:05,040 --> 00:02:07,470
the x direction is different than the y direction.

25
00:02:07,470 --> 00:02:08,370
So.

26
00:02:08,980 --> 00:02:12,280
These things will will be different.

27
00:02:12,490 --> 00:02:17,950
And but in this case, it will be taken very simple.

28
00:02:17,950 --> 00:02:20,440
Simply in this example.

29
00:02:20,440 --> 00:02:21,760
Actually, I'm going to I'm going to set it.

30
00:02:21,760 --> 00:02:28,180
One is just I don't really want to study its effect or work about its effect.

31
00:02:28,220 --> 00:02:37,690
The purpose of all of this is to simply explain how to solve heat equation, a 2D heat equation using

32
00:02:37,750 --> 00:02:41,110
um, this basically the um.

33
00:02:42,820 --> 00:02:45,250
A numeral neural neural networks.

34
00:02:45,250 --> 00:02:46,930
So we we do pens.

35
00:02:47,230 --> 00:02:49,180
So let's start.

36
00:02:49,180 --> 00:02:52,090
Let's start defining the needed libraries.

37
00:02:52,090 --> 00:02:56,650
And of course, um, the, the, the network.

38
00:02:56,680 --> 00:02:58,480
This is what we're going to do first.

39
00:02:58,480 --> 00:03:01,240
So the first thing is what we call it.

40
00:03:01,240 --> 00:03:03,460
Like we can say heat.

41
00:03:04,380 --> 00:03:05,640
Uh, to the.

42
00:03:06,630 --> 00:03:07,650
Into the.

43
00:03:10,180 --> 00:03:12,040
Bins mean main.

44
00:03:14,250 --> 00:03:18,480
This function and then we start importing the needed library.

45
00:03:18,510 --> 00:03:20,700
So import torch.

46
00:03:20,730 --> 00:03:21,840
Import.

47
00:03:23,250 --> 00:03:27,270
Import torch dot n.

48
00:03:27,270 --> 00:03:27,690
N.

49
00:03:27,690 --> 00:03:28,230
As n.

50
00:03:28,230 --> 00:03:28,770
N.

51
00:03:29,310 --> 00:03:29,970
Import.

52
00:03:29,970 --> 00:03:36,690
This time it will be very simple network and very simple optimization algorithms.

53
00:03:36,960 --> 00:03:42,240
We're going to just use Adam since just the out of the box very common.

54
00:03:42,900 --> 00:03:51,480
Adam And because the accuracy is not really what we are looking for, we're looking for mainly the concept

55
00:03:51,480 --> 00:03:54,930
and how can we do it like in a step by step manner.

56
00:03:54,930 --> 00:03:59,970
This is, this is what we want to this is why we took this course.

57
00:04:00,540 --> 00:04:09,900
So torch to Optim as Optim this one we will just we will take the Adam optimizer from it and see born

58
00:04:10,320 --> 00:04:22,410
as SNS for the we use it before for the heat plot plot lap matplotlib.pyplot.

59
00:04:22,980 --> 00:04:25,350
By plot as plt.

60
00:04:25,500 --> 00:04:27,570
The usual guy.

61
00:04:28,020 --> 00:04:38,220
The first thing we will do, we can call bins pens in n dot module, same as everything.

62
00:04:38,340 --> 00:04:45,870
We always inherit the a neural network module and init.

63
00:04:46,980 --> 00:04:47,640
Uh, sorry.

64
00:04:47,640 --> 00:04:50,760
This one and then self.

65
00:04:51,430 --> 00:04:53,620
And again, super.

66
00:04:54,930 --> 00:04:55,920
Pins.

67
00:04:57,050 --> 00:04:57,830
Bins.

68
00:04:58,950 --> 00:05:00,540
Self.

69
00:05:01,970 --> 00:05:02,600
Dot.

70
00:05:03,650 --> 00:05:04,610
In it.

71
00:05:06,430 --> 00:05:09,570
And now we will do the nut.

72
00:05:09,570 --> 00:05:18,340
Not always like the usual thing, which is actually building the network in dot sequential is capital

73
00:05:18,340 --> 00:05:22,660
letter seek when shell.

74
00:05:23,410 --> 00:05:27,450
And we start in n dot.

75
00:05:28,630 --> 00:05:29,290
Engineer.

76
00:05:30,900 --> 00:05:31,500
Lean.

77
00:05:32,640 --> 00:05:33,150
It.

78
00:05:34,360 --> 00:05:37,810
We will have a three and 64.

79
00:05:38,350 --> 00:05:41,050
This is we need to let a little bit relaxed.

80
00:05:42,780 --> 00:05:46,230
Linear 64 means now we have 2D.

81
00:05:46,260 --> 00:05:51,510
That means we have X, we have Y, and we have time.

82
00:05:51,810 --> 00:05:55,980
This is we didn't have it before, so this is why we have this one.

83
00:05:56,220 --> 00:06:00,320
And of course, of course we can do a.

84
00:06:01,380 --> 00:06:09,720
Complicated network, but will take it very simple and very just, very simple neural network, which

85
00:06:09,720 --> 00:06:14,550
is just three inputs expanding and then just.

86
00:06:16,200 --> 00:06:18,270
Collapsing onto one, which is you.

87
00:06:18,420 --> 00:06:27,330
So in a linear 364, I think like I like I like to write to, to, to write it like this.

88
00:06:28,270 --> 00:06:40,570
So here linear 64 and then an N dot the activation function ten inch and we close and then an n dot

89
00:06:41,410 --> 00:06:44,170
linear linear.

90
00:06:44,500 --> 00:06:51,580
And this time the activation function will be 64 expanding into another 64.

91
00:06:52,510 --> 00:06:54,980
I turn right here and this in.

92
00:06:56,370 --> 00:06:58,320
Dot ten.

93
00:06:58,650 --> 00:06:59,800
Etch Ten.

94
00:06:59,820 --> 00:07:00,660
Etch.

95
00:07:01,370 --> 00:07:07,670
And that I then itch and this time it will close.

96
00:07:08,440 --> 00:07:09,010
Linear.

97
00:07:11,580 --> 00:07:14,820
We'll get 64 and collapse onto one.

98
00:07:15,810 --> 00:07:19,710
Three will have to go to 64.

99
00:07:20,130 --> 00:07:26,570
The 64 has to go another 64 and then it will collapse into a.

100
00:07:27,680 --> 00:07:28,500
Two into one.

101
00:07:28,500 --> 00:07:31,350
So the neural network will be the first layer three.

102
00:07:31,400 --> 00:07:32,880
Second layer is 64.

103
00:07:33,000 --> 00:07:35,580
Third layer is going to be another 64.

104
00:07:35,580 --> 00:07:38,580
And then the last layer will be one.

105
00:07:39,370 --> 00:07:45,850
Which is what we're trying to predict, which is the the you forward.

106
00:07:47,410 --> 00:07:48,610
Self.

107
00:07:49,370 --> 00:07:50,390
And X.

108
00:07:51,520 --> 00:07:52,660
Return.

109
00:07:53,930 --> 00:07:55,760
Self dot net.

110
00:07:56,740 --> 00:07:58,060
And that's it.

111
00:07:58,490 --> 00:07:59,350
Then shift, enter.

112
00:07:59,890 --> 00:08:01,960
So that's it.

113
00:08:01,960 --> 00:08:03,490
This is how we.

114
00:08:05,070 --> 00:08:07,140
A define our network.

115
00:08:07,170 --> 00:08:10,200
Of course you can make it a little bit more.

116
00:08:11,520 --> 00:08:18,760
Complicated, but usually because all of these problems so far is very simple problems, I would say.

117
00:08:18,780 --> 00:08:27,480
So, of course, if you if you have a little bit more complex network, for example, you're solving

118
00:08:27,480 --> 00:08:28,620
Navier-Stokes equations.

119
00:08:28,620 --> 00:08:31,740
You might need to account more more than you might.

120
00:08:31,770 --> 00:08:34,140
You need to build a bigger network.

121
00:08:34,150 --> 00:08:35,730
It seems like it.

122
00:08:36,610 --> 00:08:37,110
So.

123
00:08:38,750 --> 00:08:41,840
However, we have only the heat equation and it is 2D.

124
00:08:41,840 --> 00:08:45,350
So we this is the main changes.

125
00:08:45,350 --> 00:08:48,430
We have three here input and this one as output.

126
00:08:48,440 --> 00:08:51,110
So let's next class we will.

127
00:08:52,620 --> 00:08:55,740
Define some of the losses.

128
00:08:55,740 --> 00:09:04,080
And just same thing, initial condition, boundary condition, everything like building the the whole

129
00:09:04,080 --> 00:09:04,680
system.
