from tests.verification.model_verification.resources.utils_propulsion import *


def propeller(pbp, tbp, k, pi, nu, stage):
    """
    :param pbp: Total pressure ante propeller
    :param tbp: Total temperature ante propeller
    :param k: Specific heat capacity of gas flowing through propeller
    :param pi: Propeller pressure ratio
    :param nu: Propeller isentropic efficiency
    :param stage: Stage
    :return: Total pressure and temperature post propeller
    """
    p = pbp*pi
    t = tbp*(1+1/nu*(pi**((k-1)/k)-1))
    print_color('Propeller', 'green')
    print(units('T0_{} = {:,.4f}'.format(stage, t), 'K')
          +
          units('\np0_{} = {:,.4f}'.format(stage, p), 'Pa')
          )
    return p, t


def propeller_power(pbr):
    """
    Propeller required power
    :param pbr: Propeller power
    :return: Work required by the flow on turbine
    """
    print(units('Ẇ_prop = {:,.4f}'.format(pbr), 'W'))
    return pbr


def propeller_thrust(w, nu, v0):
    """
    Thrust generated by propeller
    :param w: Propeller power
    :param nu: Propeller mechanical efficiency
    :param v0: Free stream velocity
    :return:
    """
    T_prop = nu*w/v0
    print_color('Propeller thrust', 'yellow')
    print(units('T_prop = {:,.4f}'.format(T_prop), 'N'))
    return T_prop