Open Source Codes

An Efficient and Accurate Adaptive Time-Stepping Method for the Landau-Lifshitz Equation

작성자
cfdkim
작성일
2024-12-26 11:29
조회
137
Nx=100; Lx=0; Rx=1; h=(Rx-Lx)/Nx; x=linspace(Lx+0.5*h,Rx-0.5*h,Nx);
XX=(x.^2).*((1-x).^2); dXX=2*x-6*x.^2+4*x.^3; ddXX=2-12*x+12*x.^2;
ue=@(t) sin(t).*cos(XX);
ve=@(t) sin(t).*sin(XX);
we=@(t) cos(t).*ones(1,Nx);
T=1.e-1; maxdt=0.5*h^2; t=0; u=ue(0); v=ve(0); w=we(0); tol=1.e-7;
while tT)
dt=T-t;
end
t=t+dt;
nu=u-dt*su; nv=v-dt*sv; nw=w-dt*sw;
u=nu; v=nv; w=nw;
A=[u' v' w'];
for i=1:Nx
B(i)=norm(A(i,:));
end
u=u./B; v=v./B; w=w./B;
end