# Time dependent external heat flux in PDE Toolbox

10 views (last 30 days)
Pascal Kobuß on 21 Nov 2019
Commented: Ravi Kumar on 25 Nov 2019
Dear Community;
i am dealing with an issue with my model of a heat distribution of a cylindrical circular rod. My model is quite similar to https://de.mathworks.com/help/pde/examples/heat-distribution-in-a-circular-cylindrical-rod.html, but i am trying to create a heat flux, which is time-dependent. None of the tutorials or examples is really helpful. Unfortunately i am a beginner with Matlab, so i dont offer much skills in programming.
This is my code for the heatflux at the moment. Right now i am just working with an average heatflux, but i would like to use a time-dependent formula.
y_dach = 600;
n=2;
ts=1/8000; %increment
T=4; %T_max
t=0:ts:T; %timelist
heat = y_dach*sin(2*pi*n*t+pi/2); %Formula i want to use
heatflux_percentage = 0.35;
Positive = heat >0;
heat(~Positive)=0; % only positive values
heatflux = heat/ V_cyl; ,
avg_heatflux=mean(heatflux_percentage*heatflux);
thermalBC(thermalModelT,'Edge',[7,8],'HeatFlux',avg_heatflux)
This is my solver:
tfinal = 50; %tmax
tlist = 0:2:tfinal; %timeincrements
thermalModelT.SolverOptions.ReportStatistics = 'on';
result = solve(thermalModelT,tlist);
T = result.Temperature;
I know that i somehow have to use a function handle with state.time, but i dont know how to use it.

Ravi Kumar on 21 Nov 2019
Hi Pascal,
You are on the right track, refer to the externalHeatFlux in the example:
Thought the example is for spatial variaion, you can make your heat flux funciton of time using state.time, state is available to you as second argument.
function Qflux = timeDepHeatFlux(region,state)
if isnan(state.time)
Qflux = nan(size(region.x));
return;
end
% Write you time dependent function here....
end
Regards,
Ravi

Show 1 older comment
Ravi Kumar on 21 Nov 2019
Hi Pascal,
You time vector is very large, contains about 32k time-steps. This is very large, depending on the mesh size it could take very long. You could increase the ts to first see if everything is working as you expected. Note that evern if you increase ts, solver would take the necessary smaller steps, when needed, and only provide you with restulst at each time point in the time vector.
Regards,
Ravi
Pascal Kobuß on 22 Nov 2019
Hi Ravi,
thank you. So, the problem is the very large time vector. I cant change the vector though, because my analysis lasts such a long period of time. But besides that, is there a possiblity to say, that the heatflux will stop at a certain amount of time, so that my model will cool down after the heating phase?
Ravi Kumar on 25 Nov 2019
You should be able to do this in the function. Use state.time to switch from 'on' and 'off' conditions using, if-statement for example.