%% Make the introductory figure.
if ~exist('Figures','dir') mkdir Figures; end

load('Data/VER_S_1_SG_230_gamma_5_m_0.35.mat')

[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
ShowLevel(-Esol,1,m,[35 25]);
text(1,3,-2.5,'(a)','FontSize',32);
drawnow;

h = gcf;
saveas(h,'Figures/DGIntro.fig');
saveas(h,'Figures/DGIntro.png');

load('Data/VER_S_1_SG_229_gamma_5_m_0.35.mat')

[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(2);clf;
ShowLevel(-Esol,1,m,[70 15]);
text(1,3,-2,'(b)','FontSize',32);
drawnow;

h = gcf;
saveas(h,'Figures/BCCIntro.fig');
saveas(h,'Figures/BCCIntro.png');
%% Make first row of double gyroids solutions.
load('Data/VER_S_1_SG_230_gamma_2.1_m_0.02.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);clf;
subplot(1,4,1);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(a)','FontSize',12);

load('Data/VER_S_1_SG_230_gamma_3_m_0.04.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,2);
ShowLevel(-Esol,ell,m,[-25,25]);
title('(b)','FontSize',12);

load('Data/VER_S_1_SG_230_gamma_4_m_0.05.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,3);
ShowLevel(-Esol,ell,m,[-30,30]);
title('(c)','FontSize',12);

load('Data/VER_S_1_SG_230_gamma_5_m_0.06.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,4);
ShowLevel(-Esol,ell,m,[-40,40]);
title('(d)','FontSize',12);

% save figure
h = gcf;
saveas(h,'Figures/DG1.fig');
print('-dpng','-r600','Figures/DG1.png')

%% Make second row of double gyroids.
load('Data/VER_S_1_SG_230_gamma_2.1_m_0.1.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);clf;
subplot(1,4,1);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(e)','FontSize',12);

load('Data/VER_S_1_SG_230_gamma_3_m_0.25.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,2);
ShowLevel(-Esol,ell,m,[-25,25]);
title('(f)','FontSize',12);

load('Data/VER_S_1_SG_230_gamma_4_m_0.3.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,3);
ShowLevel(-Esol,ell,m,[-30,30]);
title('(g)','FontSize',12);

load('Data/VER_S_1_SG_230_gamma_5_m_0.35.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,4);
ShowLevel(-Esol,ell,m,[-40,40]);
title('(h)','FontSize',12);

% save the figure.
h = gcf;
saveas(h,'Figures/DG2.fig');
print('-dpng','-r600','Figures/DG2.png')
% saveas(h,'Figures/DG2.png');

%% Make first row of bcc solutions.
load('Data/VER_S_1_SG_229_gamma_2.1_m_0.02.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);clf
subplot(1,4,1);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(a)','FontSize',12);

load('Data/VER_S_1_SG_229_gamma_3_m_0.04.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,2);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(b)','FontSize',12);

load('Data/VER_S_1_SG_229_gamma_4_m_0.05.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,3);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(c)','FontSize',12);

load('Data/VER_S_1_SG_229_gamma_5_m_0.06.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,4);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(d)','FontSize',12);

% Save the figure.
h = gcf;
saveas(h,'Figures/BCC1.fig');
print('-dpng','-r600','Figures/BCC1.png')

%% Make second row of bcc spheres.
load('Data/VER_S_1_SG_229_gamma_2.1_m_0.1.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);clf;
subplot(1,4,1);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(e)','FontSize',12);

load('Data/VER_S_1_SG_229_gamma_3_m_0.25.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,2);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(f)','FontSize',12);

load('Data/VER_S_1_SG_229_gamma_4_m_0.3.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,3);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(g)','FontSize',12);

load('Data/VER_S_1_SG_229_gamma_5_m_0.35.mat')
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);

figure(1);
subplot(1,4,4);
ShowLevel(-Esol,ell,m,[-20,20]);
title('(h)','FontSize',12);

%save figure.
h = gcf;
saveas(h,'Figures/BCC2.fig');
print('-dpng','-r600','Figures/BCC2.png')

%% Make exotic profiles
load Data/BumpyCyls_ver.mat

SGind = 230;
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);
figure(1);clf;
ShowLevel(-Esol,ell,-m/2,[20 15]);
drawnow;

h = gcf;
saveas(h,'Figures/BumpyCyls.fig');
print('-dpng','-r600','Figures/BumpyCyls.png')

load Data/Lozenges_ver.mat
SGind = 230;
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);
figure(1);clf;
ShowLevel(-Esol,ell,m/2,[50 20]);
drawnow;

h = gcf;
saveas(h,'Figures/Lozenges.fig');
print('-dpng','-r600','Figures/Lozenges.png')

load Data/Pipes_Balls_ver.mat
SGind = 230;
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);
figure(1);clf;
ShowLevel(-Esol,ell,m,[60 10]);
drawnow;

h = gcf;
saveas(h,'Figures/PipesBalls.fig');
print('-dpng','-r600','Figures/PipesBalls.png')

load Data/RightDG_ver.mat
SGind = 230;
[~,~,~,~,Esol] = FDF(sol,gamma,m,ell,K,SGind);
figure(1);clf;
ShowLevel(-Esol,ell,m,[50 25]);
drawnow;

h = gcf;
saveas(h,'Figures/RightDG.fig');
print('-dpng','-r600','Figures/RightDG.png')