Skip to content

Inventory Module#

The inventory module provides classes for managing building inventory data and properties.

Class Diagram#

classDiagram
    class BaseBuilding {
        +BldgType: int
        +Story: int
        +Material: int
        +WallFloorCon_FrontBack: int
        +WallFloorCon_Side: int
        +BldgLength: float
        +BldgWidth: float
        +MeanRoofHeight: float
        +WallHeight: float
        +OpeningFront: int
        +OpeningBack: int
        +OpeningSideR: int
        +OpeningSideH: int
        +OpeningLength: float
        +OpeningWidth: float
        +DoorFront: int
        +DoorGarage: int
        +DoorBack: int
        +RoofShape: int
        +RoofPitchDegree: float
        +RoofPitch_r: float
        +RoofHeight: float
        +RoofWidth: float
        +HipRidgeLength: float
        +HipRidgeAngle: float
        +TrussSpacing: float
        +SheathingLength: float
        +SheathingWidth: float
        +update_outputs()
    }

    class Building {
        +PanelCoordinate: np.ndarray
        +NumPanel: np.ndarray
        +ConnectionCoordinate: np.ndarray
        +NumConnection: np.ndarray
        +fn_panel_coordinate()
        +fn_connection_coordinate()
    }

    class BaseBuildingInventory {
        +buildings_file_name: str
        +update_outputs()
    }

    class BuildingInventory {
        +buildings: list[Building]
        +instantiate_buildings_from_json()
    }

    BaseBuilding <|-- Building
    BaseBuildingInventory <|-- BuildingInventory
    BuildingInventory o-- "1..*" Building : contains

Building#

building #

Classes:

Name Description
Building

A class used to represent a Building.

Building dataclass #

Building(
    BldgType: int,
    Story: int,
    Material: int,
    WallFloorCon_FrontBack: int,
    WallFloorCon_Side: int,
    BldgLength: float,
    BldgWidth: float,
    MeanRoofHeight: float,
    WallHeight: float,
    OpeningFront: int,
    OpeningBack: int,
    OpeningSideR: int,
    OpeningSideH: int,
    OpeningLength: float,
    OpeningWidth: float,
    DoorFront: int,
    DoorGarage: int,
    DoorBack: int,
    RoofShape: int,
    RoofPitchDegree: float,
    RoofPitch_r: float,
    RoofHeight: float,
    RoofWidth: float,
    HipRidgeLength: float,
    HipRidgeAngle: float,
    TrussSpacing: float,
    SheathingLength: float,
    SheathingWidth: float,
)

Bases: BaseBuilding

A class used to represent a Building.

Attributes:

Name Type Description
PanelCoordinate ndarray

A 2D array of the panel coordinates

NumPanel ndarray

An array of the number of panels in each row

ConnectionCoordinate ndarray

An array of RWC coordinates

NumConnection ndarray

An array of RWC numbers

Methods:

Name Description
fn_panel_coordinate

Calculate panel coordinates, and number of panels, given building geometry

fn_connection_coordinate

Calculate Roof-to-Wall Connection (RWC) coordinate and numbers

fn_connection_coordinate #

fn_connection_coordinate() -> tuple[ndarray, list[int]]

Calculate the Roof-to-Wall Connection (RWC) coordinates and numbers for a building.

This method determines the RWC coordinates and numbers based on the building's roof shape, length, and width. It supports two types of roof shapes: hip roof (1) and gable roof (2).

Notes

Instance attributes used:

  • RoofShape: The shape of the roof, where 1 represents a hip roof and 2 represents a gable roof.
  • BldgLength: The length of the building.
  • BldgWidth: The width of the building.

Outputs: Updates ConnectionCoordinate and NumConnection.

Returns:

Type Description
tuple[ndarray, list[int]]

tuple[np.ndarray, list[int]]: The roof-to-wall connection coordinates and the number of connections on each side.

Raises:

Type Description
ValueError

If the roof shape is not recognized (i.e., not 1 or 2).

fn_panel_coordinate #

fn_panel_coordinate() -> tuple[ndarray, ndarray]

Calculate panel coordinates, and number of panels, given building geometry.

This method calculates the panel coordinates and the number of panels based on the building geometry. It uses the building's roof shape, sheathing width, and building length to calculate the coordinates.

Notes

Instance attributes used:

  • RoofShape: The roof shape, either 1 for hip roof or 2 for gable roof.
  • SheathingWidth: The width of the sheathing.
  • BldgLength: The length of the building.
  • HipRidgeAngle: The angle of the hip ridge.

Returns:

Type Description
ndarray

np.ndarray: A 2D array of the panel coordinates.

ndarray

np.ndarray: An array of the number of panels in each row.

Raises:

Type Description
ValueError

If the roof shape is not recognized, a ValueError will be raised.

Outputs

None beyond the returned value.

Inventory Handler#

inventory_handler #

Classes:

Name Description
BuildingInventory

A class used to represent a Building Inventory.

BuildingInventory dataclass #

BuildingInventory(
    buildings_file_name: str = "BuildingGeometry_Old.json",
)

Bases: BaseBuildingInventory

A class used to represent a Building Inventory.

Attributes:

Name Type Description
buildings list[Building]

A list of Building objects representing the buildings in the inventory.

Methods:

Name Description
instantiate_buildings_from_json

Instantiates Building objects from a JSON file and stores them in the buildings attribute.

instantiate_buildings_from_json #

instantiate_buildings_from_json()

Instantiates Building objects from a JSON file and stores them in the buildings attribute.

The method reads a JSON file from the directory specified in the dir_of_buildings attribute, creates Building objects from the data, and stores them in the buildings attribute.

Notes

Instance attributes used:

  • dir_of_buildings (str): The directory where the building data is stored.
  • buildings (list[Building]): A list of Building objects representing the buildings in the inventory.

Raises:

Type Description
FileNotFoundError

If the JSON file cannot be found at the specified directory.

Base Classes#

base #

Classes:

Name Description
BaseBuilding

A base class for the Building class.

BaseBuildingInventory

A base class for the BuildingInventory class.

BaseBuilding dataclass #

BaseBuilding(
    BldgType: int,
    Story: int,
    Material: int,
    WallFloorCon_FrontBack: int,
    WallFloorCon_Side: int,
    BldgLength: float,
    BldgWidth: float,
    MeanRoofHeight: float,
    WallHeight: float,
    OpeningFront: int,
    OpeningBack: int,
    OpeningSideR: int,
    OpeningSideH: int,
    OpeningLength: float,
    OpeningWidth: float,
    DoorFront: int,
    DoorGarage: int,
    DoorBack: int,
    RoofShape: int,
    RoofPitchDegree: float,
    RoofPitch_r: float,
    RoofHeight: float,
    RoofWidth: float,
    HipRidgeLength: float,
    HipRidgeAngle: float,
    TrussSpacing: float,
    SheathingLength: float,
    SheathingWidth: float,
)

A base class for the Building class.

Attributes:

Name Type Description
BldgType int

The building type

Story int

The number of stories in the building

Material int

The material of the building

WallFloorCon_FrontBack int

The connection between the front and back walls

WallFloorCon_Side int

The connection between the side walls

BldgLength float

The length of the building

BldgWidth float

The width of the building

MeanRoofHeight float

The mean height of the roof

WallHeight float

The height of the walls

OpeningFront int

The width and height of the front opening

OpeningBack int

The width and height of the back opening

OpeningSideR int

The width and height of the right opening

OpeningSideH int

The width and height of the left opening

OpeningLength float

The length of the opening

OpeningWidth float

The width of the opening

DoorFront int

The width and height of the front door

DoorGarage int

The width and height of the garage door

DoorBack int

The width and height of the back door

RoofShape int

The shape of the roof

RoofPitchDegree float

The pitch of the roof in degrees

RoofPitch_r float

The pitch of the roof in radians

RoofHeight float

The height of the roof

RoofWidth float

The width of the roof

HipRidgeLength float

The length of the hip ridge

HipRidgeAngle float

The angle of the hip ridge

TrussSpacing float

The spacing of the trusses

SheathingLength float

The length of the sheathing

SheathingWidth float

The width of the sheathing

Methods:

Name Description
update_outputs

Updates the outputs of the class object by calling the __post_init__ method.

update_outputs #

update_outputs() -> None

Updates the outputs of the class object by calling the __post_init__ method. This method can be called when a change is made to some of the inputs of the class.

Outputs

Performs initialization or configuration side effects described above.

Returns:

Type Description
None

None

BaseBuildingInventory dataclass #

BaseBuildingInventory(
    buildings_file_name: str = "BuildingGeometry_Old.json",
)

A base class for the BuildingInventory class.

Attributes:

Name Type Description
dir_of_buildings str

The directory where the building data is stored.

Methods:

Name Description
update_outputs

Updates the outputs of the class object by calling the __post_init__ method.

update_outputs #

update_outputs() -> None

Updates the outputs of the class object by calling the __post_init__ method. This method can be called when a change is made to some of the inputs of the class.

Outputs

Performs initialization or configuration side effects described above.

Returns:

Type Description
None

None