Variable density in heat diffusion equation

5 views (last 30 days)
Matthew Hunt
Matthew Hunt on 30 May 2018
Commented: Torsten on 1 Jun 2018
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?
  1 Comment
Torsten
Torsten on 30 May 2018
Just like the initial conditions: as simple numbers dependent on x.

Sign in to comment.

Answers (2)

Matthew Hunt
Matthew Hunt on 31 May 2018
So I do the interp1 trick you demonstrated before?

Matthew Hunt
Matthew Hunt on 31 May 2018
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 Comments
Torsten
Torsten on 1 Jun 2018
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.

Sign in to comment.

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!