Variable density in heat diffusion equation

5 次查看(过去 30 天)
Suppose I have a heat diffusion equation:
rho(x)*c(x)*dT/dt=d/dx(k(x)*dT/dx)
Where rho(x) is the density, c(x) is the heat capacity and k(x) is thermal diffusivity, all being position dependent. Would I need to specify these as vectors in pdepe instead of simple numbers?

回答(2 个)

Matthew Hunt
Matthew Hunt 2018-5-31
So I do the interp1 trick you demonstrated before?

Matthew Hunt
Matthew Hunt 2018-5-31
So I used the following code:
function [CC, FF, SS]=battery_GE(x,t,u,DuDx)
global rho; global c_th; global a_1;global k; global epsilon; global c_1;
global D; global a_2; global sigma; global b; global c_2; global x_vector;
D_var=interp1(x_vector,D,x);
k_var=interp1(x_vector,k,x);
sigma_var=interp1(x_vector,sigma,x);
epsilon_var=interp1(x_vector,epsilon,x);
rho_var=interp1(x_vector,rho,x);
c_var=interp1(x_vector,c_th,x);
CC=[rho_var.*c_var; 0; 1];
FF=[a_1*k_var; epsilon; c_1*D_var].*DuDx;
SS=[a_2*sigma_var.*DuDx(2); -b*u(3);c_2*(DuDx(3)-(b*u(3)./epsilon_var)-DuDx(1))];
And I got the following error messages:
Error using vertcat Dimensions of arrays being concatenated are not consistent.
Error in battery_model>battery_GE (line 83)
FF=[a_1*k_var; epsilon; c_1*D_var].*DuDx;
Error in pdepe (line 246)
[c,f,s] = feval(pde,xi(1),t(1),U,Ux,varargin{:});
Error in battery_model (line 50)
sol = pdepe(m,@battery_GE,@battery_ic,@battery_bc,x,t);
What went wrong?
  2 个评论
Torsten
Torsten 2018-6-1
FF=[a_1*k_var; epsilon_var; c_1*D_var].*DuDx;
instead of
FF=[a_1*k_var; epsilon; c_1*D_var].*DuDx;
Best wishes
Torsten.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by