After defining the problem.
Now we need to solve it in order to solve it.
Well, we simply or not simply, we have to use the discretized form of the equation.
And to calculate it a time, one time step at a time.
Our solution will be what we call explicit, in which we will update the solution or we will find the
solution.
And for the next time, step.
So we start from the initial condition and then go one time step at the time, one time step, and then
see what is the solution.
And then another time step and then another time step and another and another.
This is what we call an explicit, explicit solution.
And this is how we like discretized our equation.
So let's see here what is happening.
So we have do you over and of course equals K do the second derivative of U over.
And now what we need to do we need to write this equation in terms of time plus DT.
So every time we predict we will predict the value of the next time step.
This is how it works.
We have to predict the next time.
Step what?
What's going to happen?
This goes, um, because this is a simulation.
We need to always predict what what is going to happen.
So here we start.
Uh, well, first, calculating the time.
Just give it some here just to move a little bit.
Freely.
And here we start for t in.
Range.
Starting from one.
To the length.
Of Victor.
The victor.
This one?
Minus one.
Y minus one because the the T actually in here, it will start from a in python.
We start addressing the first element to zero.
So the last element we will have one element lost.
So this is why we always put it minus one.
So it's a kind of python thing as it's, as it's known in range X also from one to the length of x.
It's the same.
And.
A x vector, also minus one.
And here we need to calculate.
So what do we need to calculate?
We need to calculate you.
Act.
Specific X at a specific time.
But what is the time going to be?
It's the time plus one.
Y plus one, because in this simulation, in the explicit simulation, we're actually predicting what's
going to happen in the future.
So t plus one, this is what's going to happen in the future at this location.
We every time step we will calculate what's happening in the future for every a the next time, step
for every location.
So this is basically what we are going to do.
And this will equals what?
This will equals.
Let's see the equation we have.
Well, we have.
This.
If we move this, you or we.
We move this.
We move it here.
So K has to be multiplied by and divided by d x squared.
So let's do that.
So it's I think it's just a simple math of how we have to arrange these equation.
So we will, we will do it.
And so the first one is K.
Multiplied.
It will multiply.
That is going to be divided by the square.
And.
This.
Values because we again go to the discretized form.
So we have k multiplied t divided by the square or dt divided by the x square multiplied k, and then
all of this, these values has to be multiplied by all of this part.
And later we have to plus u t dt so we may go and do it.
So that.
The term will be you.
A little bit like this.
U of T.
X plus one.
Minus two multiplied.
Of course we have to go.
And maybe it's better put it.
Somewhere like this.
Yeah.
This way.
So.
You t x plus x, it means x plus one.
The next point.
This is our current point is x and next point will be x plus one.
Multiply two which is this one two multiplied you at this time, which is going to be you.
Time and x.
This time the current location plus.
Plus.
This.
Which is you?
Current time, Of course.
And.
Oh, sorry.
Sorry.
And.
X minus.
One the last point.
So all of this.
Is written in here.
So this all of this is in this part of the equation, this one.
K This is going to be and then over the square is this one.
So this is constant multiplied by this value that will depend on the all the time and the X.
Now what is left is I would like to put a big.
Parent.
Oh, sorry.
A big parentheses between here, although it might be not necessary.
And this, which is We have all of this.
We.
We need to sum the value of you.
And time and X at our specific.
Time this one and specific X.
So this is this equation.
We'll just make it a little bit this way.
We will calculate for every all the time.
Starting from well, t equals one from the initial condition.
And then we keep updating the initial condition.
We will calculate for the whole space.
And we will update for the time plus one for the next time step.
And we keep doing this until we reach to the final time step.
Which is this one?
This, you move it here and this is going to be the you.
And then we still have this bulky thing.
This one will be here.
The x squared is here.
D is here because we moved it here.
The x is this one and then k.
This constant.
This values will be summed with this value.
So what is left?
Nothing.
We just run it.
It.
You.
Minus two x.
A 100.
It's.
Uh, sorry.
T vector.
Um.
I made a mistake.
This is x vector.
I put it X here, but I forgot.
Okay.
Now it should work.
So now it's computing, and we can see how after this finish, we can see how you become.
So it's now computing, Now it's finished and we can see you.
We print it out and we can see the values got updated.
Of course, these values, you can see this is the 200 is the far right, and then it will start diffusing
little by little here and then here, basically all the rods.
And then this is the values, of course, starting from zero and step by step, updating these values.
Okay, so this is how we solved our equation.
Next time we will just check the solution.