def get_subs_tes_chp(chp_ratio, v_tes, tes_invest, p_nom):
    """
    Calculate KWKG subsidy for TES in combination with CHP

    Parameters
    ----------
    chp_ratio : chp_heat/total_heat per year
    v_tes : tes volume in liter
    tes_invest
    p_nom : el. power in kW

    Returns
    -------
    kwkg_subs_tes : amount of subsidy
    """

    kwkg_subs_tes = 0

    # TES volume in m3
    v_m3 = v_tes/1000

    # subsidy applies only for systems with ratio of chp heat per year higher than 50%
    if chp_ratio >= 0.5:

        if 1.0 <= v_m3 <= 50.0:
            kwkg_subs_tes = 250 * v_m3

        elif v_m3 > 50:
            kwkg_subs_tes = 0.3 * tes_invest

        else:
            if v_m3 >= 0.3 * p_nom:
                kwkg_subs_tes = 250 * v_m3

    return kwkg_subs_tes