def emulsion_type(rho, visc, stability, asph, res):
    """
    Return the type of emulstion (entrained, unstable, stable, mesostable)

    Parameters
    ----------
    rho : Density [kg/m³]
    visc : Viscosity [Pa s]
    stability : Stability
    min_AR : Minimum between
    asph : Asphaltene content [] (0-1)
    res : Resine content [] (0-1)


    """
    min_AR = min(asph, res)
    if rho > 940 and visc > 6 and stability > -20 and stability < -3:
        return 'entrained'
    elif ((rho < 850 or rho > 1) and (visc < 0.1 or visc > 800)
          and (stability < -18 or stability > -4) and min_AR < 0.01):
        return 'unstable'
    elif stability > 4 and stability < 29:
        return 'stable'
    elif stability > -10 and stability < 5:
        return 'mesostable'
    else:
        raise Exception("Emulsion type not found")