%
% Example 6.2: Test Point Spacing
%
% State Variable Operating Space Surfaces
% Process is Carbon Removal Process (Appendix 2)
%
% Bob Newell, March 1996
%-----------------------------------------------------------
% parameters
muhat = 3.733;
Ks = 20;
Koh = 0.2;
Yh = 0.6;
bh = 0.4;
fp = 0.1;
a = 166;
b = 16;
So_sat = 10;
air = 6.3;
waste = 1.615;
%
global p
p = [ muhat Ks Koh Yh bh fp a b So_sat air waste ];
%-----------------------------------------------------------
% initial states
V = 12.5;
Ss = 4.4;
So = 3;
Xh = 850;
%
xo = [ V Ss So Xh ];
%-----------------------------------------------------------
% Operating Space Surfaces
%
% Operating space grid is:
qw = (1:11) * 0.2;
qa = (1:11) + 2;
%
n = length( qa );
t = clock;
data = zeros( n, 3*n );
for i = 1:n,
  for j = 1:n,
% set up the grid values
    p(11) = qw(j) ;
    p(10) = qa(i) ;
	disp( [ 'Air = ' num2str(p(10)) ...
	       '  Wastage = ' num2str(p(11)) ] );
% calculate the states
    x = fmins( 'Objective_Function', xo(2:4) );
	data(i,j) = x(1) ;
	data(i,j+n) = x(2) ;
	data(i,j+2*n) = x(3) ;
	disp( [ num2str(n*(i-1)+j) ', Ss= ' num2str( x(1) ) ...
	            ', So= ' num2str( x(2) ) ...
			    ', Xh= ' num2str( x(3) ) ] ) ;
  end ;
end ;
secs = etime( clock, t )
%save surf.dat data -ascii
%
fontsz = 16;
figure
mesh( qw, qa, data(:,1:n) )
set( gca, 'fontsize', fontsz );
sxlabel( '{\times \28 \it q_W}' );
sylabel( '{\times \28 \it q_A}' );
szlabel( '{\times \28 \it S_S}' )
figure
mesh( qw, qa, data(:,n+1:2*n) )
set( gca, 'fontsize', fontsz );
sxlabel( '{\times \28 \it q_W}' );
sylabel( '{\times \28 \it q_A}' );
szlabel( '{\times \28 \it S_O}' )
%title( 'State So' )
%figure
%mesh( qw, qa, data(:,2*n+1:3*n) )
%set( gca, 'fontsize', fontsz );
%title( 'State Xh' )
%
printsto -f1 -deps2 ex6-3a.eps
printsto -f2 -deps2 ex6-3b.eps
%

