Transient Heat Flow Calfem - example 2D Heat Flow Conductivity = 1*10-4 W/m oC Capacity = 0.25 J/K Kg 0oC qn=0 3m 7m 0oC Initial temp. 20oC 20oC qn=0 12m 5m Vertices = [ % Define the vertex coordinates 0 0 12 0 17 0 17 7 10 12 7 12 10 0 10 8 0 7 ]; Segments = [ % Define the line segments 6 1 2 2 3 4 3 4 4 5 5 6 2 6 7 7 8 0 8 1 2 5 8 5]; 0 2 4 6 8 10 12 Surfaces=[ 1 9 10 8 % Define the surfaces 2 3 4 9 10 5 6 7]; Seed = [ 9 4 7 4 3 9 3 7 7 9]*2; % Define the number of elements on each segment Segp=[Seed]; nen=3; % Three node elements dofsPerNode=1; mp=[ dofsPerNode, nen]; geomdraw2(Vertices,Segments,Surfaces,Segp,mp) % Draw the geometry % Generate the element mesh [Coord Edof Dof meshdb ]=strmeshgen(Vertices,Segments,Surfaces,Segp,mp); [Ex,Ey]=coordxtr(Edof,Coord,Dof,nen); Element mesh 14 16 t=1; rho=1; c=0.25; ep=[t, rho ,c]; D=1E-4*[1 0;0 1]; nel=size(Edof,1); ndof=max(Dof)); K=sparse(ndof,ndof); C=sparse(ndof,ndof); f=sparse(ndof,1); for i=1:nel [Ke,Ce]=flw2tt(Ex(i,:),Ey(i,:),ep,D); K=sparse_assem(Edof(i,:),K,Ke); C=sparse_assem(Edof(i,:),C,Ce); End bc1=extrseg ([3]',meshdb,1); bc2=extrseg ([6 7 8]',meshdb,1); bc=[bc1, ones(length(bc1),1)*20; bc2, ones(length(bc2),1)*0]; Using step1.m a0=ones(ndof,1)*0; % The initial temperature 0 degrees ti=[3600:3600:3600*96]; % Define a time-step vector ip=[3600 3600*96 0.5 [96 278 ti Dof']]; % Define: ∆t, total time, Crank-Nicholson, [no. of values to store, ndof, times ti, dofs] [Tsnap,D,V]=step1(K,C,a0,ip,f,bc) % Solve problem in time Temperature distribution 2 hours 96 hours Flux distribution 2 hours 96 hours
© Copyright 2024 Paperzz