% Calculate the turn-off and turn-on losses of igbt.            13-9-14

% The values given are assumed to be proportional to V. 

function [eoff,eon] = STGWA19N60_swg_loss(t,v,i)   	% NB.   in uJ

% Calculate the losses as a function of current, at Tj = 125C :
ipoly = [i^2 i 1];
eoffi = sum(ipoly.*[2.7273e-2 33.738 3.3909]);   	% from loss data, p3
eoni = sum(ipoly.*[0.17333 13.9885 -1.1455]);       % from loss data, p4

% Then apply junction temperature corrections relative to 125C.
tpoly = [t^2 t 1];
tc_off = sum(tpoly.*[9.572e-6 4.2141e-3 0.32367]); 	% from loss data, p1
tc_on = sum(tpoly.*[3.3845e-5 7.2911e-4 0.38003]); 	% from loss data, p2

eoff = eoffi*tc_off*v/390;                  % data provided was at 390V
eon = eoni*tc_on*v/390;                  	%   adjust to V

if (eoff < 0) || i == 0
    eoff = 0;                      	% prevent negative values from 
end                               	%   function approximation
if (eon < 0) || i == 0             	%   being returned
    eon = 0;
end

end


