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

@ -24,7 +24,7 @@ async def get_target_reliability(
"""Get all scope pagination.""" """Get all scope pagination."""
results = await get_simulation_results( results = await get_simulation_results(
simulation_id="76b2c981-c338-4d69-b85b-6977cb47ed41", simulation_id = "f31103ef-1ac8-4c29-8f66-ea9ccf06bd87",
token=token token=token
) )

@ -48,8 +48,8 @@ async def get_all_budget_constrains(
plant_result=plant_result, plant_result=plant_result,
eq_results=eq_results, eq_results=eq_results,
) )
# Create result array of dictionaries # Create result array of dictionaries
result = [ result = [
{ {
@ -91,12 +91,11 @@ 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)
results = defaultdict(float) results = defaultdict(float)
for asset in eq_results: for asset in eq_results:
results[asset['aeros_node']['node_name']] = asset['contribution'] * 100 results[asset['aeros_node']['node_name']] = asset['contribution'] * 100.0
# 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)

@ -904,50 +904,7 @@ class OptimumCostModel:
return None return None
return None return None
"""
Async version of reliability API call with retry logic
Args:
target_date: Date to query
location_tag: Location identifier
max_retries: Maximum number of retry attempts
retry_delay: Initial delay between retries (exponential backoff)
Returns:
Reliability value or None if failed
"""
date_str = target_date.strftime('%Y-%m-%d %H:%M:%S.%f')
url = f"{self.api_base_url}/calculate/reliability/{location_tag}/{date_str}"
for attempt in range(max_retries + 1):
try:
async with self.session.get(url) as response:
if response.status == 200:
data = await response.json()
return data['data']['value']
elif response.status >= 500:
# Server error - may be worth retrying
error_msg = f"Server error {response.status} for {location_tag} on {date_str}"
if attempt < max_retries:
await asyncio.sleep(retry_delay * (2 ** attempt))
continue
else:
# Client error - no point retrying
print(f"API Error for {location_tag} on {date_str}: Status {response.status}")
return None
except aiohttp.ClientError as e:
print(f"Network error for {location_tag} on {date_str} (attempt {attempt + 1}): {e}")
if attempt < max_retries:
await asyncio.sleep(retry_delay * (2 ** attempt))
continue
return None
except Exception as e:
print(f"Unexpected error for {location_tag} on {date_str}: {e}")
return None
return None
async def _get_reliability_equipment_batch( async def _get_reliability_equipment_batch(
self, self,
location_tags: List[str], location_tags: List[str],

@ -40,25 +40,104 @@ def get_overhaul_system_components():
"""Get all overhaul system components with dummy data.""" """Get all overhaul system components with dummy data."""
powerplant_reliability = { powerplant_reliability = {
"Plant Control": 98, "Plant Control": {
"SPS": 98, "availability": 0.9994866529774127,
"Turbine": 98, "efficiency": 0.9994956204510826,
"Generator": 98, "total_uptime": 17523.0,
"Condensate Water": 98, },
"Feedwater System": 98, "SPS": {
"Cooling Water": 98, "availability": 0.9932694501483038,
"SCR": 98, "efficiency": 0.9810193821516867,
"Ash Handling": 98, "total_uptime": 17414.000000000062,
"Air Flue Gas": 98, },
"Boiler": 98, "Turbine": {
"SAC-IAC": 98, "availability": 0.9931553730321733,
"KLH": 98, "efficiency": 0.9666721976783572,
"CL": 98, "total_uptime": 17412.000000000062,
"Desalination": 98, },
"FGD": 98, "Generator": {
"CHS": 98, "availability": 0.9934405658224995,
"SSB": 98, "efficiency": 0.9625424646119242,
"WTP": 98, "total_uptime": 17417.000000000062,
},
"Condensate Water": {
"availability": 0.9934405658224995,
"efficiency": 0.9531653517377116,
"total_uptime": 17417.000000000062,
},
"Feedwater System": {
"availability": 0.9936116814966953,
"efficiency": 0.9687512254370128,
"total_uptime": 17420.000000000062,
},
"Cooling Water": {
"availability": 0.99355464293863,
"efficiency": 0.9749999189617731,
"total_uptime": 17419.000000000062,
},
"SCR": {
"availability": 0.9996577686516085,
"efficiency": 0.9996690612127086,
"total_uptime": 17526.0,
},
"Ash Handling": {
"availability": 0.9931838923112059,
"efficiency": 0.9933669638506657,
"total_uptime": 17412.500000000062,
},
"Air Flue Gas": {
"availability": 0.9906456764773022,
"efficiency": 0.8565868045084128,
"total_uptime": 17368.000000000062,
},
"Boiler": {
"availability": 0.9934976043805648,
"efficiency": 0.9693239775686654,
"total_uptime": 17418.000000000062,
},
"SAC-IAC": {
"availability": 0.9936116814966953,
"efficiency": 0.9878742473840645,
"total_uptime": 17420.000000000062,
},
"KLH": {
"availability": 0.992185717545064,
"efficiency": 0.9426658166507496,
"total_uptime": 17395.000000000062,
},
"CL": {
"availability": 0.9984029203741729,
"efficiency": 0.9984546987034779,
"total_uptime": 17504.0,
},
"Desalination": {
"total_uptime": 17275.500000000062,
"availability": 0.9853696098562663,
"efficiency": 0.9118366404915063,
},
"FGD": {
"availability": 0.9933835272644342,
"efficiency": 0.9623105228919693,
"total_uptime": 17416.000000000062,
},
"CHS": {
"availability": 1.0,
"efficiency": 0.9665857756206829,
"total_uptime": 17532.0,
},
"SSB": {
"availability": 0.9933264887063691,
"efficiency": 0.993508327346586,
"total_uptime": 17415.000000000062,
},
"WTP": {
"availability": 0.9925849874515208,
"efficiency": 0.9925849874515206,
"total_uptime": 17402.000000000062,
},
} }
return powerplant_reliability return powerplant_reliability

@ -211,7 +211,7 @@ async def get_overview_overhaul(*, db_session: DbSession):
"end_date": selected_overhaul.end_date, "end_date": selected_overhaul.end_date,
"duration_oh": selected_overhaul.duration_oh, "duration_oh": selected_overhaul.duration_oh,
"crew_number": selected_overhaul.crew_number, "crew_number": selected_overhaul.crew_number,
"remaining_days": (selected_overhaul.end_date - current_date).days, "remaining_days": (selected_overhaul.start_date - current_date).days,
"equipment_count": len(results.scalars().all()), "equipment_count": len(results.scalars().all()),
}, },
} }

Loading…
Cancel
Save