2-D Transient Heat Transfer Using Surf

2 visualizaciones (últimos 30 días)
Christian Sandfort
Christian Sandfort el 10 de Oct. de 2020
Comentada: Durganshu el 12 de Oct. de 2020
Hello,
I have code that I want to plot the heat transfer of a cross section of a Li-ion battery as a function of time. The code runs but keeps giving me errors of frame size and only gives me the final temperature solution. I want it to run from 0 charge to 12 C charge with a discharge current of 45 Amps for 300 seconds.
Here is the code:
%% PARAMETERS
global k e_gen Tinit h alpha
%% RELATIVELY CONSTANT PARAMETERS
cell_capacity = 4.2; % Ah
C_rate = 12;
prompt2 = 'What is the discharge current in Amps? ';
I = input(prompt2); % A, current (discharge)
Tinit = 25;% [=] deg C, initial temperature
V = pi*(0.01085)^2*(0.0702); % [=] m^3, cell volume
R_int = .016;
prompt3 = 'What is the heat transfer coefficient in W/m^2-K? Example: 10 for ambient air, 500 for flowing water. ';
h = input(prompt3);
%% ESTIMATED PARAMETERS
k = 70; % [=] W/m-K, thermal conductivity
Cp = 800;% J/kg-K, specific heat capacity
rho = 2707; % [=] kg/m^3, density
% Value for h taken from Engineering Toolbox: h = 10 for air, 500 for oil
%% CALCULATED PARAMETERS
alpha = k/(rho*Cp);
power = I^2*R_int; % [=] W, power generated by cell
e_gen = power/V; % [=] W/m^3, volumetric heat generation term
total_t = 3600/C_rate; % [=] s, total time
%%%%%%%%%%%%%%%%%%%%%%%%
close all
m = 0; % cylinder geometry
y = linspace(0,.01085,100);
r = linspace(0,0.07,100); % r = 0 to (10.5 mm)
t = linspace(0,total_t,100);
z = zeros(length(r),length(y),length(t));
sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,r,t);
% Extract the first solution component as T
T = sol(:,:,1);
for total_t = 1:total_t
z(:,:,1:length(total_t)) = T;
end
[x,y] = meshgrid(r,y);
open(obj)
for total_t = 1:length(t)
surfc(r,y,z(:,:,total_t));
xlabel('Height in (m)');
ylabel('R in (m)');
zlabel('Temperature in (C)');
title(num2str(t(total_t),'time = %4.3 (sec)'));
zlim([0 ceil(max(T(:))+1)]);
set(gca,'Fontsize',12);
set(gca,'FontWeight','Bold');
colormap jet;
caxis([25 max(T(:))]);
colorbar;
drawnow
pause(0.1)
f = getframe(gca);
size(f.cdata)
writeVideo(obj,f);
end
close(gca)
close(obj)
% --------------------------------------------------------------------------
function [c,f,s] = pdex1pde(r,t,u,DuDx)
% Main PDE
global alpha k e_gen
c = 1/alpha;
f = DuDx;
s = e_gen/k;
end
% --------------------------------------------------------------------------
function u0 = pdex1ic(r)
% Initial condition
global Tinit
u0 = Tinit;
end
% --------------------------------------------------------------------------
function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t)
% Boundary conditions
global h k Tinit
pl = 0;
ql = 1;
pr = h*(ur-Tinit);
qr = k;
end
  1 comentario
Durganshu
Durganshu el 12 de Oct. de 2020
Can you please post your question in a better way? read the MATLAB's guide to how to ask good questions.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Fluid Dynamics en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by