function DV = DangVan(stress, cDV)

% Evaluate Dang Van stress
% stress - [s11 s22 s33 s12 s13 s23; time 1
%           s11 s22 s33 s12 s13 s23; time 2
%              etc                 ]
% cDV    - material parameter in the Dang Van criterion

% Evaluate hydrostatic stress
% xxx

% Evaluate deviatoric stress tensor
sdev=stress;
for i=1:3
	% xxx;
end

% Find
% min { max(t) [J2(sdev-smid)]}
% Find midvalue without an extra condition that smid is deviatoric
smid = fminsearch(@(smid) J2(smid,sdev),(max(sdev)+min(sdev))/2);
% Find midvalue while assuring that smid is deviatoric
% smid5s = fminsearch(@(s5) J2(s5tosdev(s5),sdev),sdevtos5((max(sdev)+min(sdev))/2));
% smid=s5tosdev(smid5s);

% Evaluate Sa = Sdev-Smid
sa=zeros(size(sdev));
for i=1:size(sdev,1)
	% xxx;
end

for i=1:size(sa,1)
	s=[sa(i,1) sa(i,4) sa(i,5);...
	   sa(i,4) sa(i,2) sa(i,6);...
	   sa(i,5) sa(i,6) sa(i,3)];	   
  sp=sort(eig(s));
  % Evaluate Tresca "shear stress amplitude"
  % xxx;
  % Evaluate Dang Van stress
  % xxx;
end

x=[1:size(sa,1)];

figure(1) 				% Stress components
plot(x,stress(:,1),'-',x,stress(:,4),'-.',x,stress(:,2),'--')
grid
legend('S1','S4','S2')
title('Stress components')
ylabel('Stress')
xlabel('time increment')
figure(2) 				% Dang Van criterion
plot(x,dv,'-',x,tresca,'-.',x,sh,'--')
grid
legend('Dang Van equivalent stress','Tresca amplitude','Hydrostatic stress')
title('Dang Van equivalent stress')
ylabel('Stress')
xlabel('time increment')


% Results
[DV,pos]=max(dv) % Maximum Dang Van equivalent stress
MaxTrescaAmp=max(tresca) % Maximum Tresca shear stress "amplitude"
tresca(pos) % Tresca shear stress "amplitude" corresponding to max DV stress
sh(pos) % Hydrostatic stress corresponding to max DV stress
