From 91cfff72e0073c97dd59de3041b32edd6d0ef5d8 Mon Sep 17 00:00:00 2001 From: Logan Ward Date: Fri, 8 Nov 2024 15:20:49 -0500 Subject: [PATCH] Start developing a schema based on Irving's metadata --- battdat/schemas/common.py | 26 ++++++++++++++++++++++++++ battdat/schemas/system.py | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 battdat/schemas/common.py create mode 100644 battdat/schemas/system.py diff --git a/battdat/schemas/common.py b/battdat/schemas/common.py new file mode 100644 index 0000000..4b91a79 --- /dev/null +++ b/battdat/schemas/common.py @@ -0,0 +1,26 @@ +"""Schemas used in multiple places""" +from typing import Literal + +from pydantic import BaseModel, Field + +class Dimensions(BaseModel): + """Dimensions of a physical object""" + + shape: str = Field(..., description='Overall shape of an object') + units: str = Field(..., description='Units for all dimensions') + + + +class Cylinder(Dimensions): + """Dimensions of a cylindrical object""" + shape: Literal['cylinder'] = 'cylinder' + radius: float = Field(..., description='Radius of the base') + height: float = Field(..., description='Length of the cylinder') + + +class RectangularPrism(Dimensions): + """Dimensions of a cylindrical object""" + shape: Literal['rectangular'] = 'rectangular' + length: float = Field(..., description='Length of one axis') + width: float = Field(..., description='Radius of the base') + height: float = Field(..., description='Length of the cylinder') diff --git a/battdat/schemas/system.py b/battdat/schemas/system.py new file mode 100644 index 0000000..8683e33 --- /dev/null +++ b/battdat/schemas/system.py @@ -0,0 +1,35 @@ +"""Metadata describing a battery system""" +from typing import Optional + +from pydantic import BaseModel, Field + +from .battery import BatteryDescription +from .common import Dimensions + + +class SystemDescription(BaseModel, allow_extras=True): + """Metadata for a battery system which includes multiple racks of modules""" + + # High-level description of the system + name: str = Field(..., description="Simple description of the battery") + rated_power: Optional[float] = Field(..., description="Nameplate power of the system (units: kVA)") + rated_energy: Optional[float] = Field(..., description="Nameplate power of the system (units: kWh)") + + # Operation limits for the system + operating_temperature_min: Optional[float] = Field(..., description='Minimum suggested operation temperature. (units: C)') + operating_temperature_max: Optional[float] = Field(..., description='Maximum suggested operation temperature. (units: C)') + soc_limit_min: Optional[float] = Field(..., description='Minimum suggested state of charge. (units: %)') + soc_limit_max: Optional[float] = Field(..., description='Maximum suggested state of charge. (units: %)') + + +class PowerConversionSpecification(BaseModel, allow_extras=True): + """Specification of the Power Conversion System Between Battery and external grid""" + + pass + + +class RackSpecification(BaseModel, allow_extras=True): + cell_spec: BatteryDescription = Field(default_factory=BatteryDescription, + description='Description of individual cells within the assembly') + + dimensions: Optional[Dimensions] = Field(description='Physical extent of the rack')