sundialsTB > idas > IDAMonitor.m
IDAMonitor

PURPOSE

IDAMonitor is the default IDAS monitoring function.

SYNOPSIS

function [new_data] = IDAMonitor(call, T, YY, YP, YQ, YYS, YPS, data)

DESCRIPTION

IDAMonitor is the default IDAS monitoring function.
   To use it, set the Monitor property in IDASetOptions to
   'IDAMonitor' or to @IDAMonitor and 'MonitorData' to mondata
   (defined as a structure).
  
   With default settings, this function plots the evolution of the step 
   size, method order, and various counters.
   
   Various properties can be changed from their default values by passing
   to IDASetOptions, through the property 'MonitorData', a structure
   MONDATA with any of the following fields. If a field is not defined, 
   the corresponding default value is used.

   Fields in MONDATA structure:
     o stats [ {true} | false ]
         If true, report the evolution of the step size and method order.
     o cntr [ {true} | false ]
         If true, report the evolution of the following counters:
         nst, nre, nni, netf, ncfn (see IDAGetStats)
     o mode [ {'graphical'} | 'text' | 'both' ] 
         In graphical mode, plot the evolutions of the above quantities.
         In text mode, print a table.
     o xaxis [ 'linear' | {'log'} ]
         Type of the time axis for the stepsize, order, and counter plots 
         (graphical mode only).
     o sol  [ true | {false} ]
         If true, plot solution components.
     o sensi [ true | {false} ]
         If true and if FSA is enabled, plot sensitivity components.
     o select [ array of integers ]
         To plot only particular solution components, specify their indeces in
         the field select. If not defined, but sol=true, all components are plotted.
     o updt [ integer | {50} ]
         Update frequency. Data is posted in blocks of dimension n.
     o skip [ integer | {0} ]
         Number of integrations steps to skip in collecting data to post.
     o dir [ {1} | -1 ]
         Specifies forward or backward integration.
     o post [ {true} | false ]
         If false, disable all posting. This option is necessary to disable
         monitoring on some processors when running in parallel.

   See also IDASetOptions, IDAMonitorFn

   NOTES:
     1. The argument mondata is REQUIRED. Even if only the default options
        are desired, set mondata=struct; and pass it to IDASetOptions.
     2. The arguments YP, YQ, and YPS are currently ignored.

CROSS-REFERENCE INFORMATION

This function calls:
  • IDAGetStats IDAGetStats returns run statistics for the IDAS solver.
This function is called by:
  • idabanx IDADENX - IDAS example problem (serial, dense)
  • idadenx IDADENX - IDAS example problem (serial, dense)

SUBFUNCTIONS

SOURCE CODE

0001 function [new_data] = IDAMonitor(call, T, YY, YP, YQ, YYS, YPS, data)
0002 %IDAMonitor is the default IDAS monitoring function.
0003 %   To use it, set the Monitor property in IDASetOptions to
0004 %   'IDAMonitor' or to @IDAMonitor and 'MonitorData' to mondata
0005 %   (defined as a structure).
0006 %
0007 %   With default settings, this function plots the evolution of the step
0008 %   size, method order, and various counters.
0009 %
0010 %   Various properties can be changed from their default values by passing
0011 %   to IDASetOptions, through the property 'MonitorData', a structure
0012 %   MONDATA with any of the following fields. If a field is not defined,
0013 %   the corresponding default value is used.
0014 %
0015 %   Fields in MONDATA structure:
0016 %     o stats [ {true} | false ]
0017 %         If true, report the evolution of the step size and method order.
0018 %     o cntr [ {true} | false ]
0019 %         If true, report the evolution of the following counters:
0020 %         nst, nre, nni, netf, ncfn (see IDAGetStats)
0021 %     o mode [ {'graphical'} | 'text' | 'both' ]
0022 %         In graphical mode, plot the evolutions of the above quantities.
0023 %         In text mode, print a table.
0024 %     o xaxis [ 'linear' | {'log'} ]
0025 %         Type of the time axis for the stepsize, order, and counter plots
0026 %         (graphical mode only).
0027 %     o sol  [ true | {false} ]
0028 %         If true, plot solution components.
0029 %     o sensi [ true | {false} ]
0030 %         If true and if FSA is enabled, plot sensitivity components.
0031 %     o select [ array of integers ]
0032 %         To plot only particular solution components, specify their indeces in
0033 %         the field select. If not defined, but sol=true, all components are plotted.
0034 %     o updt [ integer | {50} ]
0035 %         Update frequency. Data is posted in blocks of dimension n.
0036 %     o skip [ integer | {0} ]
0037 %         Number of integrations steps to skip in collecting data to post.
0038 %     o dir [ {1} | -1 ]
0039 %         Specifies forward or backward integration.
0040 %     o post [ {true} | false ]
0041 %         If false, disable all posting. This option is necessary to disable
0042 %         monitoring on some processors when running in parallel.
0043 %
0044 %   See also IDASetOptions, IDAMonitorFn
0045 %
0046 %   NOTES:
0047 %     1. The argument mondata is REQUIRED. Even if only the default options
0048 %        are desired, set mondata=struct; and pass it to IDASetOptions.
0049 %     2. The arguments YP, YQ, and YPS are currently ignored.
0050 
0051 % Radu Serban <radu@llnl.gov>
0052 % Copyright (c) 2005, The Regents of the University of California.
0053 % $Revision: 1.1 $Date: 2006/07/17 16:49:50 $
0054 
0055 
0056 new_data = [];
0057 
0058 if call == 0
0059 
0060 % Initialize unspecified fields to default values.
0061   data = initialize_data(data);  
0062 
0063 % Open figure windows
0064   if data.post
0065 
0066     if data.grph
0067       if data.stats | data.cntr
0068         data.hfg = figure;
0069       end
0070 %     Number of subplots in figure hfg
0071       if data.stats
0072         data.npg = data.npg + 2;
0073       end
0074       if data.cntr
0075         data.npg = data.npg + 1;
0076       end
0077     end
0078     
0079     if data.text
0080       if data.cntr | data.stats
0081         data.hft = figure;
0082       end
0083     end
0084 
0085     if data.sol | data.sensi
0086       data.hfs = figure; 
0087     end
0088   
0089   end
0090   
0091 % Initialize other private data
0092   data.i = 0;
0093   data.n = 1;  
0094   data.t = zeros(1,data.updt);
0095   if data.stats
0096     data.h = zeros(1,data.updt);
0097     data.q = zeros(1,data.updt);
0098   end
0099   if data.cntr
0100     data.nst = zeros(1,data.updt);
0101     data.nre = zeros(1,data.updt);
0102     data.nni = zeros(1,data.updt);
0103     data.netf = zeros(1,data.updt);
0104     data.ncfn = zeros(1,data.updt);
0105   end
0106 
0107   data.first = true;        % the next one will be the first call = 1
0108   data.initialized = false; % the graphical windows were not initalized
0109   
0110   new_data = data;
0111   
0112   return;
0113 
0114 else
0115 
0116 % If this is the first call ~= 0,
0117 % use YY and YYS for additional initializations
0118   
0119   if data.first
0120 
0121     if isempty(YYS)
0122       data.sensi = false;
0123     end
0124     
0125     if data.sol | data.sensi
0126       
0127       if isempty(data.select)
0128       
0129         data.N = length(YY);
0130         data.select = [1:data.N];
0131         
0132       else
0133         
0134         data.N = length(data.select);
0135         
0136       end
0137 
0138       if data.sol
0139         data.y = zeros(data.N,data.updt);
0140         data.nps = data.nps + 1;
0141       end
0142         
0143       if data.sensi
0144         data.Ns = size(YYS,2);
0145         data.ys = zeros(data.N, data.Ns, data.updt);
0146         data.nps = data.nps + data.Ns;
0147       end
0148       
0149     end
0150     
0151     data.first = false;
0152   
0153   end
0154   
0155 % Extract variables from data
0156 
0157   hfg  = data.hfg;
0158   hft  = data.hft;
0159   hfs  = data.hfs;
0160   npg  = data.npg;
0161   nps  = data.nps;
0162   i    = data.i;
0163   n    = data.n;
0164   t    = data.t;
0165   N    = data.N;
0166   Ns   = data.Ns;
0167   y    = data.y;
0168   ys   = data.ys;
0169   h    = data.h;
0170   q    = data.q;
0171   nst  = data.nst;
0172   nre  = data.nre;
0173   nni  = data.nni;
0174   netf = data.netf;
0175   ncfn = data.ncfn;
0176   
0177 end
0178 
0179 
0180 % Load current statistics?
0181 
0182 if call == 1
0183 
0184   if i ~= 0
0185     i = i-1;
0186     data.i = i;
0187     new_data = data;
0188     return;
0189   end
0190 
0191   if data.dir == 1
0192     si = IDAGetStats;
0193   else
0194     si = IDAGetStatsB;
0195   end
0196 
0197   t(n) = si.tcur;
0198   
0199   if data.stats
0200     h(n) = si.hlast;
0201     q(n) = si.qlast;
0202   end
0203   
0204   if data.cntr
0205     nst(n) = si.nst;
0206     nre(n) = si.nre;
0207     nni(n) = si.nni;
0208     netf(n) = si.netf;
0209     ncfn(n) = si.ncfn;
0210   end
0211 
0212   if data.sol
0213     for j = 1:N
0214       y(j,n) = YY(data.select(j));
0215     end
0216   end
0217 
0218   if data.sensi
0219     for k = 1:Ns
0220       for j = 1:N
0221         ys(j,k,n) = YYS(data.select(j),k);
0222       end
0223     end
0224   end
0225   
0226 end
0227 
0228 % Is it time to post?
0229 
0230 if data.post & (n == data.updt | call==2)
0231 
0232   if call == 2
0233     n = n-1;
0234   end
0235   
0236   if ~data.initialized
0237 
0238     if (data.stats | data.cntr) & data.grph
0239       graphical_init(n, hfg, npg, data.stats, data.cntr, data.dir, ...
0240                      t, h, q, nst, nre, nni, netf, ncfn, data.xaxis);
0241     end
0242     
0243     if (data.stats | data.cntr) & data.text
0244       text_init(n, hft, data.stats, data.cntr, ...
0245                 t, h, q, nst, nre, nni, netf, ncfn);
0246     end
0247 
0248     if data.sol | data.sensi
0249       sol_init(n, hfs, nps, data.sol, data.sensi, data.dir, data.xaxis, ...
0250                N, Ns, t, y, ys);
0251     end
0252     
0253     data.initialized = true;
0254   
0255   else
0256 
0257     if (data.stats | data.cntr) & data.grph
0258       graphical_update(n, hfg, npg, data.stats, data.cntr, ...
0259                        t, h, q, nst, nre, nni, netf, ncfn);
0260     end
0261 
0262     if (data.stats | data.cntr) & data.text
0263       text_update(n, hft, data.stats, data.cntr, ...
0264                   t, h, q, nst, nre, nni, netf, ncfn);
0265     end
0266     
0267     if data.sol
0268       sol_update(n, hfs, nps, data.sol, data.sensi, N, Ns, t, y, ys);
0269     end
0270       
0271   end
0272 
0273   if call == 2
0274     
0275     if (data.stats | data.cntr) & data.grph
0276       graphical_final(hfg, npg, data.cntr, data.stats);
0277     end
0278     
0279     if data.sol | data.sensi
0280       sol_final(hfs, nps, data.sol, data.sensi, N, Ns);
0281     end
0282 
0283     return;
0284   
0285   end
0286   
0287   n = 1;
0288 
0289 else
0290 
0291   n = n + 1;
0292 
0293 end
0294 
0295 
0296 % Save updated values in data
0297 
0298 data.i    = data.skip;
0299 data.n    = n;
0300 data.npg  = npg;
0301 data.t    = t;
0302 data.y    = y;
0303 data.ys   = ys;
0304 data.h    = h;
0305 data.q    = q;
0306 data.nst  = nst;
0307 data.nre  = nre;
0308 data.nni  = nni;
0309 data.netf = netf;
0310 data.ncfn = ncfn;
0311   
0312 new_data = data;
0313 
0314 return;
0315 
0316 %-------------------------------------------------------------------------
0317 
0318 function data = initialize_data(data)
0319 
0320 if ~isfield(data,'mode')
0321   data.mode = 'graphical';
0322 end
0323 if ~isfield(data,'updt')
0324   data.updt = 50;
0325 end
0326 if ~isfield(data,'skip')
0327   data.skip = 0;
0328 end
0329 if ~isfield(data,'stats')
0330   data.stats = true;
0331 end
0332 if ~isfield(data,'cntr')
0333   data.cntr = true;
0334 end
0335 if ~isfield(data,'sol')
0336   data.sol = false;
0337 end
0338 if ~isfield(data,'sensi')
0339   data.sensi = false;
0340 end
0341 if ~isfield(data,'select')
0342   data.select = [];
0343 end
0344 if ~isfield(data,'xaxis')
0345   data.xaxis = 'log';
0346 end
0347 if ~isfield(data,'dir')
0348   data.dir = 1;
0349 end
0350 if ~isfield(data,'post')
0351   data.post = true;
0352 end
0353 
0354 data.grph = true;
0355 data.text = true;
0356 if strcmp(data.mode,'graphical')
0357   data.text = false;
0358 end
0359 if strcmp(data.mode,'text')
0360   data.grph = false;
0361 end
0362 
0363 if ~data.sol & ~data.sensi
0364   data.select = [];
0365 end
0366   
0367 % Other initializations
0368 data.npg = 0;
0369 data.nps = 0;
0370 data.hfg = 0;
0371 data.hft = 0;
0372 data.hfs = 0;
0373 data.h = 0;
0374 data.q = 0;
0375 data.nst = 0;
0376 data.nre = 0;
0377 data.nni = 0;
0378 data.netf = 0;
0379 data.ncfn = 0;
0380 data.N = 0;
0381 data.Ns = 0;
0382 data.y = 0;
0383 data.ys = 0;
0384 
0385 %-------------------------------------------------------------------------
0386 
0387 function [] = graphical_init(n, hfg, npg, stats, cntr, dir, ...
0388                              t, h, q, nst, nre, nni, netf, ncfn, xaxis)
0389 
0390 fig_name = 'IDAS run statistics';
0391 
0392 % If this is a parallel job, look for the MPI rank in the global
0393 % workspace and append it to the figure name
0394 
0395 global sundials_MPI_rank
0396 
0397 if ~isempty(sundials_MPI_rank)
0398   fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
0399 end
0400 
0401 figure(hfg);
0402 set(hfg,'Name',fig_name);
0403 set(hfg,'color',[1 1 1]);
0404 pl = 0;
0405 
0406 % Time label and figure title
0407 
0408 if dir==1
0409   tlab = '\rightarrow   t   \rightarrow';
0410 else
0411   tlab = '\leftarrow   t   \leftarrow';
0412 end
0413 
0414 % Step size and order
0415 if stats
0416   pl = pl+1;
0417   subplot(npg,1,pl)
0418   semilogy(t(1:n),abs(h(1:n)),'-');
0419   if strcmp(xaxis,'log')
0420     set(gca,'XScale','log');
0421   end
0422   hold on;
0423   box on;
0424   grid on;
0425   xlabel(tlab);
0426   ylabel('|Step size|');
0427   
0428   pl = pl+1;
0429   subplot(npg,1,pl)
0430   plot(t(1:n),q(1:n),'-');
0431   if strcmp(xaxis,'log')
0432     set(gca,'XScale','log');
0433   end
0434   hold on;
0435   box on;
0436   grid on;
0437   xlabel(tlab);
0438   ylabel('Order');
0439 end
0440   
0441 % Counters
0442 if cntr
0443   pl = pl+1;
0444   subplot(npg,1,pl)
0445   plot(t(1:n),nst(1:n),'k-');
0446   hold on;
0447   plot(t(1:n),nre(1:n),'b-');
0448   plot(t(1:n),nni(1:n),'r-');
0449   plot(t(1:n),netf(1:n),'g-');
0450   plot(t(1:n),ncfn(1:n),'c-');
0451   if strcmp(xaxis,'log')
0452     set(gca,'XScale','log');
0453   end
0454   box on;
0455   grid on;
0456   xlabel(tlab);
0457   ylabel('Counters');
0458 end
0459 
0460 drawnow;
0461 
0462 %-------------------------------------------------------------------------
0463 
0464 function [] = graphical_update(n, hfg, npg, stats, cntr, ...
0465                                t, h, q, nst, nre, nni, netf, ncfn)
0466 
0467 figure(hfg);
0468 pl = 0;
0469   
0470 % Step size and order
0471 if stats
0472   pl = pl+1;
0473   subplot(npg,1,pl)
0474   hc = get(gca,'Children');
0475   xd = [get(hc,'XData') t(1:n)];
0476   yd = [get(hc,'YData') abs(h(1:n))];
0477   set(hc, 'XData', xd, 'YData', yd);
0478   
0479   pl = pl+1;
0480   subplot(npg,1,pl)
0481   hc = get(gca,'Children');
0482   xd = [get(hc,'XData') t(1:n)];
0483   yd = [get(hc,'YData') q(1:n)];
0484   set(hc, 'XData', xd, 'YData', yd);
0485 end
0486 
0487 % Counters
0488 if cntr
0489   pl = pl+1;
0490   subplot(npg,1,pl)
0491   hc = get(gca,'Children');
0492 % Attention: Children are loaded in reverse order!
0493   xd = [get(hc(1),'XData') t(1:n)];
0494   yd = [get(hc(1),'YData') ncfn(1:n)];
0495   set(hc(1), 'XData', xd, 'YData', yd);
0496   yd = [get(hc(2),'YData') netf(1:n)];
0497   set(hc(2), 'XData', xd, 'YData', yd);
0498   yd = [get(hc(3),'YData') nni(1:n)];
0499   set(hc(3), 'XData', xd, 'YData', yd);
0500   yd = [get(hc(4),'YData') nre(1:n)];
0501   set(hc(4), 'XData', xd, 'YData', yd);
0502   yd = [get(hc(5),'YData') nst(1:n)];
0503   set(hc(5), 'XData', xd, 'YData', yd);
0504 end
0505 
0506 drawnow;
0507 
0508 %-------------------------------------------------------------------------
0509 
0510 function [] = graphical_final(hfg,npg,stats,cntr)
0511 
0512 figure(hfg);
0513 pl = 0;
0514 
0515 if stats
0516   pl = pl+1;
0517   subplot(npg,1,pl)
0518   hc = get(gca,'Children');
0519   xd = get(hc,'XData');
0520   set(gca,'XLim',sort([xd(1) xd(end)]));
0521   
0522   pl = pl+1;
0523   subplot(npg,1,pl)
0524   ylim = get(gca,'YLim');
0525   ylim(1) = ylim(1) - 1;
0526   ylim(2) = ylim(2) + 1;
0527   set(gca,'YLim',ylim);
0528   set(gca,'XLim',sort([xd(1) xd(end)]));
0529 end
0530 
0531 if cntr
0532   pl = pl+1;
0533   subplot(npg,1,pl)
0534   hc = get(gca,'Children');
0535   xd = get(hc(1),'XData');
0536   set(gca,'XLim',sort([xd(1) xd(end)]));
0537   legend('nst','nre','nni','netf','ncfn',2);
0538 end
0539 
0540 %-------------------------------------------------------------------------
0541 
0542 function [] = text_init(n,hft,stats,cntr,t,h,q,nst,nre,nni,netf,ncfn)
0543 
0544 fig_name = 'IDAS run statistics';
0545 
0546 % If this is a parallel job, look for the MPI rank in the global
0547 % workspace and append it to the figure name
0548 
0549 global sundials_MPI_rank
0550 
0551 if ~isempty(sundials_MPI_rank)
0552   fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
0553 end
0554 
0555 figure(hft);
0556 set(hft,'Name',fig_name);
0557 set(hft,'color',[1 1 1]);
0558 set(hft,'MenuBar','none');
0559 set(hft,'Resize','off');
0560 
0561 % Create text box
0562 
0563 margins=[10 10 50 50]; % left, right, top, bottom
0564 pos=get(hft,'position');
0565 tbpos=[margins(1) margins(4) pos(3)-margins(1)-margins(2) ...
0566        pos(4)-margins(3)-margins(4)];
0567 tbpos(tbpos<1)=1;
0568 
0569 htb=uicontrol(hft,'style','listbox','position',tbpos,'tag','textbox');
0570 set(htb,'BackgroundColor',[1 1 1]);
0571 set(htb,'SelectionHighlight','off');
0572 set(htb,'FontName','courier');
0573 
0574 % Create table head
0575 
0576 tpos = [tbpos(1) tbpos(2)+tbpos(4)+10 tbpos(3) 20];
0577 ht=uicontrol(hft,'style','text','position',tpos,'tag','text');
0578 set(ht,'BackgroundColor',[1 1 1]);
0579 set(ht,'HorizontalAlignment','left');
0580 set(ht,'FontName','courier');
0581 newline = '   time         step      order  |    nst   nre   nni  netf  ncfn';
0582 set(ht,'String',newline);
0583 
0584 % Create OK button
0585   
0586 bsize=[60,28];
0587 badjustpos=[0,25];
0588 bpos=[pos(3)/2-bsize(1)/2+badjustpos(1) -bsize(2)/2+badjustpos(2)...
0589       bsize(1) bsize(2)];
0590 bpos=round(bpos);
0591 bpos(bpos<1)=1;
0592 hb=uicontrol(hft,'style','pushbutton','position',bpos,...
0593              'string','Close','tag','okaybutton');
0594 set(hb,'callback','close');
0595 
0596 % Save handles
0597 
0598 handles=guihandles(hft);
0599 guidata(hft,handles);
0600 
0601 for i = 1:n
0602   newline = '';
0603   if stats
0604     newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
0605   end
0606   if cntr
0607     newline = sprintf('%s %5d %5d %5d %5d %5d',...
0608                       newline,nst(i),nre(i),nni(i),netf(i),ncfn(i));
0609   end
0610   string = get(handles.textbox,'String');
0611   string{end+1}=newline;
0612   set(handles.textbox,'String',string);
0613 end
0614 
0615 drawnow
0616 
0617 %-------------------------------------------------------------------------
0618 
0619 function [] = text_update(n,hft,stats,cntr,t,h,q,nst,nre,nni,netf,ncfn)
0620 
0621 figure(hft);
0622 
0623 handles=guidata(hft);
0624 
0625 for i = 1:n
0626    if stats
0627     newline = sprintf('%10.3e   %10.3e     %1d    |',t(i),h(i),q(i));
0628   end
0629   if cntr
0630     newline = sprintf('%s %5d %5d %5d %5d %5d',...
0631                       newline,nst(i),nre(i),nni(i),netf(i),ncfn(i));
0632   end
0633   string = get(handles.textbox,'String');
0634   string{end+1}=newline;
0635   set(handles.textbox,'String',string);
0636 end
0637 
0638 drawnow
0639 
0640 %-------------------------------------------------------------------------
0641 
0642 function [] = sol_init(n, hfs, nps, sol, sensi, dir, xaxis, N, Ns, t, y, ys)
0643 
0644 fig_name = 'IDAS solution';
0645 
0646 % If this is a parallel job, look for the MPI rank in the global
0647 % workspace and append it to the figure name
0648 
0649 global sundials_MPI_rank
0650 
0651 if ~isempty(sundials_MPI_rank)
0652   fig_name = sprintf('%s (PE %d)',fig_name,sundials_MPI_rank);
0653 end
0654 
0655 
0656 figure(hfs);
0657 set(hfs,'Name',fig_name);
0658 set(hfs,'color',[1 1 1]);
0659 
0660 % Time label
0661 
0662 if dir==1
0663   tlab = '\rightarrow   t   \rightarrow';
0664 else
0665   tlab = '\leftarrow   t   \leftarrow';
0666 end
0667 
0668 % Get number of colors in colormap
0669 map = colormap;
0670 ncols = size(map,1);
0671 
0672 % Initialize current subplot counter
0673 pl = 0;
0674 
0675 if sol
0676 
0677   pl = pl+1;
0678   subplot(nps,1,pl);
0679   hold on;
0680 
0681   for i = 1:N
0682     hp = plot(t(1:n),y(i,1:n),'-');
0683     ic = 1+(i-1)*floor(ncols/N);
0684     set(hp,'Color',map(ic,:));
0685   end
0686   if strcmp(xaxis,'log')
0687     set(gca,'XScale','log');
0688   end
0689   box on;
0690   grid on;
0691   xlabel(tlab);
0692   ylabel('y');
0693   title('Solution');
0694 
0695 end
0696 
0697 if sensi
0698   
0699   for is = 1:Ns
0700     
0701     pl = pl+1;
0702     subplot(nps,1,pl);
0703     hold on;
0704       
0705     ys_crt = ys(:,is,1:n);
0706     for i = 1:N
0707       hp = plot(t(1:n),ys_crt(i,1:n),'-');
0708       ic = 1+(i-1)*floor(ncols/N);
0709       set(hp,'Color',map(ic,:));
0710     end
0711     if strcmp(xaxis,'log')
0712       set(gca,'XScale','log');
0713     end
0714     box on;
0715     grid on;
0716     xlabel(tlab);
0717     str = sprintf('s_{%d}',is); ylabel(str);
0718     str = sprintf('Sensitivity %d',is); title(str);
0719     
0720   end
0721   
0722 end
0723 
0724 
0725 drawnow;
0726 
0727 %-------------------------------------------------------------------------
0728 
0729 function [] = sol_update(n, hfs, nps, sol, sensi, N, Ns, t, y, ys)
0730 
0731 figure(hfs);
0732 
0733 pl = 0;
0734 
0735 if sol
0736   
0737   pl = pl+1;
0738   subplot(nps,1,pl);
0739   
0740   hc = get(gca,'Children');
0741   xd = [get(hc(1),'XData') t(1:n)];
0742 % Attention: Children are loaded in reverse order!
0743   for i = 1:N
0744     yd = [get(hc(i),'YData') y(N-i+1,1:n)];
0745     set(hc(i), 'XData', xd, 'YData', yd);
0746   end
0747 
0748 end
0749   
0750 if sensi
0751   
0752   for is = 1:Ns
0753     
0754     pl = pl+1;
0755     subplot(nps,1,pl);
0756 
0757     ys_crt = ys(:,is,:);
0758     
0759     hc = get(gca,'Children');
0760     xd = [get(hc(1),'XData') t(1:n)];
0761 %   Attention: Children are loaded in reverse order!
0762     for i = 1:N
0763       yd = [get(hc(i),'YData') ys_crt(N-i+1,1:n)];
0764       set(hc(i), 'XData', xd, 'YData', yd);
0765     end
0766     
0767   end
0768   
0769 end
0770 
0771 
0772 drawnow;
0773 
0774 
0775 %-------------------------------------------------------------------------
0776 
0777 function [] = sol_final(hfs, nps, sol, sensi, N, Ns)
0778 
0779 figure(hfs);
0780 
0781 pl = 0;
0782 
0783 if sol
0784 
0785   pl = pl +1;
0786   subplot(nps,1,pl);
0787   
0788   hc = get(gca,'Children');
0789   xd = get(hc(1),'XData');
0790   set(gca,'XLim',sort([xd(1) xd(end)]));
0791 
0792   ylim = get(gca,'YLim');
0793   addon = 0.1*abs(ylim(2)-ylim(1));
0794   ylim(1) = ylim(1) + sign(ylim(1))*addon;
0795   ylim(2) = ylim(2) + sign(ylim(2))*addon;
0796   set(gca,'YLim',ylim);
0797   
0798   for i = 1:N
0799     cstring{i} = sprintf('y_{%d}',i);
0800   end
0801   legend(cstring);
0802   
0803 end
0804 
0805 if sensi
0806   
0807   for is = 1:Ns
0808     
0809     pl = pl+1;
0810     subplot(nps,1,pl);
0811 
0812     hc = get(gca,'Children');
0813     xd = get(hc(1),'XData');
0814     set(gca,'XLim',sort([xd(1) xd(end)]));
0815 
0816     ylim = get(gca,'YLim');
0817     addon = 0.1*abs(ylim(2)-ylim(1));
0818     ylim(1) = ylim(1) + sign(ylim(1))*addon;
0819     ylim(2) = ylim(2) + sign(ylim(2))*addon;
0820     set(gca,'YLim',ylim);
0821   
0822     for i = 1:N
0823       cstring{i} = sprintf('s%d_{%d}',is,i);
0824     end
0825     legend(cstring);
0826     
0827   end
0828   
0829 end
0830 
0831 drawnow
Generated on Thu 05-Oct-2006 15:57:32 by m2html © 2003