function [tpwsDataL, tpwsDataV] = region4_calc(p,T)
% Description:      Calculates the thermodynamic properties of water based
%                   on the IAPWS IF-97 Release for Region 4
% -------------------------------------------------------------------------
% Syntax:           [tpwsDataL, tpwsDataV] = region4_calc(p,T)
%                   p           Pressure [MPa]
%                   T           Temperature [K]
% -------------------------------------------------------------------------
% Output:           tpwsDataL   Structure containing all relevant
%                               properties for the liquid phase
%                   tpwsDataV   Structure containing all relevant
%                               properties for the vapor phase

if (T <= 623.15)
    tpwsDataL = region1_calc(p,T);
    tpwsDataV = region2_calc(p,T);
else
    rho = bisection('region3_calc(x,y)', T, 'p', p, 0, 1500, 0.000001, 10000);
    tpwsDataL = region3_calc(rho,T);
    tpwsDataV = region2_calc(p,T);
end