CHE 492 HW 8 Fawaz Alsaiede

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Homework #8

November 19, 2021


CHE 492 - Computer Methods in Chemical Engineering - Dr. Jason Bara
By: Fawaz Alsaiede

1. Question 1:

1.1. Objective:
The first problem asks us to solve the heat distribution of a gold block with an initial
temperature of 900 Kelvin having a circular cavity of radius 0.33 where the left side of the
block is heated to 453 Kelvin whereas the right side of the block is maintained at a constant
temperature 293 Kelvin. MATLAB is used to simulate the heat distribution with a colormap
portraying the results.

1.2. Methods:
First, I used the createpde('thermal','transient') in order to create a thermal
analysis model containing the geometry, thermal properties of gold, initial block conditions
and thermal boundaries surrounding the block, as well as the heat fluxes. The boundary
conditions were set using the thermalBC() statement whereas the gold’s thermal block
properties were defined in SI units in the thermalProperties() statement. The
rectangular block and circular cavity were both defined in 2 matrices rl and CL respectively.
Quadratic triangular mesh was created for the thermal model using the generateMesh()
function and the thermal differential equation was solved using solve() function. The
results were visualized using as a ColorMap for time intervals of 0.25, 0.5, 1.0, and 2.0 secs
respectively. The full MATALAB script can be found in Appendix A.

1.3. Results:
Running the MATLAB script, I obtained figures showing the block and cavity geometry, the
quadratic triangular mesh, and the colormaps for the time intervals discussed earlier as can be
seen in Figures 3 through 9 below. The figures were obtained using the pdeplot() function
as a heatmap. Figure 2 below represents result snippet of the analytical representation showing
the form and structure of results obtained.

thermalresults =
TransientThermalResults with properties:

Temperature: [1076×21 double]


SolutionTimes: [0 0.2500 0.5000 0.7500 1 1.2500 1.5000 1.7500 2 2.2500
2.5000 2.7500 3 3.2500 3.5000 3.7500 4 4.2500 4.5000 4.7500 5]
XGradients: [1076×21 double]
YGradients: [1076×21 double]
ZGradients: []
Mesh: [1×1 FEMesh]

Figure 1. Snippet showing the thermal results representation form

1
Figure 2. Block and cavity geometry

Figure 3. Block mesh with quadratic triangular elements

Figure 4. Thermal heat model of block with cavity for a time interval of 5 secs.

2
Figure 5. Thermal heat model of block with cavity for a time interval of 0.25 secs.

Figure 6. Thermal heat model of block with cavity for a time interval of 0.5 secs.

Figure 7. Thermal heat model of block with cavity for a time interval of 1.0 secs.

3
Figure 8. Thermal heat model of block with cavity for a time interval of 2.0 secs.

Figure 2 is a result snippet of the transient thermal temperature representation where 1076
represents the number of heat nodes and 21 is the number of time intervals. Figures 3 and 4
represent the blocks geometry as well as the mesh formation respectively. Figure 5 is the
thermal model representation of the block after a 5 sec time interval whereas Figures 6 through
9 show the variation of the heat within the block throughout the specified time intervals.
1.4. Discussion
This problem is one of the numerous cases where MATLAB is used to solve a complex and
time extensive problems saving us time and giving us more reliable results. The heat
differential equations were solved within minutes and gave visual representations which help
the user gain an advanced understanding of heat diffusion and behavior around cavities. Such
algorithmic programs help save time and cost as well as improve efficiency leading to the
development of the chemical industry.

4
2. New Question:

Generate a colormap showing the flow of the gravitational magnetic flux around Earth.

5
Appendix A
A.1: Full script used to solve for the heat distribution in a
rectangular block with circular cavity.

A.1: Full script used to solve for the heat distribution in a rectangular block with circular cavity:
clear all
close all
clc
%%name of model thermalmodelS, createpde (create model) of type (thermal) for
transient analysis
thermalmodelS = createpde('thermal','transient');
%% creating the rectangle specifying the limit to be centered
r1 = [3 4 -.5 .5 .5 -.5 -.8 -.8 .8 .8]';
%% creating circle centered with 0.33 radius
C1 = [1,0,0,0.33]';

C1 = [C1;zeros(length(r1) - length(C1),1)];
%%subtract circle from rectangle to replace rectangle cavity
gm = [r1,C1];
sf = 'r1-C1';

ns = char('r1','C1');
ns = ns';
%% decompose geometry matrix
g = decsg(gm,sf,ns);

geometryFromEdges(thermalmodelS,g);
%plot geometry
pdegplot(thermalmodelS,'EdgeLabels','on')
axis equal
xlim([-1.1,1.1])
ylim([-1,1])
axis equal

%%Gold properties as required by assignment


thermalProperties(thermalmodelS,'ThermalConductivity',314,...
'MassDensity',19300,...
'SpecificHeat',129);

%% New Boundary conditions set


thermalBC(thermalmodelS,'Edge',3,'Temperature',453);
thermalBC(thermalmodelS,'Edge',1,'Temperature',293);
thermalIC(thermalmodelS,900);

%%Creating mesh for model


msh=generateMesh(thermalmodelS);
getClosestNode = @(p,x,y) min((p(1,:) - x).^2 + (p(2,:) - y).^2);
[~,nid] = getClosestNode( msh.Nodes, .5, 0 );

1A
Figure
%%plot the mesh
pdemesh(thermalmodelS)
%%Time interval
tlist = 0:0.25:5;
%%Solving differential equation of model during this interval
thermalresults = solve(thermalmodelS,tlist)
%%evaluate flux
[qx,qy] = evaluateHeatFlux(thermalresults);
%%Plot result with a cool colormap

figure
pdeplot(thermalmodelS,'XYData',thermalresults.Temperature(:,end), ...
'Contour','on',...
'FlowData',[qx(:,end),qy(:,end)], ...
'ColorMap','cool')

%% Visualize results at t = 0.25,0.5,1 and 2 respectively


figure
pdeplot(thermalmodelS,'XYData',thermalresults.Temperature(:,2),'Contour','on'
, ...
'ColorMap','cool');

figure
pdeplot(thermalmodelS,'XYData',thermalresults.Temperature(:,3),'Contour','on'
, ...
'ColorMap','cool');

figure
pdeplot(thermalmodelS,'XYData',thermalresults.Temperature(:,5),'Contour','on'
, ...
'ColorMap','cool');

figure
pdeplot(thermalmodelS,'XYData',thermalresults.Temperature(:,9),'Contour','on'
, ...
'ColorMap','cool');

2A

You might also like