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:
# Weight based on production capacity
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)
results[asset['aeros_node']['node_name']] = asset['contribution'] * 100
# Sort by contribution (worst contributors first)
# results = sorted(results.items(), key=lambda x: x[1], reverse=True)

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

@ -33,11 +33,10 @@ class OverhaulRead(OverhaulBase):
class AssetWeight(OverhaulBase):
node: dict
capacity_weight: float
contribution: float
eaf_impact: float
eaf: float
num_of_failures: int
downtime_hours: float
down_time: float
class MaintenanceScenario(OverhaulBase):
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
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 = []
for asset in eq_results:
# Weight based on production capacity
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)
# # Weight based on production capacity (just for seri)
# capacity_weight = asset.get('total_downtime', 0) / plant_production if plant_production > 0 else 0
# Get asset EAF and downtime
asset_eaf = asset.get('eaf', 0)
asset_derating_pct = 100 - asset_eaf
# # Get asset EAF and downtime
plant_eaf_minus = 100 - plant_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 this asset's contribution to plant EAF reduction
# # This is how much this asset alone reduces the overall plant EAF
eaf_contribution = plant_eaf_minus * asset.get("contribution")
# 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
# # Calculate actual downtime hours (if simulation hours available)
# sim_duration = plant_result.get('sim_duration', 8760) # Default to 1 year
contribution = AssetWeight(
node=asset.get('aeros_node'),
eaf=asset_eaf,
capacity_weight=capacity_weight,
contribution=asset.get("contribution"),
eaf_impact=eaf_contribution,
downtime_hours=downtime_hours,
num_of_failures=asset.get('num_events', 0),
down_time=asset.get('total_downtime')
)
results.append(contribution)
# 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
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]
# Select only standard Scope(array)
selected_asset = [asset for asset in asset_contributions if asset.node['node_name'] in standard_scope_location_tags]
project_eaf_improvement = 0.0
selected_eq = []
print(f"Plant EAF from API: {current_plant_eaf:.2f}%")
print(f"Plant EAF calculated: {calculated_plant_eaf:.2f}%")
print(f"Target EAF: {target_eaf:.2f}%")
print(f"EAF Gap: {eaf_gap:.2f}%")
for asset in asset_contributions:
if (project_eaf_improvement + asset.eaf_impact) <= eaf_gap:
selected_eq.append(asset)
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(
current_plant_eaf=current_plant_eaf,
current_plant_eaf=current_plant_eaf + project_eaf_improvement,
target_plant_eaf=target_eaf,
eaf_gap=eaf_gap,
asset_contributions=selected_asset,
asset_contributions=selected_eq,
optimization_success=optimization_success,
simulation_id=simulation_id
)

Loading…
Cancel
Save