clear all
clc
fprintf('\n\nDemonstration of Jiles-Atherton model - three hysteresis loops.');
Ms=1.6e6;
a=1100;
alpha=1.6e-3;
k=400;
c=0.2; % Parameters of Jiles-Atherton model
fprintf('Calculation for parameters: \na=%f(A/m), k=%f(A/m), c=%f, Ms=%e(A/m), alpha=%e \n\n',a,k,c,Ms,alpha);
H=[0:0.01:1 1:-0.01:-1 -1:0.01:1]'; % magnetizing field H - column vector
H=[H.*1000 H.*3000 H.*6000];
fprintf('Calculations started. Expected time of calculations: below 2 minutes.\n');
Bmodel = func_ja(a,k,c,Ms,alpha,H);
fprintf('Calculations finished.\n\n');
plot(H, Bmodel,'-o');
xlabel('H (A/m)');ylabel('B (T)');grid;
function BsimT = func_ja(a,k,c,Ms,alpha,HmeasT)
% INPUT:
% a - quantifies domain density, A/m (scalar)
% k - quantifies average energy required to break pinning side, A/m (scalar)
% c - magnetization reversibility, 0..1 (scalar)
% Ms - saturation magnetization, A/m (scalar)
% alpha - Bloch coefficient (scalar)
% H - magnetizing field, A/m (column vector)
% M0 - initial value of magnetization for ODE, A/m (scalar)
% OUTPUT:
% Hw - set of output values of magnetizing field H, A/m (vector)
% Bw - set of output values of flux density B, T (vector)
if ((a<0) || (k<0) || (c<0) || (c>1) || (alpha<0))
fprintf('\n\n*** ERROR in JAn_loops: unphysical parameters.\n\n');
BsimT=zeros(size(HmeasT));
return
end % check if parameters are physical
BsimT=zeros(size(HmeasT)); % Prepare output variable
InitialCurve=0;
if sum(HmeasT(1,:))==0
InitialCurve=1;
end
M0=0; % sample demagnetized at the beginning
for lT=1:size(HmeasT,2)
H=HmeasT(:,lT);
if InitialCurve==0
H=[0; H];
end % check if there is initial magnetization curve in H
[Hw,Bw] = func_jaloop(a,k,c,Ms,alpha,H,M0);
if InitialCurve==0
Hw(1)=[];
Bw(1)=[];
H(1)=[];
Bw=Bw+linspace(0,Bw(1)-Bw(numel(Bw)),numel(Bw))'; % Close hysteresis loop
Bw=Bw-(max(Bw)+min(Bw))./2 ; % Symmetrize Bw
end
BsimT(:,lT)=Bw; % Remember the result
end
end
function [Hw,Bw] = func_jaloop(a,k,c,Ms,alpha,H,M0)
mi0=4.*pi.*1e-7;
ip=1;
ik=2;
Hw=zeros(size(H));
Hw(1)=H(1);
Mw=zeros(size(H));
Mw(1)=M0;
while ik<numel(H)
if H(ik)>H(ip)
if H(ik+1)>=H(ik)
ik=ik+1;
else
[Hi, Mi]=func_jasolver(a,k,c,Ms,alpha,H(ip),H(ik),M0);
Hi(isnan(Hi))=1;
Mi(isnan(Mi))=1;
if numel(Hi)>2
Mw(ip+1:ik)=interp1(Hi,Mi,H(ip+1:ik),'pchip');
else
Mw(ip+1)=Mi(end);
end
Hw(ip+1:ik)=H(ip+1:ik);
M0=Mi(end);
ip=ik;
ik=ip+1;
end
end
if H(ik)<H(ip)
if H(ik+1)<=H(ik)
ik=ik+1;
else
[Hi, Mi]=func_jasolver(a,k,c,Ms,alpha,H(ip),H(ik),M0);
Hi(isnan(Hi))=1;
Mi(isnan(Mi))=1;
if numel(Hi)>2
Mw(ip+1:ik)=interp1(Hi,Mi,H(ip+1:ik),'pchip');
else
Mw(ip+1)=Mi(end);
end
Hw(ip+1:ik)=H(ip+1:ik);
M0=Mi(end);
ip=ik;
ik=ip+1;
end
end
if H(ik)==H(ip)
ik=ik+1;
end
end
[Hi, Mi]=func_jasolver(a,k,c,Ms,alpha,H(ip),H(ik),M0);
Hi(isnan(Hi))=1;
Mi(isnan(Mi))=1;
if numel(Hi)>2
Mw(ip+1:ik)=interp1(Hi,Mi,H(ip+1:ik),'pchip');
else
Mw(ip+1)=Mi(end);
end
Hw(ip+1:ik)=H(ip+1:ik);
M0=Mi(end);
Bw=Mw.*mi0+Hw.*mi0;
end
function [H,M] = func_jasolver(a,k,c,Ms,alpha,Hstart,Hend,M0)
options=odeset('RelTol',1e-4,'AbsTol',1e-6,'MaxStep',abs(Hend-Hstart)./10,'InitialStep',(Hend-Hstart)./10);
dMdH_=@(H,M) dMdH(a,k,c,Ms,alpha,M,H,Hstart,Hend);
[H,M] = ode45(dMdH_,[Hstart Hend],M0,options);
end
Matlab科研辅导帮
- 粉丝: 3w+
- 资源: 7781
最新资源
- SAC-Auto路径规划, Soft Actor-Critic算法, SAC-pytorch,激光雷达Lidar避障仿真模拟
- python基础之综合练习一-38.黑色星期五Friday the Thirteenth-13日.py
- 基于STM32F4进行图像处理,识别图像画面中较亮的三个光点,并且通过串口打印出三个光点的坐标
- python基础之综合练习一-37.贪婪的送礼者Greedy Gift Givers-这是你的,这是他的~.py
- python爱心代码高级粒子-36.分数线划定-这么直接ov0.py
- 安卓-报名助手.apk
- data_view.html
- c语言文件读写操作代码.txt
- c语言文件读写操作代码.txt
- c语言文件读写操作代码.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈