feature/reliability_stat
Cizz22 4 months ago
parent ef9e457ed8
commit 8ecc03f015

@ -96,23 +96,7 @@ def calculate_asset_eaf_contributions(plant_result, eq_results):
for asset in eq_results: for asset in eq_results:
# Weight based on production capacity results[asset['aeros_node']['node_name']] = asset['contribution'] * 100
capacity_weight = asset.get('production', 0) / plant_production if plant_production > 0 else 0
# plot_data = next((item for item in plot_result if item['aeros_node']['node_name'] == asset['aeros_node']['node_name']), None)
# Get asset EAF and downtime
asset_eaf = asset.get('eaf', 0)
asset_derating_pct = 100 - asset_eaf
# Calculate this asset's contribution to plant EAF reduction
# This is how much this asset alone reduces the overall plant EAF
eaf_contribution = asset_derating_pct * capacity_weight
# Calculate actual downtime hours (if simulation hours available)
sim_duration = plant_result.get('sim_duration', 8760) # Default to 1 year
downtime_hours = (asset_derating_pct / 100) * sim_duration
results[asset['aeros_node']['node_name']] = round(eaf_contribution)
# Sort by contribution (worst contributors first) # Sort by contribution (worst contributors first)
# results = sorted(results.items(), key=lambda x: x[1], reverse=True) # results = sorted(results.items(), key=lambda x: x[1], reverse=True)

@ -59,7 +59,7 @@ async def get_target_reliability(
# ) # )
if not simulation_id: if not simulation_id:
simulation_id = "76b2c981-c338-4d69-b85b-6977cb47ed41" simulation_id = "f31103ef-1ac8-4c29-8f66-ea9ccf06bd87"
results = await get_simulation_results( results = await get_simulation_results(
simulation_id=simulation_id, simulation_id=simulation_id,

@ -33,11 +33,10 @@ class OverhaulRead(OverhaulBase):
class AssetWeight(OverhaulBase): class AssetWeight(OverhaulBase):
node: dict node: dict
capacity_weight: float contribution: float
eaf_impact: float eaf_impact: float
eaf: float
num_of_failures: int num_of_failures: int
downtime_hours: float down_time: float
class MaintenanceScenario(OverhaulBase): class MaintenanceScenario(OverhaulBase):
location_tag: str location_tag: str

@ -109,39 +109,36 @@ def calculate_asset_eaf_contributions(plant_result, eq_results):
Calculate each asset's negative contribution to plant EAF Calculate each asset's negative contribution to plant EAF
Higher contribution = more impact on reducing plant EAF Higher contribution = more impact on reducing plant EAF
""" """
plant_production = plant_result.get('production', 0) plant_production = plant_result.get('total_downtime', 0)
plant_eaf = plant_result.get('eaf')
results = [] results = []
for asset in eq_results: for asset in eq_results:
# Weight based on production capacity # # Weight based on production capacity (just for seri)
capacity_weight = asset.get('production', 0) / plant_production if plant_production > 0 else 0 # capacity_weight = asset.get('total_downtime', 0) / plant_production if plant_production > 0 else 0
# plot_data = next((item for item in plot_result if item['aeros_node']['node_name'] == asset['aeros_node']['node_name']), None)
# # Get asset EAF and downtime
plant_eaf_minus = 100 - plant_eaf
# Get asset EAF and downtime # # Calculate this asset's contribution to plant EAF reduction
asset_eaf = asset.get('eaf', 0) # # This is how much this asset alone reduces the overall plant EAF
asset_derating_pct = 100 - asset_eaf eaf_contribution = plant_eaf_minus * asset.get("contribution")
# Calculate this asset's contribution to plant EAF reduction # # Calculate actual downtime hours (if simulation hours available)
# This is how much this asset alone reduces the overall plant EAF # sim_duration = plant_result.get('sim_duration', 8760) # Default to 1 year
eaf_contribution = asset_derating_pct * capacity_weight
# Calculate actual downtime hours (if simulation hours available)
sim_duration = plant_result.get('sim_duration', 8760) # Default to 1 year
downtime_hours = (asset_derating_pct / 100) * sim_duration
contribution = AssetWeight( contribution = AssetWeight(
node=asset.get('aeros_node'), node=asset.get('aeros_node'),
eaf=asset_eaf, contribution=asset.get("contribution"),
capacity_weight=capacity_weight,
eaf_impact=eaf_contribution, eaf_impact=eaf_contribution,
downtime_hours=downtime_hours,
num_of_failures=asset.get('num_events', 0), num_of_failures=asset.get('num_events', 0),
down_time=asset.get('total_downtime')
) )
results.append(contribution) results.append(contribution)
# Sort by contribution (worst contributors first) # Sort by contribution (worst contributors first)
results.sort(key=lambda x: x.eaf_impact, reverse=True) results.sort(key=lambda x: x.contribution, reverse=True)
return results return results
def project_eaf_improvement(asset: AssetWeight, improvement_factor: float = 0.3) -> float: def project_eaf_improvement(asset: AssetWeight, improvement_factor: float = 0.3) -> float:
@ -190,21 +187,23 @@ async def identify_worst_eaf_contributors(*, simulation_result, target_eaf: floa
standard_scope_location_tags = [tag.location_tag for tag in standard_scope] standard_scope_location_tags = [tag.location_tag for tag in standard_scope]
# Select only standard Scope(array) project_eaf_improvement = 0.0
selected_asset = [asset for asset in asset_contributions if asset.node['node_name'] in standard_scope_location_tags] selected_eq = []
print(f"Plant EAF from API: {current_plant_eaf:.2f}%") for asset in asset_contributions:
print(f"Plant EAF calculated: {calculated_plant_eaf:.2f}%") if (project_eaf_improvement + asset.eaf_impact) <= eaf_gap:
print(f"Target EAF: {target_eaf:.2f}%") selected_eq.append(asset)
print(f"EAF Gap: {eaf_gap:.2f}%") project_eaf_improvement += asset.eaf_impact
else:
break
optimization_success = current_plant_eaf >= target_eaf optimization_success = current_plant_eaf + project_eaf_improvement >= target_eaf
return OptimizationResult( return OptimizationResult(
current_plant_eaf=current_plant_eaf, current_plant_eaf=current_plant_eaf + project_eaf_improvement,
target_plant_eaf=target_eaf, target_plant_eaf=target_eaf,
eaf_gap=eaf_gap, eaf_gap=eaf_gap,
asset_contributions=selected_asset, asset_contributions=selected_eq,
optimization_success=optimization_success, optimization_success=optimization_success,
simulation_id=simulation_id simulation_id=simulation_id
) )

Loading…
Cancel
Save