source: palm/trunk/UTIL/chemistry/gasphase_preproc/kpp/util/sparsity_plots.m @ 3209

Last change on this file since 3209 was 2696, checked in by kanani, 7 years ago

Merge of branch palm4u into trunk

File size: 962 bytes
Line 
1% Plots the sparsity patterns of the  Jacobian and the Hessian
2
3%%%%% JACOBIAN
4figure(1);
5
6J = zeros(NVAR,NVAR);
7for k=1:LU_NONZERO
8  J( LU_IROW(k), LU_ICOL(k) ) = 1;
9end
10spy(J);
11TK = floor( linspace(1,NVAR,5) );
12set(gca,'XTick',TK,'YTick',TK,'FontSize',14,'LineWidth',2);
13
14%%%%% HESSIAN
15figure(2);
16
17H = zeros(NVAR,NVAR,NVAR);
18for k=1:NHESS
19  H( IHESS_I(k), IHESS_J(k), IHESS_K(k) ) = 1;
20  H( IHESS_I(k), IHESS_K(k), IHESS_J(k) ) = 1;
21end
22
23M = ceil( sqrt(NVAR) );
24
25for i=1:M
26  for j=1:M
27    k = M*(i-1)+j;
28    if ( k <= NVAR )
29      subplot(M,M,k);
30      hold on
31      G = reshape( H(k,1:NVAR,1:NVAR), NVAR, NVAR );
32      % spy(G); figure;hold on
33      for iH=1:NVAR; for jH=1:NVAR
34         if( G(iH, jH) )
35            plot(iH,NVAR+1-jH,'.');
36         end;
37      end; end
38      text(NVAR/6,NVAR*0.6,int2str(k))
39      set(gca,'XLim',[1,NVAR],'YLim',[1,NVAR]);
40      set(gca,'XTick',[],'YTick',[]);
41      axis('square');
42      box on     
43      hold off;
44    end
45  end
46end   
Note: See TracBrowser for help on using the repository browser.