tueniuu's picture
Upload 48 files
78fefe8 verified
from fastapi import APIRouter, HTTPException
from ..models.model_b import AllBInput
from ..logic.calc_b import calculate_all_b
router = APIRouter()
@router.post("/calculate/all")
def calculate_b(input: AllBInput):
cathode_name = input.cathode_name
# 1) V–Q / dQdV arrays
if len(input.V) != len(input.t):
raise HTTPException(400, "V and t must be same length")
# 2) Rate‑capability arrays
if len(input.C_rates) != len(input.t_discharge):
raise HTTPException(400, "C_rates and t_discharge must be same length")
# 3) GITT‑diffusion arrays
if len(input.delta_E_tau) != len(input.delta_E_s):
raise HTTPException(400, "delta_E_tau and delta_E_s must be same length")
# All validations passed, compute everything
return calculate_all_b(cathode_name, input.dict())