%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Chapter 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%         For plotting the graphs and calculating some complex            %
%               expressions represented in Chapter 3                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Figure 2
% graph 2.1

clc
clear all

x=[0:0.005:1]; %dimensionless length
c=345;q=345*sqrt(3);A=1; %values of constants

Xi=((A^2-q^2/c^2)*x.^2+2*A.*x+1).^2; %dimensionless temperature

p=plot(x,Xi)
ylim([0 2.5])
set(gca, 'FontSize', 13)
title('$c_A = 345$ ms$^{-1}$, $|r| = 597.558$ s$^{-1}$, $A = 1$ m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig2_1.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);

%% graph 2.2

clc
clear all

x=[0:0.005:1];
c=345;q=172.5;A=-1/120;

Xi=((A^2-q^2/c^2)*x.^2+2*A.*x+1).^2;

p=plot(x,Xi)
ylim([0 1.3])
set(gca, 'FontSize', 13)
title('$c_A = 345$ ms$^{-1}$, $|r| = 172.5$ s$^{-1}$, $A = - 0.008$ m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold')
set(p,'LineWidth',2.5)

matlab2tikz('fig2_2.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);

%% graph 2.3

clc
clear all

x=[0:0.005:1];
c=345;q=345*sqrt(10.25-3*sqrt(10));A=sqrt(10)-2.5;

Xi=((A^2-q^2/c^2)*x.^2+2*A.*x+1).^2;
p=plot(x,Xi)
ylim([0 4.5])
set(gca, 'FontSize', 13) 
title('$c_A = 345$ ms$^{-1}$, $|r| = 301.39$ s$^{-1}$, $A = 0.662$ m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold')
set(p,'LineWidth',2.5)

matlab2tikz('fig2_3.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);
                   
%% graph 2.4

clc
clear all

x=[0:0.005:1];
c=345;q=sqrt(33-24*sqrt(2));A=-5/2+2*sqrt(2);

Xi=((A^2-q^2/c^2)*x.^2+2*A.*x+1).^2;

p=plot(x,Xi)
ylim([0 3.5])
set(gca, 'FontSize', 13) 
title('$c_A = 345$ ms$^{-1}$, $|r| = 0.97$ s$^{-1}$, $A = 0.328$ m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig2_4.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);
                   
%% calculation of variable \eta in expression (3.30)
clear all
clc
syms c_A A q x k % where k=A^2-r^2/c_A^2
fun=1/(k*x^2+2*A*x+1);
pretty(fun)
n=1/c_A *int(fun)
pretty(n)

%% Figure 3
% graph 3.1

clc
clear all

x=[0:0.005:1];
q=1;

Xi=(q*x+1).^2;

p=plot(x,Xi)
ylim([0 4.2])
set(gca, 'FontSize', 13)
title('$q$ = 1 m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig3_1.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);

%% graph 3.2

clc
clear all

x=[0:0.005:1];
q=-1/2;

Xi=(q*x+1).^2;

p=plot(x,Xi)
ylim([0 1.3])
set(gca, 'FontSize', 13)
title('$q$ = - 0.5 m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig3_2.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);
                   
%% calculation of variable \eta in expression (3.51)                  
                   
clear all
clc
syms c_A q x 
fun=1/(c_A*(q*x+1));
n=int(fun);
pretty(n)

%% Figure 4 Linear temperature distribution
% graph 4.1

clc
clear all

x=[0:0.005:1];
A=1;

Xi=A*x+1;

p=plot(x,Xi)
ylim([0 2.3])
set(gca, 'FontSize', 13)
title('$A$ = 1 m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig4_1.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);

%% graph 4.2

clc
clear all

x=[0:0.005:1];
A=-1/2;

Xi=A*x+1;

p=plot(x,Xi)
ylim([0 1.2])
set(gca, 'FontSize', 13)
title('$A$ = - 0.5 m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig4_2.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);

%% Figure 5 Exponential temperature distribution 
% graph 5.1 

clc
clear all

x=[0:0.005:1];
A=-log(3);

Xi=exp(-A*x);

p=plot(x,Xi);
ylim([0 3.3])
set(gca, 'FontSize', 13)
title('$\gamma$ = - $\ln{3}$ m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig5_1.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);

%% graph 5.2

clc
clear all

x=[0:0.005:1];
A=-log(0.5);

Xi=exp(-A*x);

p=plot(x,Xi);
ylim([0 1.2])
set(gca, 'FontSize', 13)
title('$\gamma$ = - $\ln{0.5}$ m$^{-1}$','Interpreter','latex','fontsize',17,'fontweight','bold')
xlabel('\sigma','FontWeight','bold')
ylabel('\Xi','FontWeight','bold') 
set(p,'LineWidth',2.5)

matlab2tikz('fig5_2.tikz', ...
   'extraaxisoptions',['title style={font=\Large},'...
                       'xlabel style={font=\Large},'...
                       'ylabel style={font=\Large},',...
                       'legend style={font=\scshape},']);