From 8c01702c7ab925106528dd5115ed52dc78543a2e Mon Sep 17 00:00:00 2001 From: ariwahyunahar Date: Tue, 23 Dec 2025 17:10:36 +0700 Subject: [PATCH] edit plant simulation run2.py -> menambahkan hitung nilai cf=selisih dari rata2 3 tahun terakhir eaf - (cf - eaf) --- src/modules/plant/run2.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/modules/plant/run2.py b/src/modules/plant/run2.py index 8d5524f..ec18b72 100644 --- a/src/modules/plant/run2.py +++ b/src/modules/plant/run2.py @@ -391,6 +391,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(""" @@ -399,7 +401,6 @@ def main(): order by year asc """) year_rows = cur.fetchall() - print(year_rows) year_data_map = {int(t): (validate_number(cf), validate_number(eaf)) for (t, cf, eaf) in year_rows if t is not None} @@ -418,6 +419,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"]) @@ -431,6 +441,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 @@ -449,9 +461,8 @@ def main(): cost_bd_om = cost_bd_om cost_bd_pm_nonmi = cost_bd_pm_nonmi cost_bd_bd = cost_bd_bd - - net_capacity_factor = net_capacity_factor_v - eaf = eaf_v + eaf = eaf_v + net_capacity_factor = eaf_v - selisih_eaf_cf # ++++++ REVENUE +++++++ revenue_total = revenue_a + revenue_b + revenue_c + revenue_d