필터 지우기
필터 지우기

PDE Thermal model computation speed

조회 수: 3 (최근 30일)
juan ugalde
juan ugalde 2019년 2월 20일
댓글: Ravi Kumar 2019년 3월 14일
Dear all,
I am currently using the PDE tool box to model a battery heating. Initially, the boundary conditions were all defined by convection and a constant ambient temperature.In said configuration, the computation time was around 10s.
Then, I changed one of the boundary conditions to a time dependent temperature boundary using the handle function : Tval = Tfun(location,state). In this case, the computation time was very long, requiring more than 10 minutes to obtain the results
I would like to know if this behavior is normal.
Here is my code:
Thermal=createpde('thermal','transient');
para= struct;
%%%%%%%%Parametres%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
para.rho=2845;
para.cp=1000;
para.kx=0.2;
para.ky=25;
para.convec= 10;
para.ambientT= 20;
c = [para.kx;para.ky];
%%%%%%% Geometrie%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
R1 = [3,4,-0.0105,0.0105,0.0105,-0.0105,0.035,0.035,-0.035,-0.035]';...
g=decsg(R1);
geometryFromEdges(Thermal,g);
hmax = .0025;
generateMesh(Thermal,'Hmax',hmax);
figure;
hold on
box on
pdegplot(Thermal,'EdgeLabels','on');
pdeplot(Thermal)
axis equal
%%%%%%Proprietes%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
thermalProperties(Thermal,'ThermalConductivity',c,...
'MassDensity',para.rho,...
'SpecificHeat',para.cp)
internalHeatSource(Thermal,@heatSourceFun)
%%%%%%Boundaries%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
thermalBC(Thermal,'Edge',4, ...
'ConvectionCoefficient',para.convec, ...
'AmbientTemperature',para.ambientT)
thermalBC(Thermal,'Edge',2 , ...
'ConvectionCoefficient',para.convec, ...
'AmbientTemperature',para.ambientT)
%
% thermalBC(Thermal,'Edge',1 , ...
% 'ConvectionCoefficient',para.convec,...
% 'AmbientTemperature',para.ambientT)
%
thermalBC(Thermal,'Edge',3 , ...
'ConvectionCoefficient',para.convec,...
'AmbientTemperature',para.ambientT)
thermalBC(Thermal,'Edge', 1, 'Temperature',@Tfun)
thermalIC(Thermal,30);
%Solve
tlist=1:2100;
thermalresults = solve(Thermal,tlist);
T = thermalresults.Temperature;
Modele_plot;
And here is my Tfun function
function Tval = Tfun(location,state)
load('sup.mat')% experimental data
if isnan(state.time)
Tval= NaN(length(location.x));
elseif state.time<=1
Tval= 30*ones(length(location.x));
elseif state.time>1
Tval=sup(floor(state.time))*ones(length(location.x));
end
end
Thanks in advance,
Juan.

답변 (1개)

Ravi Kumar
Ravi Kumar 2019년 3월 12일
Hi Juan,
Nonconstant BC would take longer than constant BC. However, the increase you are observing seems abnormal, given that you are not modelling any nonlinear behavior.
Two suggestions:
1. Move the load outside of the function. You can do that by wrapping the Tfun as an outer function that taken required two arguments, but then calls an inner computation function that takes three arguments, location, state, and sup. Something like:
load('sup.mat')
Tfunc = @(location,state) TfuncComputation(location,state,sup);
rename you current Tfunc definitation as TfuncComputation. (Make sure you get the syntax correct.)
2. Use 'Vectorized' option in thermalBC
thermalBC(model,'Temperature',@Tfunc,'Vectorized','on')
Regards,
Ravi
  댓글 수: 2
juan ugalde
juan ugalde 2019년 3월 13일
Dear Ravi,
Thank you for your reply. I did not manage to use for 1st option but I moved the load outside the function using a global variable, which considerably reduced the calculation time to 1-2 minutes.
I would like to ask you one question regarding the ambient temperature. Indeed, I would like to know if it is possible to have a time dependent function as Tfun. I want to model the thermal behavior of an object when I change the ambient temperature.
Thanks again,
Juan.
Ravi Kumar
Ravi Kumar 2019년 3월 14일
Hi Juan,
In this case you can compute the heat flux in a function and specify it using 'HeatFlux'.
thermalBC(Thermal,'Edge',3,'HeatFlux', @heatFlux)
You can use the ambient termperature and heat transfer coefficents to comptute the resulting heat flux in quite general form.
Regards,
Ravi

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by