code for the transient heat transfer in a rectangular sheet , problem in formulation of for loop for simulation of time steps

4 ビュー (過去 30 日間)
I have written a code for the simulation of rectangular sheet and the problem statement is as follows:
  1. need to simulate the temperature profile across the thickness of the rectangular sheet
  2. the sheet is very long so i am taking differential element of same thickness but length is less
  3. speed of the sheet is to be considered which is 10 m/min here
  4. the total time for the transient simulation has to be 0 to 10 seconds
  5. first the sheet travels in air for a distance of 1 mm(test distance) and convective heat transfer condition applies at both of the boundary
  6. then the sheet is exposed to hot roller from end and the contact length is projected to be the length of sector found out by using circumference, wrap angle so in top it is exposed to air having same convective heat transfer condition and from the bottom, conduction is there so i have applied dirichlet boundary condition
  7. then it again travels in air for a distance of 0.5 mm where the convective heat transfer will be applied at both of the edges
the problem is regarding the time simulation
i want that for each time increment, the material should move
for example at t=0 s, speed =1 m/s , dt = 1 s
distance = 1*1 = 1
t_old = t
t=t_old+dt = 1+1 = 2 s, speed = 1 m/s
distance = 2*1
so it should go on like from t = 0 to 10 and calculate the corresponding distance travelled
and then at every distance travelled , the model should perform and apply the boundary conditions to get the results
but the problem is in the loop, i cannot figure it out how to correct the loop or should i write double loop instead of one
because the results=solve(model,tlist) or solve(model) is defined only in these forms in matlab and tlist should take two arguements. Also, the dependence of time is there in the model so if time changes, the model should give different results but it cannot be seen explicitly
code for reference and matlab is not allowing to upload the geometry file as it is in STL format
% Define the geometry and mesh (assuming one layer)
model = createpde('thermal', 'transient');
importGeometry(model, '/home/jbagchi/OB_5.stl');
generateMesh(model);
% Define the thermal properties for the PVC body
thermal_conductivity1 = 0.15; % W/m-K
specific_heat1 = 1350; % J/kg-K
density1 = 1250; % kg/m^3
% Define the thermal properties for the steel roller
thermal_conductivity2 = 50; %W/m-K
convective_htc = 500; %W/m2-K
diameter = 0.4; %m
% Convert material speed from m/min to m/s
material_speed = 10 / 60; % m/min to m/s
% Define the element size of your mesh
element_size = 0.001; % Adjust based on your mesh element size
% Calculate the dwell time
dwell_time = element_size / material_speed;
%Calculate the contact length, roller temperature
roller_diameter = 0.4; %metre
contact_angle_deg = 180; %in degree
contact_length = (pi*roller_diameter*contact_angle_deg)/360; %in metre
contact_length_test = 0.001; %m
air_contact_length = 0.5 ;%m
% Define the time parameters
t_end = 10.0; % seconds
dt = min(0.01, dwell_time); % Adjust time step to be smaller or equal to dwell time
% Define the transient heat conduction PDE
thermalProperties(model, "ThermalConductivity", thermal_conductivity1, "MassDensity", density1, "SpecificHeat", specific_heat1);
% Define initial temperature condition
initialTemperature = 25.0; % °C
thermalIC(model, initialTemperature);
% Initialize distance traveled
distance_traveled = 0;
%Define timesteps
tlist = 0:dt:t_end;
% Loop through time steps
for t = 0:t_end
% Update distance traveled based on material speed
distance_traveled = distance_traveled + material_speed * dt; % m/min to m
% Apply boundary conditions based on distance traveled
if distance_traveled < contact_length_test
% Contact with air (no heat transfer)
thermalBC(model, "Edge", 2, "Temperature", 25);
thermalBC(model, "Edge", 4, "Temperature", 25);
elseif distance_traveled < (contact_length_test + contact_length)
% Contact with roller (conduction and convection)
thermalBC(model, "Edge", 2, "Temperature", 100);
thermalBC(model, "Edge", 4, "ConvectionCoefficient", 12, "AmbientTemperature", 25); % Adjust h as needed
else
% Contact with air again (no heat transfer)
thermalBC(model, "Edge", 2, "Temperature", 25);
thermalBC(model, "Edge", 4, "Temperature", 25);
end
end
% Solve for current time step
results = solve(model, tlist);
% Extract the temperature at the end of the time step
temperature = results.Temperature(:, end);
%Set the tolerance of the solver options.
model.SolverOptions.RelativeTolerance = 1.0e-3;
model.SolverOptions.AbsoluteTolerance = 1.0e-4;
% Extract and visualize the temperature field at specific time steps
time_steps_to_plot = [0, 2, 4, 6, 8, 10]; % Time steps to visualize
figure;
for i = 1:length(time_steps_to_plot)
subplot(2, 3, i);
pdeplot(model, 'XYData', results.Temperature(:, i), 'Contour', 'on');
title(['Time = ', num2str(time_steps_to_plot(i)), ' s']);
end
% Add a color bar to the last subplot
h = colorbar;
set(h, 'Position', [0.92, 0.12, 0.02, 0.76]);
could someone please help me with this!
thanks in advance!
  1 件のコメント
vidyesh
vidyesh 2023 年 9 月 27 日
Hello Joydeep,
I was not able to reproduce the issue at my end. It would be helpful to debug if you could provide the STL file and the expected result. You can upload the STL file by zipping it.

サインインしてコメントする。

回答 (1 件)

vidyesh
vidyesh 2023 年 9 月 25 日
Hello Joydeep Bagchi,
I understand that you are facing an issue while creating a loop to solve your equation.
The current ‘for’ loop starts at 't = 0' and increments by 1 until 't' reaches the value of 't_end'. However, to get the desired results, it is necessary for 't' to increment by 'dt' for each iteration instead.
Please make the following change in line 53:
Replace
for t = 0:t_end
with
for t = 0:dt:t_end
Hope this helps resolve the issue.
  1 件のコメント
Joydeep Bagchi
Joydeep Bagchi 2023 年 9 月 25 日
yes, I have tried but it doesn't give me the desired result
however, thankyou for the reply

サインインしてコメントする。

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by