3D Heat Equation in PDE Solver
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello. I have a code that solves my heat equation. However, when I interpolate temperatures at a specific point, I get an error:
Error using pde.ThermalResults.interpolateSolutionInternal
Incorrect number of input arguments.
Error in pde.TransientThermalResults/interpolateTemperature (line 208)
Tintrp = pde.ThermalResults.interpolateSolutionInternal(obj,varargin{:});
Error in untitled8 (line 42)
T_center = interpolateTemperature(results, 5,5,0.5);
I have the following code:
% Create a PDE model
model = createpde("thermal", "transient");
% Import the geometry from the STL file
g = importGeometry(model, "Plate10x10x1.stl");
% Plot the geometry with face labels and transparency
pdegplot(g, 'FaceLabels', 'on', 'FaceAlpha', 0.5);
% Customize the plot as needed
xlabel('x');
ylabel('y');
zlabel('z');
title('Cake Geometry');
% Define the boundary conditions
T_oven = 350; % Oven temperature (in Fahrenheit)
T_initial = 80; % Initial temperature of the cake (in Fahrenheit)
% Convert temperatures to Celsius for PDE Toolbox
T_oven = (T_oven - 32) * 5/9;
T_initial = (T_initial - 32) * 5/9;
% Define the thermal properties
thermalProperties(model, 'ThermalConductivity', 0.2, 'MassDensity', 1000, 'SpecificHeat', 4.2);
% Define the boundary conditions
thermalBC(model, 'Face', [1 2 3 4 5 6], 'Temperature', T_oven);
% Set the initial temperature distribution
thermalIC(model, T_initial);
% Generate the mesh
generateMesh(model);
tlist = 0:0.5:5;
% Solve the PDE
results = solve(model, tlist);
% Extract the temperature at the center of the cake
T_center = interpolateTemperature(results, 5,5,0.5);
% Convert the temperature back to Fahrenheit for plotting
T_center = T_center * 9/5 + 32;
% Plot the temperature of the center of the cake against time
t = results.Mesh.Nodes(4, :);
plot(t, T_center);
xlabel('Time');
ylabel('Temperature (°F)');
title('Temperature of the Center of the Cake');
% Convert the temperature to Celsius for display
T_center_celsius = (T_center - 32) * 5/9;
fprintf('Final temperature of the center of the cake: %.2f°C\n', T_center_celsius(end));
0 comentarios
Respuestas (1)
Torsten
el 2 de Jul. de 2023
Editada: Torsten
el 2 de Jul. de 2023
T_center = interpolateTemperature(results, 5,5,0.5);
You didn't specify the times at which you want the temperature to be supplied. It's the fifth argument to "interpolateTemperature" that is missing.
Read the documentation for "interpolateTemperature" carefully:
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!