% Copyright (c) 2015, Lennon O'Naraigh
% All rights reserved.
% 
% Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
% 
% 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
% 
% 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer 
% in the documentation and/or other materials provided with the distribution.
% 
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
% INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
% IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 
% OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
% OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
% OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
% EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

% April 2015.  Solves the Orr-Sommerfeld equation for single-phase
% Poiseuille flow in a CHANNEL.

function [alpha,lambda1,lambda2]=main_temporal()

[u_vec1,ddu_vec1,~]=get_u();


% [lambda,L,M]=OS_solver(alpha_param,u_vec1,ddu_vec1);


% **************************************************************************

alpha=0:0.0001:0.005;
display(length(alpha));

sizezero=0*(1:length(alpha));
lambda1=sizezero;
lambda2=sizezero;
lambda3=sizezero;
lambda4=sizezero;
lambda5=sizezero;
lambda6=sizezero;
lambda7=sizezero;
lambda8=sizezero;
lambda9=sizezero;
lambda10=sizezero;

for i=1:length(alpha)
        alpha_param=alpha(i);
        [lambda,~,~]=OS_solver(alpha_param,u_vec1,ddu_vec1);
        [~,ix]=max(real(lambda));
        v1=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v2=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v3=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v4=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v5=lambda(ix);
        lambda(ix)=-1000;

        [~,ix]=max(real(lambda));
        v6=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v7=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v8=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v9=lambda(ix);
        lambda(ix)=-1000;
        [~,ix]=max(real(lambda));
        v10=lambda(ix);
        
        lambda1(i)=v1;
        lambda2(i)=v2;
        lambda3(i)=v3;
        lambda4(i)=v4;
        lambda5(i)=v5;
        lambda6(i)=v6;
        lambda7(i)=v7;
        lambda8(i)=v8;
        lambda9(i)=v9;
        lambda10(i)=v10;
        
        display(i)
end

end




