Code covered by the BSD License  

Highlights from
nanoind_data_analysis

image thumbnail

nanoind_data_analysis

by

 

06 Sep 2013 (Updated )

A MATLAB GUI to plot and to analyze (nano)indentation data (obtained with conical indenters)

model_bilayer_elastic.m
%% Copyright 2013 MERCIER David
%% Script used to calculate the bilayer elastic model
%% Initialization
clear Em; clear Ef; clear Ef_sol; clear Ef_sol_fit; clear Ef_red; clear Ef_red_solfit;

%% Refreshing the GUI
if (val4 ~= 3 && val4 ~= 4)
    set(value_bilayermodel_GUI,   'Value', 1);
    set(value_multilayermodel_GUI,'Value', 1);
    set(cb_corr_thickness_GUI,    'Value', 0);
    set(title_bilayermodel_GUI,   'Visible', 'off');
    set(value_bilayermodel_GUI,   'Visible', 'off');
    set(title_multilayermodel_GUI,'Visible', 'off');
    set(value_multilayermodel_GUI,'Visible', 'off');
    set(cb_corr_thickness_GUI,    'Visible', 'off');

else
    set(title_bilayermodel_GUI, 'Visible', 'on');
    set(value_bilayermodel_GUI, 'Visible', 'on');
    set(cb_corr_thickness_GUI,  'Visible', 'on');
    
end

%% Setting variables & parameters
Es_red = Es / (1-nus^2);  % Reduced Young's modulus of the substrate (in GPa)

if get(cb_corr_thickness_GUI, 'Value') == 1
    t_corr = t - (hc./3);
    
else
    t_corr = t;
    
end

legend2 = 'Results with the bilayer model';

%% Optimization of Young's modulus of the thin film
if val2 ~= 1
    if val4 == 3
        x       = t_corr./ac;
        phigao1 = (2/pi).*atan(x)+(x./pi).*log((1+(x).^2)./(x).^2); % Hay et al. (2011) 
        nuc     = 1-(((1-nus)*(1-nuf))./(1-(1-phigao1)*nuf-(phigao1*nus))); % Hay et al. (2011)  - Poisson's coefficient of the composite (film + substrate)
        phigao0 = (2.*atan(x)./pi) + ((1./(2.*pi.*(1-nuc))).* (((1-2*nuc).*x.*log(1+(1./x).^2)) - (x./(1+(x).^2))));
        
        if val2 == 2 %Doerner & Nix (1986) modified by King (1987)
            alpha         = 0.25;
            k_DN          = -alpha.*x;
            bilayer_model = @(Ef_red_sol,x) ...
                (1e-9*(((1./(1e9*Ef_red_sol))*(1-exp(k_DN)))+((1./Es_red)*(exp(k_DN)))).^-1);
            
        elseif val2 == 3 %Gao et al. (1992)
            bilayer_model = @(Ef_red_sol,x) ...
                (1e-9*((((1e9*Ef_red_sol)-Es_red).*phigao0)+Es_red));
            
        elseif val2 == 4 %Perriot et al. (2003)
            model_perriot_barthel;
            
        elseif val2 == 5 %Bec et al. (2006)
            x             = h;
            bilayer_model = @(Ef_red_sol,x) ...
                (1e-9*(((2.*ac)./(1+2.*(t_corr)./(pi.*ac))) .* ...
                (((t_corr)./(pi.*ac.^2.*1e9*Ef_red_sol) + ...
                (1./(2.*ac.*Es_red))))).^-1);
            
        elseif val2 == 6 %Hay et al. (2011)
            F             = 0.626;
            bilayer_model = @(Ef_red_sol,x) ...
                ((1e-9*((2.*(1+nuc)))./(((1-phigao0) .* ...
                (1./((Es./(2.*(1+nus)))))) + ...
                (phigao0.*(1./(1e9*(Ef_red_sol.*(1-nuf.^2))./(2.*(1+nuf))))))))./(1-nuc.^2);
        end
        
        if val2 ~= 4
            Ef_red_sol0 = str2double(get(value_youngfilm1_GUI, 'String'));    % Make a starting guess at the solution (Ef in GPa)
            
            OPTIONS=optimset('lsqcurvefit');
            OPTIONS=optimset(OPTIONS, 'TolFun',  1e-20);
            OPTIONS=optimset(OPTIONS, 'TolX',    1e-20);
            OPTIONS=optimset(OPTIONS, 'MaxIter', 10000);
            [Ef_red_solfit, resnorm, residual, exitflag, utput, lambda, jacobian] =...
                lsqcurvefit(bilayer_model, Ef_red_sol0, x, Esample_red,0, 1000, OPTIONS);
            
            Ef_sol_fit = Ef_red_solfit * (1-nuf^2);
            
            %% Calculation of Em with elastic bilayer models
            if val2 == 2 %Doerner & Nix (1986) modified by King (1987)
                Em_red = 1e-9 * (((1./(1e9*Ef_red_solfit)) * (1-exp(k_DN))) + ((1./Es_red)*(exp(k_DN)))).^-1;
                
            elseif val2 == 3 %Gao et al. (1992)
                Em_red = 1e-9 * ((((1e9*Ef_red_solfit) - Es_red) .* phigao0) + Es_red);
                
            elseif val2 == 5 % Bec et al. (2006)
                Em_red = 1e-9 * (((2.*ac)./(1+2.*(t_corr)./(pi.*ac))) .* ...
                    (((t_corr)./(pi.*ac.^2.*(1e9*Ef_red_solfit)) + (1./(2.*ac.*Es_red))))).^-1;
                
            elseif val2 == 6 % Hay et al. (2011) 
                Em_red =((1e-9 * ((2.*(1+nuc)))./(((1-phigao0) .* (1./((Es./(2.*(1+nus)))))) + ...
                    (phigao0.*(1./(1e9*(Ef_red_solfit.*(1-nuf.^2))./(2.*(1+nuf))))))))./(1-nuc.^2);
            end
            
            Em = Em_red*(1-nuf.^2);  % Em in GPa
        end
        
        %% Calculation of Ef with elastic bilayer models and Esample_red
    elseif val4 == 4
        x       = (t_corr)./ac;
        phigao1 = (2/pi).*atan(x)+(x./pi).*log((1+(x).^2)./(x).^2); % Hay et al. (2011) 
        nuc     = 1-(((1-nus)*(1-nuf))./(1-(1-phigao1)*nuf-(phigao1*nus))); % Hay et al. (2011) - Poisson's coefficient of the composite (film + substrate)
        phigao0 = (2.*atan(x)./pi) + ((1./(2.*pi.*(1-nuc))).* (((1-2*nuc).*x.*log(1+(1./x).^2)) - (x./(1+(x).^2))));
        
        if val2 == 2 % Doerner & Nix (1986) modified by King (1987)
            alpha  = 0.25;
            k_DN   = -alpha.*x;
            Ef_red = 1e-9*(((1./(1e9.*Esample_red)) - ((1./Es_red)*(exp(k_DN))))./(1-exp(k_DN))).^-1;
            
        elseif val2 == 3 % Gao et al. (1992)
            Ef_red = 1e-9*((((1e9.*Esample_red)-Es_red)./phigao0) + Es_red);
            
        elseif val2 == 4 % Perriot et al. (2003)
            model_perriot_barthel;
            
        elseif val2 == 5 % Bec et al. (2006)
            Ef_red = 1e-9 * (((pi.*ac.^2)./(t_corr)) .* ...
                (((1./(1e9.*Esample_red)) .* ...
                (((1+2.*(t_corr)./(pi.*ac)))./(2.*ac))) - ...
                (1./(2.*ac.*Es_red)))).^-1;
            
        elseif val2 == 6 % Hay et al. (2011)
            F      = 0.626;
            mueq   = Esample./(2.*(1+nuc));
            mus    = 1e-9.*Es./(2.*(1+nus));
            A_Hay  = F.*phigao0;
            B_Hay  = mus-(((F.*phigao0.^2)-phigao0+1).*mueq);
            C_Hay  = -phigao0.*mueq.*mus;
            muf    = (-B_Hay+(B_Hay.^2-(4.*A_Hay.*C_Hay)).^0.5)./(2.*A_Hay);
            Ef     = (2.*muf.*(1+nuf));
            Ef_red = Ef./(1-nuf^2);  % Ef in GPa
        end
        Ef=Ef_red.*(1 - nuf^2);
        
    end
    
elseif val2 == 1 || val4 == 5 || val5 == 1 || val4 == 2 % No Bilayer Model
    
    % Preallocation
    Ef     = NaN(length(h), 1);
    Ef_red = NaN(length(h), 1);
    Em_red = NaN(length(h), 1);
    
    for ii = 1:1:length(h)
        Ef(ii)      = 0;
        Ef          = Ef.';
        Ef_red(ii)  = 0;
        Ef_red      = Ef_red.';
        Ef_sol_fit  = 0;
        Em_red(ii)  = 0;
        Em_red      = Em_red.';
    end
    
end

set(MainWindows, 'CurrentAxes', AxisPlot_GUI);
model_hardness;

Contact us