|
|
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 |
|
|
|
|
|
if len(input.V) != len(input.t): |
|
|
raise HTTPException(400, "V and t must be same length") |
|
|
|
|
|
|
|
|
if len(input.C_rates) != len(input.t_discharge): |
|
|
raise HTTPException(400, "C_rates and t_discharge must be same length") |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
return calculate_all_b(cathode_name, input.dict()) |
|
|
|