% Copyright 1997 Thomas Mc Avoy
% routine to determine which inner casacde loop to bump test
function [d,k,titl,titl1]=whicas
disp('THE FOLLOWING VALVES CAN BE BUMP TESTED. PLEASE CHOOSE ONE OF THEM') 
	disp(' ')
	disp('	VALVE-1: THE D-FEED FLOW VALVE')
	disp('	VALVE-2: THE E-FEED FLOW VALVE')
	disp('	VALVE-3: THE A-FEED FLOW VALVE') 
	disp('	VALVE-4: THE C-FEED FLOW VALVE')
	disp('	VALVE-6: THE PURGE FLOW VALVE')
	disp('	VALVE-7: THE SEPARATOR EXIT FLOW VALVE')
	disp('	VALVE-8: THE PRODUCT FLOW VALVE')
	disp('	VALVE-9: THE STEAM FLOW VALVE')
	disp('	VALVE-10: THE REACTOR CW TEMP VALVE')
	disp('	VALVE-11: THE CONDENSER CW TEMP VALVE')
	disp(' ')
check=0; 
while check==0
	disp(' ')
	k=input ('INPUT WHICH VALVE IS TO BE BUMP TESTED: ');
	while (isempty(k)==1)
		disp('PLEASE ENTER VALVE AGAIN. ')
		d=input ('INPUT WHICH VALVE IS TO BE BUMP TESTED: ');
	end

	if k>12|k<1
		disp('YOUR SELECTION IS OUTSIDE THE RANGE 1 TO 12')
		s=sprintf('FOR A BUMP TEST YOU SELECTED VALVE %3.0f',k);
		disp(s)
		disp(' ')
		disp('PLEASE START OVER')
	end
	if k==5|k==12
		s=sprintf('YOU SELECTED VALVE %3.0f',k);
		disp(s)
		disp('THIS IS NOT A VALID CHOICE FOR AN INNER CASCADE')
		disp(' ')
		disp('PLEASE START OVER')
	else
		if k==10
		disp('NOTE - THIS LOOP SHOULD BE CLOSED FOR TUNING')
		end

	check=1;
	end
end
		if k==1
		disp('THE D-FEED VALVE WILL BE PERTURBED - MV#1')
		titl='D-Feed Flow';
		elseif k==2
		disp('THE E-FEED VALVE WILL BE PERTURBED - MV#2')
		titl='E-Feed Flow';
		elseif k==3
		disp('THE A-FEED VALVE WILL BE PERTURBED - MV#3')
		titl='A-Feed Flow';
		elseif k==4
		disp('THE C-FEED VALVE WILL BE PERTURBED - MV#4')
		titl='C-Feed Flow';
		elseif k==6
		disp('THE PURGE VALVE WILL BE PERTURBED - MV#6')
		titl='Purge Flow';
		elseif k==7
		disp('THE SEPARATOR UNDERFLOW VALVE WILL BE PERTURBED - MV#7')
		titl='Separator Exit Flow';
		elseif k==8
		disp('THE PRODUCT VALVE WILL BE PERTURBED - MV#8')
		titl='Product Flow';
		elseif k==9
		disp('THE STEAM VALVE WILL BE PERTURBED - MV#9')
		titl='Steam Flow';
		elseif k==10
		titl='Reactor CW Temp';
		elseif k==11
		disp('THE CONDENSER COOLING WATER VALVE WILL BE PERTURBED - MV#11')
		titl='Condenser CW Temp';
		end
	disp(' ')
loop=0;
while loop==0
	d=input ('INPUT PERCENT (UP TO 5%) PERTURBATION STEP: ');
	while (isempty(d)==1)
		disp('PLEASE ENTER % PERTURBATION (UP TO 5%) AGAIN. ')
		d=input ('INPUT PERCENT (%) PERTURBATION STEP: ');
	end
	if (d>5|d<0)          % Only 5% steps or less allowed
       disp(' ')
       disp('NOT A VALID SELECTION, PERTURBATION TOO LARGE') 
	   disp('PLEASE START OVER')
       disp('PRESS ENTER TO CONTINUE AND INPUT % PERTURBATION')
       pause;
	else;
		d=d/100;
		loop=1;
	end
end

titl1=sprintf('Bump Percent = %4.1f',100*d);
