在matlab中,我们用两种方式去求解PDE方程,一种是使用 PDE toolbox,可以在App中查找到PDE Modeler,然后打开,通过绘制图形,设置边界,选择方程和细化网格,然后求解出结果;另外一种是通过编译代码,运用Function函数进行求解,现在我们就尝试第二种方法实现电芯热仿真过程。
圆柱电池热模型
我们根据圆柱的产热和散热特点,参考相关资料,建立模型如下
2.PDE方程求解在matlab中的帮助文件中,我们可以看到PDE的形式为将热模型方程换成相应的形式之后,可表述出m=1c=1/αf=δu/δts=egen/k
function [c,f,s] = pdex1pde(r,t,u,dudx)global alpha k e_genc = 1/alpha;f = dudx;s = e_gen/k;此外初始条件和边界条件也可以相关对应的表述,分别为function u0 = pdex1ic(r)global Tinitu0 = Tinit;function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)global h k Tinitpl = 0;ql = 1;pr = h*(ur-Tinit);qr = k;
3.模型计算
设置初始值和绘制图像,相关代码参考其他资料如下function [] = battery(C_rate)global k e_gen Tinit h alphacell_capacity = 1.1;C_rate=2;I = cell_capacity*C_rate;R_int = 0.017;Tinit = 30;V = pi*(0.009)^2*(0.065);k = 0.20;Cp = 1000;rho = 2362;h = 10;alpha = k/(rho*Cp);power = I^2*R_int;e_gen = power/V;total_t = 3600/C_rate;close allfilename = ['battery_' num2str(C_rate) 'C']m = 1;r = linspace(0,0.009,100);t = linspace(0,total_t,100); sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,r,t);T = sol(:,:,1);pcolor(r.*1000,t./60,T)xlabel('Distance from center, r (mm)')ylabel('Time, t (min)')hcb = colorbar; title(hcb,'Temperature (^oC)')title([num2str(C_rate) 'C'])print(filename,'-dsvg')figureSOC = t.*C_rate/3600*100;y_limits = [29 ceil(max(T(:))+1)];for i = 1:length(T(:,1)) plot(r.*1000,T(i,:)); title(['t = ' num2str(t(i)./60,3) ' min; SOC = ' num2str(SOC(i),3) '%'],'FontSize',16) xlabel('Distance from center, r (mm)') ylabel('Temperature (^oC)') ylim(y_limits) drawnow frame = getframe(2); im = frame2im(frame); [imind,cm] = rgb2ind(im,256); if i == 1 imwrite(imind,cm,[filename '.gif'],'gif','Loopcount',1); else imwrite(imind,cm,[filename '.gif'],'gif','WriteMode','append','DelayTime',0.05); endend4.结果分析
从下面图示可以看出,30min电池可以达到32℃。