% FEAcomp. Solution of Example 7.5.
% J.A. Mayugo & E.J. Barbero (c) 2006, 2007, 2013

clear all; close all;

% FEA solution 
% time, 0 lamina stress, 90 lamina stress displacement
FEsolu =    [ 0     469.550       53.9553      0.112791    
   30.000         579.451       40.1664      0.140264    
   60.000         675.128       28.1693      0.164355    
   90.000         749.855       18.8051      0.183326    
   120.00         803.397       12.0983      0.197072    
   150.00         839.428       7.58589      0.206475    
   180.00         862.660       4.67655      0.212695    
   210.00         877.230       2.85205      0.216754    
   240.00         886.208       1.72771      0.219415    
   270.00         891.680       1.04231      0.221198    
   300.00         894.994      0.627239      0.222439]; 

[m,n]=size (FEsolu');

num_layer_0=1
num_layer_90=8

time  = FEsolu(:,1)';
str_0 = FEsolu(:,2)';
str_90 = FEsolu(:,3)';

str_tot = 100 .*str_0./str_0;  
strain =  [FEsolu(:,4)./25]';

Ex_tot = str_tot./strain;
Ex_0   = str_0./strain;
Ex_90  = str_90./strain;

f1=figure;
linewth  = 1.4;
[AX,H1,H2] = plotyy(time,str_0,time,str_90,'plot');
plot(time,str_0,'k','LineWidth',linewth,'MarkerSize',10);   
hold on
plot(time,str_90.*20,'k','LineWidth',2.8);     
%plot(time,str_tot,'LineWidth',1);                      
legend('0 degree lamina','90 degree lamina','Location','NorthEast');legend('boxoff');
xlabel('t [min]','Fontsize',16);
ylabel('\sigma_x (lamina 0) [MPa]','Fontsize',16);
axis([0 300 0 1200])
set(gca,'Fontsize',16);
ax1=gca;
ax2=axes('Position',get(ax1,'Position'),...
           'XAxisLocation','top',...
           'YAxisLocation','right',...
           'Color','none',...
           'Fontsize',16,...
           'XLim',get(ax1,'XLim'),...
           'YLim',get(ax1,'YLim'),...
           'XTick',get(gca,'XTick'),...
           'YTick',get(gca,'YTick'),...
           'XTickLabel',get(gca,'XTickLabel'),...
           'YTickLabel',get(gca,'YTickLabel'),...
           'XColor','w','YColor','k');
ylabel('\sigma_x (lamina 90) [MPa]');
set(ax2,'YTickLabel',{'0','10','20','30','40','50','60'});
hold off;

f2=figure;
plot(time,Ex_tot/max(Ex_tot),'k--','LineWidth',2);    
hold on
plot(time,Ex_0/max(Ex_0),'k','LineWidth',1.4);           
plot(time,Ex_90/max(Ex_90),'k','LineWidth',2.8);         
legend('Laminate','0 degree lamina','90 degree lamina','Location','SouthWest');legend('boxoff');
xlabel('t [min]','Fontsize',16);ylabel('Cx/(Cx)_0','Fontsize',16);
set(gca,'Fontsize',16);
hold off;

saveas(f1,['Fig7_5'],'pdf');
saveas(f2,['Fig7_6'],'pdf');
saveas(f1,['Fig7_5'],'eps');
saveas(f2,['Fig7_6'],'eps');
saveas(f1,['Fig7_5'],'png');
saveas(f2,['Fig7_6'],'png');

%[-xplot./tau;exp(-xplot./tau); exp(-xplot./tau).^m; D_0 + D_1p .* (1-exp(-xplot./tau).^m)]'
