www.pudn.com > ja20131006.rar > hystersis_ja.m, change:2013-05-07,size:1511b


% HYBRID JA FERROMAGNETIC HYSTERESIS SIMULATOR 
%Curve,M=Ms*b*H/(1+b*norm(H)). 
%Ms: Saturation Magnetization. 
clear 
f=40; 
dt=1/(f*1000); 
NTo=2; 
Hmax=10000; 
a=1000; 
alpha=0.001; 
c=0.1; 
b=1000; 
Ms=1.7E+6; 
k=2000; 
len=round(NTo/(f*dt)); 
    T=linspace(0,NTo/f,len); 
    hs=(sin(2*pi*f*T))'; 
disp('******************'); 
disp('Setting up Simulation'); 
disp('******************'); 
varargin 
s=size(hs); 
len=s(1); 
col=s(2); 
disp('************'); 
disp('Simulation set up & runing......'); 
disp('************'); 
disp(''); 
 
%Main JA Algorithm 
mirr=0; 
m=0; 
OUT1=zeros(len,col);OUT2=zeros(len,col); 
OUT3=zeros(len,col); 
lasthe=0; 
lastm=0; 
for i=2:len 
    dm=1;n=0; 
      h=hs(i);      
      if( i < len)   
         dhs=hs(i+1)-hs(i); 
             if(dhs>0) 
                 delta=1; 
             else 
                 delta=-1; 
             end 
      end     
    while(n<100)&&(norm(dm)>1E-10) 
        H=h*Hmax; 
        M=m*Ms; 
        He=H+alpha*M;       
        he=He/Hmax; 
        dhe=he-lasthe;     
        man=(coth((He)/a)-a/(He)); 
        dmirr=(Hmax/k)*(man-mirr)*delta*dhe; 
         mirr=mirr+dmirr;     
         m=c*man+(1-c)*mirr; 
         dm=lastm-m; 
          lasthe=he; 
          lastm=m; 
          n=n+1; 
    end 
    OUT1(i,:)=M; OUT2(i,:)=man*Ms; OUT3(i,:)=he*Hmax; 
end 
figure 
plot(hs*Hmax,OUT1,'k','LineWidth',2.5) 
hold; 
xlabel('Hx') 
ylabel('Mx') 
% figure 
% plot(hs*Hmax,OUT2,'k','LineWidth',2.5) 
% hold; 
% xlabel('Hx') 
% ylabel('Man')