%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Name: go.m
% Author: J. Kristoffer Hultgren
%
% Description:
%
% Plots the plasma environment in a given plane at a given heliocentric
% distance.
% Requires the Hybrid model compiled on disk. MHD and DSMC models should
% be run in GUI.
%
% Input:  -
%
% Output: -
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function go()

heli = input('What heliocentric distance do you want to model? (1.3/2.0/2.7/3.3): ', 's');

plane = input('Which plane is zero? (x/y/z): ', 's');

lim = input('Out to what distance do you want to model? (km) ');

disp('Creates data points...')

wholeSpace(plane,lim);  % Creates a text file with coordinates of all points

disp('Run space.dat in GUI for DSMC and MHD models, save model output in simu/, then press any key to continue.')
pause

disp('Running Hybrid model...')

if strcmp(heli,'1.3')
    
    % Runs Hybrid model
    !./ICES.pl space.dat CG_1.3_au simu HYB
    
    % Removes text lines
    !sed -i '1,34d' simu/Hybrid_CG_1.3_au.dat        
    !sed -i '1,3d' simu/DSMC_CG_1.3_au.dat
    !sed -i '1,3d' simu/MHD_CG_1.3_au.dat
    
    % Renaming for compatibility
    !mv simu/Hybrid_CG_1.3_au.dat simu/Hybrid13.dat
    !mv simu/DSMC_CG_1.3_au.dat simu/DSMC13.dat
    !mv simu/MHD_CG_1.3_au.dat simu/MHD13.dat

    load('simu/DSMC13.dat');
    plotDSMCPlane(DSMC13,heli);
    
    load('simu/Hybrid13.dat');
    plotHybridPlane(Hybrid13,heli); 
    
    load('simu/MHD13.dat');
    plotMHDPlane(MHD13,heli); 
        
end

if strcmp(heli,'2.0')
    
    % Runs Hybrid model
    !./ICES.pl space.dat CG_2.0_au simu HYB
    
    % Removes text lines
    !sed -i '1,34d' simu/Hybrid_CG_2.0_au.dat
    !sed -i '1,3d' simu/DSMC_CG_2.0_au.dat
    !sed -i '1,3d' simu/MHD_CG_2.0_au.dat
    
    % Renaming for compatibility
    !mv simu/Hybrid_CG_2.0_au.dat simu/Hybrid20.dat
    !mv simu/DSMC_CG_2.0_au.dat simu/DSMC20.dat
    !mv simu/MHD_CG_2.0_au.dat simu/MHD20.dat

    load('simu/DSMC20.dat');
    plotDSMCPlane(DSMC20,heli);
    
    load('simu/Hybrid20.dat');
    plotHybridPlane(Hybrid20,heli); 
    
    load('simu/MHD20.dat');
    plotMHDPlane(MHD20,heli); 
    
end

if strcmp(heli,'2.7')
    
    % Runs Hybrid model
    !./ICES.pl space.dat CG_2.7_au simu HYB
    
    % Removes text lines
    !sed -i '1,34d' simu/Hybrid_CG_2.7_au.dat
    !sed -i '1,3d' simu/DSMC_CG_2.7_au.dat
    !sed -i '1,3d' simu/MHD_CG_2.7_au.dat
    
    % Renaming for compatibility
    !mv simu/Hybrid_CG_2.7_au.dat simu/Hybrid27.dat
    !mv simu/DSMC_CG_2.7_au.dat simu/DSMC27.dat
    !mv simu/MHD_CG_2.7_au.dat simu/MHD27.dat

    load('simu/DSMC27.dat');
    plotDSMCPlane(DSMC27,heli);
    
    load('simu/Hybrid27.dat');
    plotHybridPlane(Hybrid27,heli); 
    
    load('simu/MHD27.dat');
    plotMHDPlane(MHD27,heli);
    
end

if strcmp(heli,'3.3')
    
    % Runs Hybrid model
    !./ICES.pl space.dat CG_3.3_au simu HYB
    
    % Removes text lines
    !sed -i '1,34d' simu/Hybrid_CG_3.3_au.dat
    !sed -i '1,3d' simu/DSMC_CG_3.3_au.dat
    !sed -i '1,3d' simu/MHD_CG_3.3_au.dat
    
    % Renaming for compatibility
    !mv simu/Hybrid_CG_3.3_au.dat simu/Hybrid33.dat
    !mv simu/DSMC_CG_3.3_au.dat simu/DSMC33.dat
    !mv simu/MHD_CG_3.3_au.dat simu/MHD33.dat

    load('simu/DSMC33.dat');
    plotDSMCPlane(DSMC33,heli);
    
    load('simu/Hybrid33.dat');
    plotHybridPlane(Hybrid33,heli); 
    
    load('simu/MHD33.dat');
    plotMHDPlane(MHD33,heli); 
    
end

disp('Finished!')
