[Python] How to skip iteraction and referring the new one to two previous ones

Discussão em 'Python' iniciado por Stack, Dezembro 6, 2024.

  1. Stack

    Stack Membro Participativo

    I have a dictionaries with key having values for each time intervals. For each new time t, functions perform calculation by using dictionary values at t-1. Now, I have a problem with t 1681, which I want to skip.

    Original:

    for t in time:

    ELZfarm_m_h2_production=0
    ELZfarm_m_O2_production=0
    h2_net_to_change_from_storage=0

    # System consumption at t-1
    # Power consumed by the ELZs
    P_ELZ_inoperation_tbefore = sum(ELZmodule[key]['Power'][t-1] for key in ELZmodule.keys() ) # MW
    # Power consumed by UTILITIES
    Power_consump_utilities_Mw= sum(Power_consumption_utilities[key][t-1] for key in Power_consumption_utilities.keys() ) # MW
    # Total Power consumed by the system
    Power_consump_system_tot_Mw = P_ELZ_inoperation_tbefore + Power_consump_utilities_Mw # MW

    # Determing the total Delta Power variation from t-1
    Delta_P_system = Psolar[t] - Power_consump_system_tot_Mw # MW

    # Positive Delta Power Variation
    if Delta_P_system >= 0:
    ......


    Idea:

    for t in time:

    if t == 1861:
    continue

    elif t == 1862:
    t-1 = 1860

    ELZfarm_m_h2_production=0
    ELZfarm_m_O2_production=0
    h2_net_to_change_from_storage=0

    # System consumption at t-1
    # Power consumed by the ELZs
    P_ELZ_inoperation_tbefore = sum(ELZmodule[key]['Power'][t-1] for key in ELZmodule.keys() ) # MW
    # Power consumed by UTILITIES
    Power_consump_utilities_Mw= sum(Power_consumption_utilities[key][t-1] for key in Power_consumption_utilities.keys() ) # MW
    # Total Power consumed by the system
    Power_consump_system_tot_Mw = P_ELZ_inoperation_tbefore + Power_consump_utilities_Mw # MW

    # Determing the total Delta Power variation from t-1
    Delta_P_system = Psolar[t] - Power_consump_system_tot_Mw # MW

    # Positive Delta Power Variation
    if Delta_P_system >= 0:
    ......


    I'm aware it cannot be written like that. Do you have any help for that?

    Thanks for the collaboration.

    Continue reading...

Compartilhe esta Página