%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % FILE: heat2d.m % PURPOSE: a code that aims to simulate 2d heat equation % using Euler method and central differencing % Copyright Ville Vuorinen (2019), no guarantee of % code functionality %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set(0,'DefaultAxesFontName','Times New Roman') set(0,'DefaultAxesFontSize',15) clear * close all Substance = 2; % 1=air 2=water if(Substance == 1) MyFile = 'AirBox.mat'; % give name of the file to save data in elseif(Substance == 2) MyFile = 'WaterBox.mat'; % give name of the file to save data in end TotalSimuTimeSeconds = 1; % how many seconds to simulate ? myBC = 4; % in setTBCs.m you can create new BC's , myBC=4 in HW2 GeometricalDetails; ThermodynamicalDetails; FluidDynamicalDetails; dxmin = min(dx,dy); dt = 0.05e-1; % timestep TotalSimuTimesteps = round(TotalSimuTimeSeconds/dt); giveInfo; setTBCs; for(t=1:TotalSimuTimesteps) tic; setTBCs; solveTemperature; visualizeResults; end save(MyFile, 'T', 'U', 'X', 'Y', 'Lx', 'Ly', 'alpha', 'k', 'rho', 'cp', 'iny','inx');