So now we know how all of this works in one dimension.
But to be honest, mathematically speaking, it wasn't really a one dimensional problem.
It was already an end dimensional problem because we had these and coupled differential equations.
So now we'll go into the two dimensions in the physical sense.
And so here the equation will change a bit.
So we will now, instead of using the Second Order special derivative, we used a La Plus operator,
which gives us now two terms.
So we have the X derivative.
Second Order and the wider relative second order acting on you.
And so if we dis criticize the both of these terms here, we get something like this.
So this time, or you will of course, still be spatial dependent, but it will be an array which is
of ordered and my end.
So it's a much larger array.
And when we just read ties to derivative, when we go along the X direction, we have to change the
first index.
And when we split ties to the derivative in the y direction, we go along the second index.
And this is basically all we have to change from a fundamental point of view.
So here I have copied from previously our function, which was here still one dimensional.
And then the command where we have called integrate dots of underscore IBP and we have to change this
now in just a bit.
So when we change it here to the two dimensional case, we have to of course change it here as well.
And we have to write that this is not anymore, just an array of length you.
But instead, it's an array of length, u times length you so we can write down like this, for example.
OK, so now we have an array when when the length of you is 100, now it's an array of 100 times 100.
So we have 10000 entries that are zero here.
And for the derivative, we can use this in the very cool.
We can use the same approach basically in a very cool way.
We go for the index, for the X coordinate and for the Y coordinate basically through the whole array,
except for the first and the last index.
And then we do the same thing here.
So this time I will use this term already in this line.
So I don't like this.
So basically, here we change only the first index.
So like this second index stays as it was, and then we multiply here a divided by x squared.
And then we add here another term, which is the second term were basically the constant index will
be the first one and only the second index will be changed.
So like this and here we must write eight times D.I.Y. Square.
So, of course, then we must define the why, which in our case, we will also choose to be one.
And now we are basically done.
So this means now we have a nice function that we can call.
For example, we could see f 2d at some point of time, it doesn't matter because our function is not
time dependent so we can write any time.
For example, one.
And then for you, we write an array and p towards Perry, and now we can write, for example, of one
to three comma.
Maybe like this four or five six seven eight nine.
And then we run this and then this will be our output.
So of course, this now looks a bit bit odd.
This was because I've chosen these numbers in an odd way.
So yeah, it must be quite dramatic.
Maybe like this?
Yeah.
OK, good.
Now we have a working example.
So this means the uttermost values are still zero because we don't touch them.
They are not updated.
The remains, the euro.
So basically, we have a heat bath along all the edges of the sample and just in the middle.
It will be updated and Tier will calculate the second derivative, according to this term.
So basically the Le Plus operator acting on the function you.
OK, so now we know this works, but you have seen the input and the output are always arrays of the
size, size, coma, size.
And this is a problem because if we now run this, it will give us an error.
Maybe the problem is here
that the zero was not an array that is quadratic.
So let's change this and here let's change, for example, to this one.
But still, it's not working.
And when we scroll down, we see what is the problem here?
The problem is then use that y zero, which is in this case, the initial condition, which in our case
is called u0, must be one dimensional.
So if you remember previously in all the examples or starting condition was just a one dimensional array,
it was basically a list.
And now it is an array that is of size, size, time, size.
So it's a 100 by 100 array.
So it is not compatible with the integrate dot solve on the school IVP command, and we must change
this.
We must flatten disarray to be just a single array of the size 10000.
So basically we just have to remove the brackets.
So this is pretty easy when we just want to address here the starting conditions.
For example, we could write you zero dot flatten.
So then the starting condition is a flattened array.
However, still we get the error, but this time it's not the error anymore that the y zero must be
one dimensional.
But here we see now that there is a problem with the EU new in our function, which appears to be one
dimensional, but we expected to indices.
So you see the use zero dot flattens or initial condition, which will then beat this value is now one
dimensional.
So it's basically of Rs 10000.
But here we we give two indices, so it doesn't know how to apply this.
So that's really a problem here, but we have to solve as well.
There exists now many ways to solve this problem, but the very, very simple one is to just first flatten
or so first reshape the array to be of size and timing size ends or 100 times 100.
And then, in the end, flatten it again.
So let me show you what I mean.
It's a pretty straightforward solution, even though it's probably not the most elegant one.
So as I said, in the end, we must flatten so that the shape fits.
So I call this here flattened, so I could also change it directly here.
But I just want to keep it for educational purposes so that you have the initial solution here.
And then we must change here to flatten it.
And now the only thing left to do, I think, is that we right here that this is of size.
X come out.
Size.
Why?
Because in general, it doesn't have to be quadratic here.
So, for example, we can then change it here as well.
And we must introduce this time the size X and size Y beforehand.
So how it works.
And now the only thing that's left to do is we must right you is you don't reshape size x color size
Y.
So we come here, we call you zero flatten, which is then just an array with a single bracket to you
and then and therefore just a single index.
And then we reshape it.
So we introduce additional brackets and so that we can address two of these indices.
Then we do the same thing as we did before where we check that worked and then to return the value we
flatten out again.
So that's a bit of a trick that we are using here.
So let's see if I have any typo or with words.
OK, looks good.
So at least there is no around this time.
So now we can go ahead and see what is the solution.
But to be honest, since I have checked this before.
Let me change a bit of the starting parameters here because in this example, only one of the corners
will be heated to one and this is way too less.
So we will not see anything if we just hit a single corner.
We must, we must hit at least a single side.
So, for example, we could write like this, then the whole left side is heated up to one.
OK, so we could also hit the left side and the bottom side, then we would ride like this.
Good.
So now let's go ahead and let's plot this.
And here is now a bit difficult because we have no two coordinates X and Y, and we have the time,
so we have to think of a nice way to plot this.
In any case, we must plot it using such a contour plot.
So let me show you what you could do.
So this time I call this text list and why lists?
And I arranged these by using once again the NPR dot mesh grid, but with NPR range size X and size
white.
And then the X label will be coordinates X and the Y label will be coordinate y.
And then here we have X list and wait lists.
And now we want to plot the solution plot y and we want to plot all of the coordinates for one particular
time index.
So I call this T index and for example, we could call here T Index just to start just to see what happens
at the very beginning.
So when I run this, it gives me an aura, because the problem is that dizzy value.
So basically the this one must be two dimensional and it is one dimensional because we have flattened
here.
So once again, we must reshape.
So basically this one.
Apply its to this one.
And now it works, and you see this is the plot of the temperature for all of the X and Y coordinates
at the time, Step T equals zero.
So now let me make this just a bit nicer by adding here a label Pulte dots for the label of title.
I mean, the title is time is equal to then people must turn this to a string solution dot t t index.
So now we have a title here T is equal to zero.
And now I want to plot several of these plots.
And to do this, you could either copy this to individual cells because a single cell can only have
a single output or you just write Peel T show.
So no, nothing happens or nothing changes, but I to see.
But now we can copy this several times and we can change it here to T and divided by two.
And then the last one would be T end.
And so we have no three plots at time equals zero.
After half the time and after the total time.
So it turns out.
Here we are at 50.
Here we are at 100, so there isn't that much of a difference, but you can see already how the left
and the bottom really heat up the sample and how the heat or the temperature extends already far deeper
into the sample.
Compared to this one, we're only very, very left in the bottom were heated up to now to explore the
physics a bit more.
Let's increase the simulation time to 10000.
So of course, now it takes much longer to simulate because this is now really already quite demanding
because we have a system of 100 times 100 cell indices, so 10000 elements, 10000 equations that are
propagated for 10000 timestamps.
So of course, this is quite a demanding calculation.
So especially if you have a bit of a weaker PC than maybe you shouldn't go to 10000 tier, but maybe
stop at, I don't know, 2000 or so.
But now it's finished for me.
And you see here we have some nice gradient and maybe here I use like this.
Now we can nicely compare.
Yeah, or even like this.
Now we have it at zero, at 50 and at 10000.
So you see here we have some nice temperature change or some, some some some light heating up of the
sample where you see the heat extends over a bit of into the interior.
And here you see, we have a very nice gradient and the heat is equally distributed where these two
edges are heat paths, where the temperature is always equal to one.
And here we have heat paths that are always where the temperature is always equal to zero.
So of course, in between, we have some nice homogenous gradients.
So before I conclude, I want to just show you what happens when you change the starting conditions.
So I've just copied these two cells from before, so nothing has changed here yet.
This is just to your starting conditions.
Calling the solve underscore IVP commands and then here to plot.
And what I will change is I will also make the right and the upper edges heat bath with a temperature
of four one.
So for this, I have to write you minus one and you also minus one.
And now we have heat buffs everywhere, except for the middle.
So I run this and once again, it takes a few seconds because it's quite a difficult calculation.
But once it's finished, we will see what happens.
So you see here we have this nice gradient from hot to cold.
What happens if we heat here as well?
So probably everything will then heat up and get hot.
But let's see what happens.
Shouldn't take too long anymore.
And now we're finally finished, and he said the results at T equals zero.
We have only heated up areas at the edges and in the middle it's zero, as we have specified.
And then you see, after 50 seconds, the heat really penetrates into the middle, where it starts to
heat up more and more to sample.
And yeah, here you see, basically, everything is very, very close to one.
So it's a bit of an odd way to plot this.
This means one plus the value here.
So you see, it's pretty pretty close to one and you just have some very small distribution here of
heat.
But basically, you could say, OK, after such a long time, everything is heated up and equal to one
because you heat up from everywhere and you cool from nowhere.
So of course, the whole sample will heat up to the temperature of one.
All right.
So we have solved here the heat equation, which was a bit of a different class of problem because we
did not simulate a single object with just a single or two or three coordinates, but we simulated really
an array of multiple cells with which each contain individual values in this case for the temperature.
And we have seen that this leads us to and coupled differential equations or in the two-dimensional
case, even end times and coupled differential equations.
We have seen that we are easily capable of solving a system consisting of 10000 cells, and so we have
to propagate 10000 differential equations at the same time.
And this was no problem for the for the command integrator to solve, underscore IVP that we have used
previously.
But once again, the method was quite similar as before.
The only thing that we had to take care of was that the function and the input parameters, the starting
parameters are all flattened, so it must just be a one dimensional list or an array of numbers.
So we have to get rid of the brackets first and then we have to be clever and reorganize our data later
on for the plotting, for example, to make it such a two dimensional system.