|
|
|
@ -48,12 +48,12 @@ async def get_simulation_results(*, simulation_id: str, token: str):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
calc_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}?nodetype=RegularNode"
|
|
|
|
calc_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}?nodetype=RegularNode"
|
|
|
|
plot_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/plot/{simulation_id}?nodetype=RegularNode"
|
|
|
|
# plot_result_url = f"{RBD_SERVICE_API}/aeros/simulation/result/plot/{simulation_id}?nodetype=RegularNode"
|
|
|
|
calc_plant_result = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}/plant"
|
|
|
|
calc_plant_result = f"{RBD_SERVICE_API}/aeros/simulation/result/calc/{simulation_id}/plant"
|
|
|
|
|
|
|
|
|
|
|
|
async with httpx.AsyncClient(timeout=300.0) as client:
|
|
|
|
async with httpx.AsyncClient(timeout=300.0) as client:
|
|
|
|
calc_task = client.get(calc_result_url, headers=headers)
|
|
|
|
calc_task = client.get(calc_result_url, headers=headers)
|
|
|
|
plot_task = client.get(plot_result_url, headers=headers)
|
|
|
|
# plot_task = client.get(plot_result_url, headers=headers)
|
|
|
|
plant_task = client.get(calc_plant_result, headers=headers)
|
|
|
|
plant_task = client.get(calc_plant_result, headers=headers)
|
|
|
|
|
|
|
|
|
|
|
|
# Run all three requests concurrently
|
|
|
|
# Run all three requests concurrently
|
|
|
|
@ -64,12 +64,12 @@ async def get_simulation_results(*, simulation_id: str, token: str):
|
|
|
|
plant_response.raise_for_status()
|
|
|
|
plant_response.raise_for_status()
|
|
|
|
|
|
|
|
|
|
|
|
calc_data = calc_response.json()["data"]
|
|
|
|
calc_data = calc_response.json()["data"]
|
|
|
|
plot_data = plot_response.json()["data"]
|
|
|
|
# plot_data = plot_response.json()["data"]
|
|
|
|
plant_data = plant_response.json()["data"]
|
|
|
|
plant_data = plant_response.json()["data"]
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
"calc_result": calc_data,
|
|
|
|
"calc_result": calc_data,
|
|
|
|
"plot_result": plot_data,
|
|
|
|
# "plot_result": plot_data,
|
|
|
|
"plant_result": plant_data
|
|
|
|
"plant_result": plant_data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -103,7 +103,7 @@ def calculate_asset_weights(plant_result, eq_results):
|
|
|
|
|
|
|
|
|
|
|
|
return results
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
|
|
def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
|
|
|
|
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
|
|
|
|
@ -115,7 +115,7 @@ def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
|
|
|
|
for asset in eq_results:
|
|
|
|
for asset in eq_results:
|
|
|
|
# Weight based on production capacity
|
|
|
|
# Weight based on production capacity
|
|
|
|
capacity_weight = asset.get('production', 0) / plant_production if plant_production > 0 else 0
|
|
|
|
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)
|
|
|
|
# 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
|
|
|
|
# Get asset EAF and downtime
|
|
|
|
asset_eaf = asset.get('eaf', 0)
|
|
|
|
asset_eaf = asset.get('eaf', 0)
|
|
|
|
@ -136,7 +136,6 @@ def calculate_asset_eaf_contributions(plant_result, eq_results, plot_result):
|
|
|
|
eaf_impact=eaf_contribution,
|
|
|
|
eaf_impact=eaf_contribution,
|
|
|
|
downtime_hours=downtime_hours,
|
|
|
|
downtime_hours=downtime_hours,
|
|
|
|
num_of_failures=asset.get('num_events', 0),
|
|
|
|
num_of_failures=asset.get('num_events', 0),
|
|
|
|
plot_data=plot_data
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
results.append(contribution)
|
|
|
|
results.append(contribution)
|
|
|
|
|
|
|
|
|
|
|
|
@ -169,12 +168,12 @@ async def identify_worst_eaf_contributors(*, simulation_result, target_eaf: floa
|
|
|
|
# Calculate current plant EAF and asset contributions
|
|
|
|
# Calculate current plant EAF and asset contributions
|
|
|
|
calc_result = simulation_result['calc_result']
|
|
|
|
calc_result = simulation_result['calc_result']
|
|
|
|
plant_result = simulation_result['plant_result']
|
|
|
|
plant_result = simulation_result['plant_result']
|
|
|
|
plot_result = simulation_result['plot_result']
|
|
|
|
# plot_result = simulation_result['plot_result']
|
|
|
|
|
|
|
|
|
|
|
|
# Get equipment results from calc_result
|
|
|
|
# Get equipment results from calc_result
|
|
|
|
eq_results = calc_result if isinstance(calc_result, list) else [calc_result]
|
|
|
|
eq_results = calc_result if isinstance(calc_result, list) else [calc_result]
|
|
|
|
|
|
|
|
|
|
|
|
asset_contributions = calculate_asset_eaf_contributions(plant_result, eq_results, plot_result)
|
|
|
|
asset_contributions = calculate_asset_eaf_contributions(plant_result, eq_results)
|
|
|
|
current_plant_eaf = plant_result.get("eaf", 0)
|
|
|
|
current_plant_eaf = plant_result.get("eaf", 0)
|
|
|
|
eaf_gap = target_eaf - current_plant_eaf
|
|
|
|
eaf_gap = target_eaf - current_plant_eaf
|
|
|
|
|
|
|
|
|
|
|
|
|