|
|
from fastapi import APIRouter, HTTPException |
|
|
from ..models.model_e import CapacityFadeInput |
|
|
from ..logic.calc_e import calculate_all_e |
|
|
|
|
|
router = APIRouter() |
|
|
|
|
|
@router.post("/calculate/e") |
|
|
async def calc_e(input: CapacityFadeInput): |
|
|
cathode_name=input.cathode_name |
|
|
if len(input.cycle_numbers) != len(input.Q_discharge_list): |
|
|
raise HTTPException(400, "cycle_numbers and Q_discharge_list must match length") |
|
|
if len(input.cycle_numbers_imp) != len(input.impedance_list): |
|
|
raise HTTPException(400, "cycle_numbers_imp and impedance_list must match length") |
|
|
if not (0 <= input.SOC_fraction <= 1): |
|
|
raise HTTPException(400, "SOC_fraction must be between 0 and 1") |
|
|
if input.k_fade <= 0 or input.b_fade <= 0: |
|
|
raise HTTPException(400, "k_fade and b_fade must be positive") |
|
|
return calculate_all_e(cathode_name, input.dict()) |
|
|
|