Skip to content

Damage Ratio Calculation#

The cheersafe.damage_ratio_calculation classes convert final component failure states into explicit wind damage ratios, implicit wind damage ratios, implicit flood damage ratios, and weighted building damage ratios.

Use these classes after a cheersafe.loads.LoadingAndFailureCheck object has produced final loads and final resistances for one building, component configuration, flood depth, wind orientation, wind speed, and resistance sample.

Related API: Damage Ratio Calculation API Related notebook: Fragility Curve Calculation with Detailed Damage Ratio Analysis

Class Pages#

Shared Inputs#

All classes require:

  • Building: a cheersafe.inventory.Building. Damage-ratio weighting uses Building.BldgType; implicit wind also uses Building.Story.
  • FailureChecks: a cheersafe.loads.LoadingAndFailureCheck or compatible object with get_final_resistance().
  • ComponentConfigurationIndex: zero-based row index into Inputs/ComponentCombination_All.json; valid range is 0 to 191 for the current dataset.
  • FloodDepthIndex: zero-based row index into the flood-depth dimension of ProbDS_Flood; the current probability file has 136 flood-depth rows.
  • Optional rng: seed, NumPy generator, or compatible random source used by stochastic implicit damage methods.

Dataset Loading#

With Config.AUTO_LOAD_DATASETS = True, BaseDamageRatio.__post_init__ loads:

  • Inputs/ProbDS_Flood.json, shape (8, 4, 136, 6).
  • Inputs/ComponentCombination_All.json, shape (192, 6).
  • Inputs/DamageState_Flood.json, shape (6, 2).
  • Inputs/ReplacementRatio.json, shape (8, 9).

With AUTO_LOAD_DATASETS = False, call the load_* methods or assign the arrays/dictionaries before executing damage-ratio methods that use them.

Method Execution#

With Config.AUTO_EXECUTE_METHODS = True, constructors calculate and assign class outputs. With it disabled, call methods manually and assign returned values explicitly.

import numpy as np
from cheersafe.damage_ratio_calculation import DamageRatioCalculation
from cheersafe.inventory import BuildingInventory
from cheersafe.loads import LoadingAndFailureCheck
from cheersafe.tools import Utils

building = BuildingInventory(buildings_file_name="BuildingGeometry.json").buildings[0]
mean = Utils.from_json("Inputs/MeanResistanceValue.json")
failure = LoadingAndFailureCheck(
    np.full(sum(building.NumPanel), mean[1, 0]),
    np.full(sum(building.NumPanel), mean[0, 0]),
    np.full(sum(building.NumConnection), mean[2, 0]),
    np.full(building.DoorFront + building.DoorBack + building.DoorGarage
            + building.OpeningFront + building.OpeningBack
            + 2 * (building.OpeningSideR + building.OpeningSideH), mean[3, 0]),
    np.full(12, mean[4, 0]),
    building,
    0,
    50,
)
ratio = DamageRatioCalculation(building, failure, 0, 0, rng=1234)
print(ratio.get_building_damage_ratio())