Temperature Dependent parameters in PDE toolbox

조회 수: 4 (최근 30일)
Alexis  CAILLON
Alexis CAILLON 2016년 5월 21일
답변: Alexis CAILLON 2016년 5월 22일
Hello !
I'm trying to implement a Phase Change Material in PDE Toolbox in a 2D model, so that I build a model and I need to use Temp-dependent heat capacity and conductivity. I define the capacity as follow and it works well
d = @(region,state) 900.*(4250 +(15000-4250).*exp(-((21.7-state.u)./3).^2)); %Cp*rho
...
specifyCoefficients(modele,'m',0,'d',d,...,'face',1);
But to define conductivity I need a stattement condition on temperature. So I wrote a function in c.m
function y = c(region,state)
if state.u < 21.7
y = 0.25;
else
y = 0.20;
end
And I call the function in the main program as follow ..
cond = @c
specifyCoefficients(modele,'m',0,'d',d,'c',cond,...,'face',1);
But when I run the program , I get the following error:
Error using formGlobalKF2D
Coefficient evaluation function, "c", was requested to calculate coefficients at 276 locations so should have returned a
matrix with 276 columns. Instead it returned a matrix with 1 columns.
Does someone know how to implement a statement condition on my coefficients ?

채택된 답변

Alexis  CAILLON
Alexis CAILLON 2016년 5월 22일
I found by myself what was my mistake ! The c coefficient has to be a matrix of N lines ( number of equation) and Nr columns ( length(region.x) ) !
So it is sufficient to do modify the code as follow :
function y = c(region,state)
Nr = length(region.x)
y = zeros(1,Nr)
if state.u < 21.7
y(1,:) = 0.25;
else
y(1,:) = 0.20;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General PDEs에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by