% FEAcomp. Solution of Example 7.6
% J.A. Mayugo and E.J. Barbero (c) 2006, 2007, 2013
% To run this M-file need the function:
%                   fitfunFEAcomp(xdata, ydata,ifun)
% avaiable in .\Examples\Ch7ex\FEAcomp_Ex704\

clear all; close all;

% Experimental Creep Data
time = [1e-6 20 40 60 80 100];
sigma4 = [62.6 38.1 23.1 13.9 8.4 5.04]*1e-3;
G23 = sigma4/0.02;

%sigma2 = [92.76 56.11 33.83 20.36 12.23 7.35];
%C22 = sigma2/0.01;
%D    = [1.49 1.99 2.21 2.35 2.56 2.66 2.75 2.85 2.92 2.96 3.01];
%D = 1./C22

xdata = time;
ydata = G23;
[m,n]=size (xdata);

% Maxwell Model    
[est,mod]= fitfunFEAcomp(xdata, ydata,1);  % #12 to activate fitpower
        G_0 = est(1)
        tau = 1/est(2)
f0=figure;
linewth  = 2.;
fontsze  = 24;
plot(xdata,ydata,'x','LineWidth',linewth,'MarkerSize',12);          % experimental data
hold on
xplot = [0:1:204];
plot (xplot,G_0.*exp(-xplot/tau),'--','LineWidth',1);                          % Maxell Model
legend('FEM Data','Maxwell Model','Location','NorthEast');legend('boxoff');
xlabel('t [min]','Fontsize',fontsze);ylabel('G_{23} [GPa]','Fontsize',fontsze);
axis([0 120 0 3.5])
set(gca,'Fontsize',fontsze);
hold off
saveas(f0,['figEx706'],'pdf');
