% % @file modes.m % % @brief % % @copyright % Copyright (©) 2021 EPFL (Ecole Polytechnique Fédérale de Lausanne) % SPC (Swiss Plasma Center) % % SPClibs is free software: you can redistribute it and/or modify it under % the terms of the GNU Lesser General Public License as published by the Free % Software Foundation, either version 3 of the License, or (at your option) % any later version. % % SPClibs is distributed in the hope that it will be useful, but WITHOUT ANY % WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS % FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. % % You should have received a copy of the GNU Lesser General Public License % along with this program. If not, see . % % @author % (in alphabetical order) % @author Trach-Minh Tran % N=8; kmodes=N-1; %% modes on fine grid %% xh=(1/N).*(0:1:N); wh=zeros(N+1,kmodes); for k=1:kmodes wh(:,k) = sin((k*pi).*xh); end %% Restriction %% R=[ 1 0 0 0 0 0 0 0 0 0 0.5 1 0.5 0 0 0 0 0 0 0 0 0.5 1 0.5 0 0 0 0 0 0 0 0 0.5 1 0.5 0 0 0 0 0 0 0 0 0 1 ]; %% Null space of Restriction %% ns = [ 0 0 0 0 2 0 0 0 -1 -1 0 0 0 2 0 0 0 -1 -1 0 0 0 2 0 0 0 -1 -1 0 0 0 2 0 0 0 0]; figure subplot(211) plot(ns,'o-'); title('Basis of Null space of Restriction') subplot(212) plot(R','o-'); title('Basis of Range of Prolongation') %% modes on coarse grid %% N2h = N/2; x2h=(1/N2h).*(0:1:N2h); w2h = R*wh; x=0:0.01:1.; figure for k=1:kmodes subplot(3,3,k) plot(xh,wh(:,k),'o', x, sin((k*pi).*x),'b-', x2h, w2h(:,k), 'ro-'); grid on end figure for k=1:N/2 subplot(2,2,k) plot(xh,wh(:,k),'o-', xh,wh(:,N-k),'r*-') grid on end