From 66c670c7153ad7215d74b4efa5ffa3ccc0a8de6c Mon Sep 17 00:00:00 2001 From: Cizz22 Date: Mon, 25 Aug 2025 14:04:10 +0700 Subject: [PATCH] fix --- src/aeros_simulation/service.py | 2 +- src/aeros_simulation/utils.py | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/aeros_simulation/service.py b/src/aeros_simulation/service.py index 04688bf..82cdca0 100644 --- a/src/aeros_simulation/service.py +++ b/src/aeros_simulation/service.py @@ -236,7 +236,7 @@ async def save_simulation_result( ideal_production=result["idealProduction"] ) - efor = (result["totalDowntime"] / (result["totalDowntime"] + result["totalUpTime"])*100) if (result["totalDowntime"] + result["totalUpTime"]) > 0 else 0 + efor = (result["totalDowntime"] / (result["totalDowntime"] + result["totalUpTime"]))*100 if (result["totalDowntime"] + result["totalUpTime"]) > 0 else 0 calc_result = AerosSimulationCalcResult( aeros_simulation_id=simulation_id, diff --git a/src/aeros_simulation/utils.py b/src/aeros_simulation/utils.py index e6fd9bf..bdb9688 100644 --- a/src/aeros_simulation/utils.py +++ b/src/aeros_simulation/utils.py @@ -18,18 +18,23 @@ def calculate_eaf( Returns: Dictionary with EAF result and breakdown """ - # Calculate lost production - lost_production = ideal_production - actual_production - estimated_max_capacity = ideal_production / period_hours if period_hours > 0 else 0 + try: + # Calculate lost production + lost_production = ideal_production - actual_production + print(ideal_production, actual_production, lost_production) - # Calculate total equivalent derate hours - total_equivalent_derate_hours = lost_production / estimated_max_capacity + estimated_max_capacity = ideal_production / period_hours if period_hours > 0 else 0 - # Calculate EAF - effective_available_hours = available_hours - total_equivalent_derate_hours - return (effective_available_hours / period_hours) * 100, total_equivalent_derate_hours + # Calculate total equivalent derate hours + total_equivalent_derate_hours = lost_production / estimated_max_capacity if estimated_max_capacity > 0 else 0 + # Calculate EAF + effective_available_hours = available_hours - total_equivalent_derate_hours + return (effective_available_hours / period_hours) * 100 if period_hours > 0 else 0, total_equivalent_derate_hours + except Exception as e: + print("Error calculating EAF:", str(e)) + raise # def calculate_efor( # forced_outage_hours: float,