def PH2_Calc(KH2, tH2, Kr, I, qH2):
    """
    Calculate PH2.

    :param KH2: hydrogen valve constant [kmol.s^(-1).atm^(-1)]
    :type KH2 : float
    :param tH2: hydrogen time constant [s]
    :type tH2 : float
    :param Kr: modeling constant [kmol.s^(-1).A^(-1)]
    :type Kr : float
    :param I: cell load current [A]
    :type I : float
    :param qH2: molar flow of hydrogen [kmol.s^(-1)]
    :type qH2 : float
    :return: PH2 [atm] as float
    """
    try:
        result = ((1 / KH2) / (1 + tH2)) * (qH2 - 2 * Kr * I)
        return result
    except (TypeError, ZeroDivisionError):
        print(
            "[Error] PH2 Calculation Failed (KH2:%s, tH2:%s, Kr:%s, I:%s, qH2:%s)" %
            (str(KH2), str(tH2), str(Kr), str(I), str(qH2)))