|
|
|
|
@ -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
|
|
|
|
|
plant_eaf_minus = 100 - plant_eaf
|
|
|
|
|
|
|
|
|
|
# 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 = plant_eaf_minus * asset.get("contribution")
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
# # 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]
|
|
|
|
|
|
|
|
|
|
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}%")
|
|
|
|
|
project_eaf_improvement = 0.0
|
|
|
|
|
selected_eq = []
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
)
|
|
|
|
|
|