- #1
Quakerbrat
- 3
- 0
This may be more of a MATLAB question, and if so, I do apologize for posting this in the wrong place.
I am doing a project on the Buttke scheme, which is a numerical approximation to the Biot-Savart Law. I am almost finished, but I am having trouble writing the code.
The scheme is Crank-Nicolson but it involves a cross product.
Here is the PDE:
$\displaystyle{\frac{\partial \mathbf{X}}(s,t){\partial t} = \textbf{X}(s,t) \times \frac{\partial ^2 \mathbf{X}(s,t)}{\partial s^2}}$
Here is the iteration:
$\displaystyle{\Big(\mathbf{X}_j^{n+1} - \mathbf{X}_j^{n}\Big) = \frac{\Delta t}{4(\Delta s)^2}\Big(\mathbf{X}_j^{n+1} + \mathbf{X}_j^{n}\Big) \times \Big(\mathbf{X}_{i+1}^{n} + \mathbf{X}_{i-1}^{n}+ \mathbf{X}_{i+1}^{n+1} + \mathbf{X}_{i-1}^{n+1} \Big)}$
If anyone could give me a hint about how to begin this iteration within a loop, that would be extremely helpful. I have done iterations before, but for some reason the cross product is really throwing me off.
Here is what I have (using the fact that in R2 cross products are really determinants)
r = dt/4*ds^2;
%Calculate Iterative Sequence
for j = 2:dt
for k = 1:tmax
A(k,j) = X(k+1,j)+X(k,j)
B(k,j) = X(k+1,j-1)+X(k,j-1)+X(k+1,j+1)+X(k,j+1)
Y(k+2,j) = X(k,j)+r*det(A,B);
end
end
I really don't need someone to write anything for me, just give me some guidance as to how this could be iterated. I feel like I am missing something simple.
Thanks so much,
Quakerbrat
I am doing a project on the Buttke scheme, which is a numerical approximation to the Biot-Savart Law. I am almost finished, but I am having trouble writing the code.
The scheme is Crank-Nicolson but it involves a cross product.
Here is the PDE:
$\displaystyle{\frac{\partial \mathbf{X}}(s,t){\partial t} = \textbf{X}(s,t) \times \frac{\partial ^2 \mathbf{X}(s,t)}{\partial s^2}}$
Here is the iteration:
$\displaystyle{\Big(\mathbf{X}_j^{n+1} - \mathbf{X}_j^{n}\Big) = \frac{\Delta t}{4(\Delta s)^2}\Big(\mathbf{X}_j^{n+1} + \mathbf{X}_j^{n}\Big) \times \Big(\mathbf{X}_{i+1}^{n} + \mathbf{X}_{i-1}^{n}+ \mathbf{X}_{i+1}^{n+1} + \mathbf{X}_{i-1}^{n+1} \Big)}$
If anyone could give me a hint about how to begin this iteration within a loop, that would be extremely helpful. I have done iterations before, but for some reason the cross product is really throwing me off.
Here is what I have (using the fact that in R2 cross products are really determinants)
r = dt/4*ds^2;
%Calculate Iterative Sequence
for j = 2:dt
for k = 1:tmax
A(k,j) = X(k+1,j)+X(k,j)
B(k,j) = X(k+1,j-1)+X(k,j-1)+X(k+1,j+1)+X(k,j+1)
Y(k+2,j) = X(k,j)+r*det(A,B);
end
end
I really don't need someone to write anything for me, just give me some guidance as to how this could be iterated. I feel like I am missing something simple.
Thanks so much,
Quakerbrat