def dr_new_energy_capacity_rule(mod, g, p):
    """
    **Expression Name**: DRNew_Energy_Capacity_MWh
    **Defined Over**: DR_NEW_OPR_PRDS

    Total energy capacity in each period is the sum of all new build over the
    previous periods (including the current period).

    Vintages = all periods
    """
    return sum(
        mod.DRNew_Build_MWh[g, prev_p]
        for prev_p in mod.PERIODS if prev_p <= p
    )