





Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!






% 0. 1-0.2 Here node coordinates and element connectivity are defined. nodeCoordinates = [ 0 0 ; 0.01 0 ; 0.02 0 ; 0.03 0 ; 0 0.01 ; 0.01 0.01 ; 0.02 0.01 ; 0.03 0.01 ; 0.02 0.02 ; 0.03 0.02 ; 0.02 0.03 ; 0.03 0.03 ]; elementNodes = [ 1 2 6 5 ; 2 3 7 6 ; 3 4 8 7 ; 7 8 10 9 ; 9 10 12 11 ]; % Size of model numnodes=size(nodeCoordinates,1) [numelements nNodeElem]=size(elementNodes) nDof = 1 %% Unknown field is scalar nDofsGlobal=nDof*numnodes % 0.3 Define material assignment for each element for i=1:numelements elementMat(i)=1; % defines the number of material for each element end % 0.4 Define propertie of each material % As many properties as number of materials in total propMatlist(1).K=384; % W/(m K) % 0.5 Boundary conditions % 0.5.1. Define nodes with prescribed T and their value prescribedTNodes= [1;5]; temperatures = 20 * ones(2,1); % ºC or K % 0.5.2 Define nodes with prescribed Q and their value prescribedQNodes=[11 ; 12];
stiffglob(nodos_global,nodos_global)=stiffglob(nodos_global,nodos_global)+stiffelem;% Add element stiffness matrix to global one (assembly) end Q_T_bound=-stiffglob*T; %1.2 Eliminate equations in which T is presribed activeDofs=setdiff(1:nDofsGlobal,[prescribedTNodes]); %1.3 Solve linear system Tred=stiffglob(activeDofs,activeDofs)(Q(activeDofs)+Q_T_bound(activeDofs)); % Solution: Global displacement vector T(activeDofs)=Tred; scatter(nodeCoordinates(:,1),nodeCoordinates(:,2),100,T) plot_2DMESH_mats(nodeCoordinates,elementNodes,T,elementMat) plot_flux(nodeCoordinates,elementNodes,T,elementMat,propMatlist) %0.6 Define volumetric heat source (W/m^3), r<0 entry flux function r=heat_source(x) r=3e7; %W/m^ return end
prescribedQNodes=[11 ; 12]; t = 0.005; q0 = 1e6; L = 0.01; Nn = length(prescribedQNodes); Q = t * q0 * L/Nn; fluxes= Q * ones(Nn,1) % They have to be W/m = q_0*Le , %% SOLVER %1.1 Form stiffness matrix stiffglob=zeros(nDofsGlobal); T=zeros(nDofsGlobal,1); % Global unknown vector at nodes Q=zeros(nDofsGlobal,1);% Global RHS at nodes % Initialize force and displacement with BCs T(prescribedTNodes,1)=temperatures; % applied Temperatures Q(prescribedQNodes,1)= fluxes ;% applied heat (W/m in 2D) for ielem=1:numelements %Loop in elements nodos_global=elementNodes(ielem,:); %Obtain dof numbers for element ielem xnod(1,1)=nodeCoordinates(elementNodes(ielem,1),1); xnod(2,1)=nodeCoordinates(elementNodes(ielem,1),2); xnod(3,1)=nodeCoordinates(elementNodes(ielem,2),1); xnod(4,1)=nodeCoordinates(elementNodes(ielem,2),2); xnod(5,1)=nodeCoordinates(elementNodes(ielem,3),1); xnod(6,1)=nodeCoordinates(elementNodes(ielem,3),2); xnod(7,1)=nodeCoordinates(elementNodes(ielem,4),1); xnod(8,1)=nodeCoordinates(elementNodes(ielem,4),2); propMat.K=propMatlist(elementMat(ielem)).K; stiffelem=element_stiffness_2D4N(propMat,xnod,2); rdV = integrateb(@heat_source,xnod,2);
Q(nodos_global,1)=Q(nodos_global,1)+rdV; stiffglob(nodos_global,nodos_global)=stiffglob(nodos_global,nodos_global)+stiffelem;% Add element stiffness matrix to global one (assembly) end Q_T_bound=-stiffglob*T; %1.2 Eliminate equations in which T is presribed activeDofs=setdiff(1:nDofsGlobal,[prescribedTNodes]); %1.3 Solve linear system Tred=stiffglob(activeDofs,activeDofs)(Q(activeDofs)+Q_T_bound(activeDofs)); % Solution: Global displacement vector T(activeDofs)=Tred; scatter(nodeCoordinates(:,1),nodeCoordinates(:,2),100,T) plot_2DMESH_mats(nodeCoordinates,elementNodes,T,elementMat) plot_flux(nodeCoordinates,elementNodes,T,elementMat,propMatlist) %0.6 Define volumetric heat source (W/m^3), r<0 entry flux function r=heat_source(x) r= - 3e7; %W/m^ return end