Time dependent external heat flux in PDE Toolbox

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.
Many thanks in advance!

 Akzeptierte Antwort

Ravi Kumar
Ravi Kumar am 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

4 Kommentare

Hi Ravi,
Thanks for your help!
This solution works, but Matlab needs a very long time to build the model.
Is this because of the time increments? My function looks now like this.
function Qflux = timeDepHeatFlux(region,state)
if isnan(state.time)
Qflux = nan(size(region.x));
return;
end
V_cyl = 2* pi * 0.0211*0.0211*0.5; %Volumen des bestrahlten Zylinders
y_dach = 1500; %maximal ankommender Wärmestrom
n=2; %Drehzahl Kern
heat = y_dach*sin(2*pi*n*state.time+pi/2); % function
heatflux_percentage = 0.10; %Wieviel Prozent des Strahlers werden benötigt
Positive = heat >0;
heat(~Positive)=0;
heatflux = heat/ V_cyl;
Qflux=heatflux_percentage*heatflux;
end
Thank you,Pascal
Ravi Kumar
Ravi Kumar am 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
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
Ravi Kumar am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by