So the good results of the last lecture was that we have now at the back to potential and we know that
it's correct and we have the vector potential in terms of an array, we have an array capital eight,
which includes points in space that you show that you see here.
And then we have the corresponding value of the vector potential.
And we've also seen that only to Z component of the vector potential is different from zero.
So it only has this a z value that we plot here and what we will consider in the following.
So according to the Maxwell equation, we can calculate the magnetic fields based on the kernel of the
vector potential, and we have our vector potential readily available.
And if you remember in the previous section, we have also learned about the kernel.
So this was the section about the derivatives and we have introduced another operator and we have even
programmed to call for a continuous function.
So now here, it's a tiny bit different because we have an array and so we must reprogram this kernel,
but it's not really that much different.
And if you remember, I told you back in this lecture that we will have an exercise later on.
And now is the time.
Now you will calculate really a kernel which has a physical meaning.
And so you know how to calculate the kernel.
And the only thing that we can use now that we have to consider is that we have considered here basically
an infinitely long wire, which therefore has the same vector potential in all the layers.
This is a bit tricky here because in our example, when the wire is not infinitely long, it's not actually
constant with Z, but it's only very tiny changes here.
So we will consider that these are zero here because we have only considered a single layer, so we
wouldn't be able to calculate these derivatives with our current version of the code and principle.
It's possible, but then you would have to calculate a for different layers.
And then in the end, you will see that it's just very, very close to zero.
So this means using this approximation, these two terms here will be zero.
And so this is what we have to calculate.
And first, we have to create an empty list like we did before for the vector potential for the magnetic
field.
And this will be B is equal to and now I will, of course, save a bit of typing and scroll up to this
point where we have to vector potential and it will be exactly the same thing here.
Oops.
Like this?
OK, so now we have the empty magnetic field and now we could, of course, loop again over all the
positions.
But actually here it's pretty, pretty easy to just work with the arrays.
So let us get started and let us first program the X component, which would be something like this
X component, all the values in X, all the values and Y and of course, only two single value in Z.
And now if you remember how we calculate a derivative, there was always a good compromise, I would
say, when we use the central difference as methods, because if you remember, this had a better order
of the error than the forward or backward differences.
And also it was quite easy to program because it only contains a single term.
In this case, we go one step in the right direction, forward and backward, and we subtract two terms
and divide by the difference in space.
So this means we run into a bit of a problem here at the edge of our list, which is why I will just
disregard the edge and I will just start from the second value, which is the index one.
And I go to the second last because this one is excluded.
It will be the second last and the same for the wider region.
So we could, of course, also program an equation for the last and the first values.
But then we would have to use them forward and backwards differences methods.
But I will just disregard these values and we don't care here because as you will see, the magnetic
fields will be very close to zero at these values anyway.
So now comes the central differences methods.
So we need to use here A and the Z components, and this will be a two and then we will use here all
the so basically the same indices along the X direction and for the Y direction we go one step forward.
So basically, we take this one, but we go one step forward, which means like this, we start from
the third value, which is in X two.
And yes, and then we go to the very last one, which is programmed like this and also take the only
value on the Z direction.
Now we must subtract from here the same thing where we go into the negative direction, which will be
programmed like this.
We go start from the first and go to the third last year because minus two means here, it's excluded.
It's not included in the list anymore.
And then we just have to divide by the total difference, which will be on the difference and risk base,
which will be two times.
OK, so this is already this term and the other terms, of course, very similar.
So I will just copy and then fixed the indices.
So here it will be now the X sorry, not the X, but the Y coordinates so index one.
And we have to consider here again the Z component, but the derivative along the X direction and a
minus sign.
So first of all, add here the minus sign and then I basically just have to swap these indices here
and also here.
OK, that's already it.
And now we must use the Z component.
This one is a bit more to write because they are now two terms.
So the Z component considers the X derivative of a Y, so we can basically take this one, but we must
use a Y.
So we change to two, two to one here in the first index, and then we must subtract the Y derivative
of X so we can take this one and change the index to zero for eight X.
And that's already it.
Now we have calculated all the B values except for the outermost values of our.
But as I told you, we simply do not care about this.
We could, as I told you, just use central differences, but we do not care here.
Now I want to pull up the individual coordinates and so we can just copy this code because I want to
use again a control plot.
So I use here now instead be and this will be the magnetic fields and magnetic fields.
And the first one will be the X, which has the index zero, of course, and we can just plot it.
And though I want to plot also the others.
So now you could make subplots right next to each other, which which would look a bit nicer.
But I want to do it really quickly and save a bit of time.
So I just try to appeal to shows so know I can use several plot commands in this cell and I just copy
this twice.
Use here do Y components or index one.
B Y and index to be easy.
And so now you see we have here magnetic field in the X direction, which is basically very small or
close to zero everywhere, except close to the middle.
And same for B y.
But you see there is some sign change going on here and there is a rotation of this funny looking thing.
And you do see component is just zero.
So if you have already worked with such quantum plots, then maybe you can already imagine what the
solution looks like.
But if not, I want to show you here another way of plotting, and this will be, first of all, the
absolute value.
And for this, I will just copy once again such a code here and here.
I will use now the absolute value, and for this we must use, of course, and p towards square root
of
B X squared plus.
And then I copied this b y squared plus p z squared.
And you see, this is now the absolute value of the magnetic fields.
And even though there is a tiny artifact here from the plotting or for the from the from the letters
from the coordinate grid that we are using, I can tell you that actually when you saw that analytically,
it is radial, symmetric and despite these points here, also in our numeric solution, it is radial,
symmetric and it has quite a large value in the middle.
And then it declines when you go away from the wire and then you can look at the individual components
here.
You see, the X component is positive and here at the bottom and it's negative here and the Y component
is positive here and negative here.
So you can already imagine that we really have such a scenario here where the current rotates, because
here also in the negative y direction, the magnetic field is along a positive X and so on is exactly
the same situation as in the image, and we will now go ahead and create such an arrow plots that you
have just seen in this figure.
And we will also compare our result to the analytical solution.
So for the analytical solution, I have basically taken this vector potential that I've shown you earlier
that I have derived in the course and then I have just analytically calculated the curl.
So Knobloch cross the vector potential.
So this is what the analytical solution looks like.
It is, in a sense, similar to the vector potential.
But instead of the logarithm, you have now won over the square root of x squared plus y square and
you have not the vector potential along the Z direction, but along this particular, you call it the
toroidal orientation, which means that the magnetic field circulates around the z axis.
So this is really what you can also see above.
So the X component is proportional to minus Y and the Y component is proportional to positive X.
So you see Y component proportional to positive x x component proportionate to negative y.
And if I program this and compare it with our solution here, I have chosen to show B y and cut along
the x axis.
So this will be B y cut along this axis.
Then we will get the following profile this one.
And I think we have once again a nice agreement of our calculated the numerical solution and blue points
and the analytical result and ret.
Sorry.
The only problem that we see here is that the outermost point looks a bit odd.
This is for the reason that I have explained to you that I did not consider these for either of a tiff.
So they are just chosen to be zero here and we have not actually calculated them.
We could fix this by forward or backward differences.
Then it would probably go here closer to the red line.
And there's another problem pretty close to the center, which is basically due to the fact that here
we would need more points to get a better result.
So if you want, you can try to get a better results by improving the parameters and improving the convergence
of the integral.
But I think it's not really necessary because as a result looks really good.
So now the last thing I want to show you is that we want to recreate such a figure in a sense, so we
will generate such an arrow plot for the magnetic fields around our charged wire.