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
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
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
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
Yasmin Tamimi 2014 年 9 月 25 日
編集済み: Yasmin Tamimi 2014 年 9 月 25 日
P_gamma = 1.76e11;
P_hbar = 1.054e-34;
a1 = 100e-9 ;
b1 = 40e-9 ;
Area = a1*b1*pi ;
t1 = 2.0e-9 ;
Ms = 8e5 ;
Ku = 300.0 ;
alpha = 0.02 ;
Vol = Area*t1 ;
C1 = 1/(1+(alpha^2)); P_U0 = 4.0e-7 * pi; C2 =P_U0*Vol*Ms ;
G0 = P_gamma*P_U0;
P_Q = 1.6021918e-19;
Nx = 0.0182; Ny = 0.0515; Nz = 0.931;
EAi = 1; EAj = 0; EAk = 0;
P = 0.35;
hx = -50*79.5775; %hx = 50*79.5775; hy = 0; hz = 0.5e3;
theta(1) = 89 * pi/180; % intialize theta
phi(1) = 0 * pi/180; % initialize phi
Youssef  Khmou
Youssef Khmou 2014 年 9 月 25 日
hMaz? and what is the output vector that flips ?
Yasmin Tamimi
Yasmin Tamimi 2014 年 9 月 25 日
vector M = [Mi Mj Mk] flips. hMaz (h azimuth) is the proporton of h vector as a function of phi
Youssef  Khmou
Youssef Khmou 2014 年 9 月 25 日
there is no formula for hMaz
Yasmin Tamimi
Yasmin Tamimi 2014 年 9 月 25 日
the last two equations in the code above are hMpol and hMaz. I'm re writting them here:
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))) ;
Youssef  Khmou
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
Yasmin Tamimi 2014 年 9 月 25 日
編集済み: Yasmin Tamimi 2014 年 9 月 25 日
I already initialized all vectors before the loop but I didn't show it here just to shorten the code.
Youssef  Khmou
Youssef Khmou 2014 年 9 月 25 日
and the result, where it represents the flip?
Yasmin Tamimi
Yasmin Tamimi 2014 年 9 月 26 日
Vector M flips so my code is correct but my problem is that it doesn't converge to -x-axis where the values of Mi, Mj and Mk equals zero or something near to it. After it flips to the other side it keeps rotating around -x-axis. So I believe that I have to add something that will help in the converging process?
Youssef  Khmou
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
Yasmin Tamimi 2014 年 9 月 26 日
No, I'm not considering the temp. in my calculations. I tried changing Is as it directly affects the flipping but it doesn't help in converging. I also tried changing the values of hx, hy and hz and alpha. Those variables affect the convergence. I tried using different combinations but still didn't get to one that forces my vector to converge!
Youssef  Khmou
Youssef Khmou 2014 年 9 月 26 日
Converging M means that the magnetization is zero? what about the volume ?
Yasmin Tamimi
Yasmin Tamimi 2014 年 9 月 27 日
編集済み: Yasmin Tamimi 2014 年 9 月 27 日
Vector M is position vector initially its M=[Mi Mj Mk]= [1 0 0] and the end result must be [-1 0 0]. The volume stays constant bcz it is the area multiplied by the thickness of the material.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCondensed Matter & Materials Physics についてさらに検索

質問済み:

2014 年 9 月 25 日

編集済み:

2014 年 9 月 27 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by