# -*- coding: utf-8 -*- """ Exercice 13-2h : résolution d'une équation de convection-diffusion par la méthode des éléments finis Created on Mon Sep 11 16:53:42 2017 @author: ribot/grivet """ from pylab import * # Paramètes alfa = 1; epsilon = 0.1; # Discrétisation en espace xmin = 0; xmax = 1; npt = 21 nint = npt-1; nx = npt-2 h = (xmax-xmin)/nint xx = linspace(xmin,xmax,npt) #xx=xx' xxint = xx[1:nx+1] # Matrice de rigiditĂŠ K=(2*eye(nx,nx)-diag(ones(nx-1),1)-diag(ones(nx-1),-1))/h; # Matrice d'advection A=(diag(ones(nx-1),1)-diag(ones(nx-1),-1)); # Second membre F = ones_like(xxint) # Résolution - système 1D u=solve((epsilon*K+alfa*A),F) uu=hstack((0,u,0)) plot(xx,uu);