Vector convergence in cartesian coordinates
조회 수: 3 (최근 30일)
이전 댓글 표시
Hey everyone,
How can I help my vector in cartesian coordinates converge to its resting point. The vector flips from +x-axis to the negative but instead of converging to it it keeps rotating around it!
Thanks in advance.
댓글 수: 2
Geoff Hayes
2014년 9월 25일
Yasmine - you might want to provide some context concerning what problem you are trying to solve. As well, posting some of the code may allow others to get an idea of what is happening and be in a better position to provide/offer some guidance.
Matt J
2014년 9월 26일
Yasmine Tamimi Commented:
Ok,, so I have a magnetization vector that according to some torques flips from +x-axis to -x-axis.. the problem I'm facing is that it doesn't converge to -x-axis it keeps rotating.. So, what shall I add to help it converge?
Steps = 20000; % Arrays size
time = 100e-9; % Total time
dt = (time/(Steps)); % Time step
Tswitch = 0:dt:time; % in seconds
for t = 1:Steps %Euler's Method
dtheta(t) = dt*((C1*G0)*(hMaz(t) + alpha*hMpol(t))) ; %3.1239
dphi(t) = dt*(((C1*G0)/sin(theta(t)))*(alpha*hMaz(t)- hMpol(t))); %1.57
theta(t+1) = theta(t) + dtheta(t) ; %3.1239
phi(t+1) = phi(t) + dphi(t); %1.57
Mi(t+1) = sin(theta(t+1))*cos(phi(t+1));
Mj(t+1) = sin(theta(t+1))*sin(phi(t+1));
Mk(t+1) = cos(theta(t+1));
u(t+1) = (EAi*Mi(t+1))+(EAj*Mj(t+1))+(EAk*Mk(t+1)); % dot prod. of M and EA.
Anis(t+1) = acos(u(t+1));
epoli(t+1) = cos(theta(t+1))*cos(phi(t+1));
epolj(t+1) = cos(theta(t+1))*sin(phi(t+1));
epolk(t+1) = -sin(theta(t+1));
eazi(t+1) = -sin(phi(t+1));
eazj(t+1) = cos(phi(t+1));
eazk(t+1) = 0 ;
ddu_acos(t+1) = -1/sqrt(1-(u(t+1)^2));
du_dMpol(t+1) = (EAi*cos(theta(t+1))*cos(phi(t+1))+EAj*cos(theta(t+1))*sin(phi(t+1))- EAk*sin(theta(t+1)));
du_dMaz(t+1) = sin(theta(t+1))*(EAj*cos(phi(t+1)) - EAi*sin(phi(t+1)));
dd_Anis(t+1) = Ku*Vol*sin(2*Anis(t+1));
g(t+1) = (-4 + ((1+P)^3)*(3+u(t+1))/(4*(P^1.5))) ;
G(t+1) = 1/g(t+1) ;
Ffi(t+1) = EAj*cos(theta(t+1)) - EAk*sin(theta(t+1))*sin(phi(t+1)) ;
Ffj(t+1) = -EAi*cos(theta(t+1)) + EAk*sin(theta(t+1))*cos(phi(t+1)) ;
Ffk(t+1) = EAi*sin(theta(t+1))*sin(phi(t+1))- EAj*sin(theta(t+1))*cos(phi(t+1)) ;
hMpol(t+1) = - (dd_Anis(t+1) * ddu_acos(t+1) * du_dMpol(t+1))/C2 - ((Is*P_hbar/(2*P_Q*g(t+1)*C2))*((epoli(t+1)*Ffi(t+1))+(epolj(t+1)*Ffj(t+1))+(epolk(t+1)*Ffk(t+1))))- Ms*sin(2*theta(t+1))*((Nx-Nz)+ (Ny-Nx)*(sin(phi(t+1))^2))+((hx*cos(theta(t+1))*cos(phi(t+1))+hy*cos(theta(t+1))*sin(phi(t+1))-hz*sin(theta(t+1))));
hMaz(t+1) = - (dd_Anis(t+1) * ddu_acos(t+1) * du_dMaz(t+1))/(C2*sin(theta(t+1)))- ((Is*P_hbar/(2*P_Q*g(t+1)*C2))*((eazi(t+1)*Ffi(t+1))+(eazj(t+1)*Ffj(t+1))))- Ms*(Ny-Nx)*sin(theta(t+1))*sin(2*phi(t+1))+(hy*cos(phi(t+1)) - hx*sin(phi(t+1))) ;
end
답변 (1개)
Youssef Khmou
2014년 9월 25일
There are 24 undefined variables C1;G0;hMaz;hMpol;Alpha;theta;phi;EAj;EAi;EAk;Ku;Vol;P;C2;Is;P_hbar;P_Q;Ms;Nx;Nz;Ny;hx;hy;hz;
I tired using random values but the vector hMaz gives NaN values, because we need precise values of these variables, because i think this is inside quantum box right?
댓글 수: 13
Youssef Khmou
2014년 9월 26일
Converging M means that the magnetization is zero? what about the volume ?
참고 항목
카테고리
Help Center 및 File Exchange에서 Particle & Nuclear Physics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!