function dev = Deviatoric(tensor)

% This function calculates the deviatoric part of a given second order
% tensor

if size(tensor,1) == size(tensor,2)
    dev = tensor - (1/3) * trace(tensor) * eye(size(tensor)) ;
else
    error('Input tensor must be square')
end
