Variable density in heat diffusion equation

7 vues (au cours des 30 derniers jours)
Matthew Hunt
Matthew Hunt le 30 Mai 2018
Commenté : Torsten le 1 Juin 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 commentaire
Torsten
Torsten le 30 Mai 2018
Just like the initial conditions: as simple numbers dependent on x.

Connectez-vous pour commenter.

Réponses (2)

Matthew Hunt
Matthew Hunt le 31 Mai 2018
So I do the interp1 trick you demonstrated before?

Matthew Hunt
Matthew Hunt le 31 Mai 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 commentaires
Matthew Hunt
Matthew Hunt le 31 Mai 2018
I see the error.
Torsten
Torsten le 1 Juin 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Linear Algebra dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by