Clear Filters
Clear Filters

How can I represent Temperature VS Radius from this transient routine?

2 views (last 30 days)
The goal of my work is rapresenting the temperature VS radius in a cylinder. I've obtained the distribution by ''ColorMapData'', but I have the necessity to obtain the plot of temperature VS radius and then, the temeprature VS radiur at different time (iteration).
this is my code:
model=createpde("thermal",'transient')
geo = multicylinder(0.00885,0.0277);
model.Geometry = geo;
generateMesh(model);
pdemesh(model)
figure
pdegplot(model,'FaceLabels','on',"CellLabels","on",'FaceAlpha',0.5)
k = 0.35; % Thermal conductivity, W/(m*°K)
rho = 999.14; % Density, kg/m^3
cp = 2126.66; % Specific heat, W*s/(kg*°K)
thermalProperties(model,'ThermalConductivity',k,'MassDensity',rho,"SpecificHeat",cp)
thermalBC(model,"Face",[3,model.Geometry.NumFaces],"Temperature",30);
thermalIC(model,60,'Cell',1);
tlist=0:0.5:60;
result=solve(model,tlist);
T = result.Temperature;
figure
pdeplot3D(model,"ColorMapData",T(:,end))

Answers (1)

Atithi
Atithi on 5 Jul 2023
I have made some modifications to the code and also added comments for you to understand it better
This code creates a thermal model with multiple cylinders as the geometry. It sets the thermal properties, boundary conditions, and initial conditions. Then, it solves the model for a range of time steps and obtains the temperature distribution.
The first figure plots the temperature versus radius at the final time step, while the second figure shows the temperature versus radius at different time iterations, with each subplot representing a specific time.
model = createpde("thermal", "transient");
geo = multicylinder(0.00885, 0.0277);
model.Geometry = geo;
generateMesh(model);
pdemesh(model);
figure;
pdegplot(model, 'FaceLabels', 'on', 'CellLabels', 'on', 'FaceAlpha', 0.5);
k = 0.35; % Thermal conductivity, W/(m*°K)
rho = 999.14; % Density, kg/m^3
cp = 2126.66; % Specific heat, W*s/(kg*°K)
thermalProperties(model, 'ThermalConductivity', k, 'MassDensity', rho, 'SpecificHeat', cp);
thermalBC(model, "Face", [3, model.Geometry.NumFaces], "Temperature", 30);
thermalIC(model, 60, 'Cell', 1);
tlist = 0:0.5:60;
result = solve(model, tlist);
T = result.Temperature;
% Plot temperature versus radius at the final time step
figure;
pdeplot3D(model, 'ColorMapData', T(:, end));
title('Temperature vs Radius at Final Time');
% Plot temperature versus radius at different time iterations
figure;
for i = 1:length(tlist)
subplot(2, ceil(length(tlist)/2), i);
pdeplot3D(model, 'ColorMapData', T(:, i));
title(['Temperature vs Radius at Time = ', num2str(tlist(i)), ' s']);
end
Note : This code takes around 2 minutes to run (Might take longer on weaker systems)
Do let me know if it works and if it was helpful

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!