Cizz22 3 months ago
parent bd437651a2
commit a29b058bfa

@ -248,7 +248,7 @@ async def create_calc_result_object(
async def calculate_plant_eaf(
db_session: DbSession, simulation_id: UUID, is_default: bool, konkin_offset: Optional[int] = 0
db_session: DbSession, simulation_id: UUID, mo_downtime: int, po_downtime:int, oh_interval:int
):
"""Calculate overall plant EAF from individual node results."""
plant_calc_data = await get_plant_calc_result(
@ -258,33 +258,30 @@ async def calculate_plant_eaf(
plant_plot_data = await get_simulation_with_plot_result(
db_session=db_session, simulation_id=simulation_id, node_id="plant"
)
is_oh_from_aeros = (plant_calc_data.total_uptime + plant_calc_data.total_downtime) > oh_interval
seasonal_outage = (mo_downtime*24 + po_downtime*24) if is_oh_from_aeros else mo_downtime*24
forced_outage = (plant_calc_data.total_downtime - po_downtime*24) if is_oh_from_aeros else plant_calc_data.total_downtime
total_period_time = plant_calc_data.total_uptime + seasonal_outage + forced_outage
eaf, derated_hours = calculate_eaf(
eaf, efor, sof, edh = calculate_eaf(
available_hours=plant_calc_data.total_uptime,
period_hours=plant_calc_data.total_uptime + plant_calc_data.total_downtime,
actual_production=plant_calc_data.production,
ideal_production=plant_calc_data.ideal_production,
downtime_hours=plant_calc_data.total_downtime,
period_hours=total_period_time,
forced_outage_hours=forced_outage,
seasonal_outage_hours=seasonal_outage,
plot_data=plant_plot_data.timestamp_outs
)
if konkin_offset > 0:
eaf_konkin = calculate_eaf_konkin(
plot_data=plant_plot_data.timestamp_outs,
periode_time=int(plant_calc_data.total_uptime + plant_calc_data.total_downtime),
konkin_offset=konkin_offset
)
plant_calc_data.eaf_konkin = eaf_konkin
efficiency_uptime = plant_calc_data.total_uptime - derated_hours
plant_calc_data.total_mo_downtime = mo_downtime
plant_calc_data.total_po_downtime = po_downtime
plant_calc_data.eaf = eaf
plant_calc_data.derating_hours = derated_hours
plant_calc_data.efor = efor
plant_calc_data.sof = sof
plant_calc_data.derating_hours = edh
await db_session.commit()
return eaf, derated_hours, efficiency_uptime
return eaf
# async def calculate_eaf_konkin_pnat(
# db_session

@ -10,9 +10,8 @@ setup_logging(log)
def calculate_eaf(
available_hours: float,
period_hours: float,
actual_production: float,
ideal_production: float,
downtime_hours,
forced_outage_hours:float,
seasonal_outage_hours: float,
plot_data = None
):
"""
@ -33,12 +32,15 @@ def calculate_eaf(
try:
# Calculate lost production
max_capacity = 660
derate_production = ideal_production - actual_production
# Calculate total equivalent derate and outage hours
edh = calculate_equivalent_derate_hours(plot_data, max_flow_rate=max_capacity)
# Calculate EAF
effective_available_hours = available_hours - edh
return (effective_available_hours / period_hours) * 100 if period_hours > 0 else 0, edh
eaf = ((available_hours - edh) / period_hours) * 100
efor = ((forced_outage_hours + edh)/period_hours) * 100
sof = (seasonal_outage_hours/period_hours)*100
return eaf, efor, sof, edh
except Exception as e:
print("Error calculating EAF:", e)
raise

@ -46,7 +46,9 @@ async def calculate_plant_eaf_activity(params: dict):
return await calculate_plant_eaf(
db_session=db_session,
simulation_id=params["HubCnnId"],
is_default=False,
mo_downtime=params["MaintenanceOutages"],
po_downtime=params["OverhaulDuration"],
oh_interval=params["OverhaulInterval"]
)

Loading…
Cancel
Save