diff --git a/src/modules/plant/run_plant_simulation.py b/src/modules/plant/run_plant_simulation.py index c362cc0..db27960 100644 --- a/src/modules/plant/run_plant_simulation.py +++ b/src/modules/plant/run_plant_simulation.py @@ -398,7 +398,8 @@ def main(): cost_a_depreciation = 0 net_capacity_factor_v = 0 eaf_v = 0 - + eaf_history = [] + cf_history = [] # Prefetch master data CF dan EAF sekali saja di luar loop cur.execute(""" SELECT year as tahun, cf, eaf @@ -424,6 +425,15 @@ def main(): net_capacity_factor_v = 0 eaf_v = 0 + # rata-rata 3 tahun terakhir untuk net_capacity_factor + eaf_history.append(eaf_v) + cf_history.append(net_capacity_factor_v) + last_3_eaf = eaf_history[-3:] + last_3_cf = cf_history[-3:] + avg_eaf_3 = sum(last_3_eaf) / len(last_3_eaf) if last_3_eaf else 0 + avg_cf_3 = sum(last_3_cf) / len(last_3_cf) if last_3_cf else 0 + selisih_eaf_cf = abs(avg_cf_3 - avg_eaf_3) + if data["is_actual"] == 1: production_bruto = validate_number(data["production_bruto"]) production_netto = validate_number(data["production_netto"]) @@ -437,6 +447,8 @@ def main(): cost_bd_om = validate_number(data["cost_bd_om"]) cost_bd_pm_nonmi = validate_number(data["cost_bd_pm_nonmi"]) cost_bd_bd = validate_number(data["cost_bd_bd"]) + net_capacity_factor = net_capacity_factor_v + eaf = eaf_v else: production_netto = net_capacity_factor * 8760 * daya_mampu_netto / 100 production_bruto = production_netto / (100 - (auxiliary + susut_trafo)) * 100 @@ -457,8 +469,8 @@ def main(): cost_bd_pm_nonmi = cost_bd_pm_nonmi cost_bd_bd = cost_bd_bd - net_capacity_factor = net_capacity_factor_v eaf = eaf_v + net_capacity_factor = eaf_v - selisih_eaf_cf # ++++++ REVENUE +++++++ revenue_total = revenue_a + revenue_b + revenue_c + revenue_d