Vector convergence in cartesian coordinates
显示 更早的评论
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
0 个投票
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 个评论
Yasmin Tamimi
2014-9-25
编辑:Yasmin Tamimi
2014-9-25
Youssef Khmou
2014-9-25
hMaz? and what is the output vector that flips ?
Yasmin Tamimi
2014-9-25
Youssef Khmou
2014-9-25
there is no formula for hMaz
Yasmin Tamimi
2014-9-25
Youssef Khmou
2014-9-25
But before those lines, hMpol and hMaz are called in the first line inside the loop, so you need an initialization, and Is is not provided, anyway before the loop i put :
Is=1e-3;
hMpol(1)=rand;
hMaz(1)=rand;
Here is the result:

can you give a comment?
Yasmin Tamimi
2014-9-25
编辑:Yasmin Tamimi
2014-9-25
Youssef Khmou
2014-9-25
and the result, where it represents the flip?
Yasmin Tamimi
2014-9-26
Youssef Khmou
2014-9-26
what about temperature? it is a factor for magnetization, try to change at least some variable that is implicitly related to it, try different values for Is, if it means the flow of electrons.
Yasmin Tamimi
2014-9-26
Youssef Khmou
2014-9-26
Converging M means that the magnetization is zero? what about the volume ?
Yasmin Tamimi
2014-9-27
编辑:Yasmin Tamimi
2014-9-27
类别
在 帮助中心 和 File Exchange 中查找有关 Condensed Matter & Materials Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!