Skip to content

FragilityCalculator#

FragilityCalculator extends vulnerability analysis with exceedance-style fragility curves. Use it when you need probability curves for grouped damage states at selected damage-ratio thresholds.

Inputs#

FragilityCalculator uses the same probability dictionary, wind grid, flood grid, and damage-state table as VulnerabilityCalculator.

Additional inputs:

Input Default Units or indexing
ds_thresholds [0.03, 0.09, 0.22, 0.46] Damage-ratio thresholds, unitless fractions.
line_styles built-in list Matplotlib style strings for plotting.

The calculation uses prob_damage_states[(building_type, resistance_type)][:, 0, :], so flood-depth index 0 is used for wind fragility.

Outputs And Returns#

calculate_fragility_curves() returns a dictionary:

Key Shape Meaning
wind_speed [wind] Wind speeds in mph.
DS0 [wind] Probability associated with exceeding the lowest damage group.
DS1, DS2, ... [wind] Curves derived from ds_thresholds.

plot_fragility_curves(save_path=None) returns a matplotlib figure and optionally writes an image file.

Configuration Behavior#

With AUTO_LOAD_DATASETS=True, all datasets load at construction. With False, call the inherited load_* methods first.

With AUTO_EXECUTE_METHODS=True, construction computes inherited vulnerability outputs and fragility_curves. With False, call calculate_vulnerability_curve() and calculate_fragility_curves() manually.

Minimal Examples#

Automatic:

from cheersafe.config import Config
from cheersafe.damage_probability_analysis import FragilityCalculator

Config.AUTO_LOAD_DATASETS = True
Config.AUTO_EXECUTE_METHODS = True

fragility = FragilityCalculator(
    building_type=1,
    resistance_type=1,
    prob_ds_file_path="Outputs/ProbDS_wfd_dictMaxIter50_aggregated.pkl",
)
curves = fragility.fragility_curves

Manual control:

from cheersafe.config import Config
from cheersafe.damage_probability_analysis import FragilityCalculator

Config.AUTO_LOAD_DATASETS = False
Config.AUTO_EXECUTE_METHODS = False

fragility = FragilityCalculator(
    building_type=1,
    resistance_type=1,
    prob_ds_file_path="Outputs/ProbDS_wfd_dictMaxIter50_aggregated.pkl",
)
fragility.load_prob_damage_states()
fragility.load_wind_speed()
fragility.load_flood_depth()
fragility.load_damage_state()
fragility.expected_damage_ratio, fragility.vulnerability_curve = (
    fragility.calculate_vulnerability_curve()
)
curves = fragility.calculate_fragility_curves()