Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

few minor bugfixes and enhancements to support wind pbe #99

Merged
merged 6 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions pelicun/assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
'1_excessive.coll.DEM': {'DS1': 'collapse_DS1'},
'2_collapse': {'DS1': 'ALL_NA'},
'3_excessiveRID': {'DS1': 'irreparable_DS1'},
'4_irreparable': {'DS1': 'ALL_NA'},
'5_irreparable': {'DS1': 'collapse_DS0'},
},
# TODO(AZ): expand with ground failure logic
'Hazus Earthquake': {
Expand Down Expand Up @@ -982,14 +984,14 @@ def calculate_damage( # noqa: C901
component_db = []

if component_database_path is not None:
if custom_model_dir is None:
msg = (
'`custom_model_dir` needs to be specified '
'when `component_database_path` is not None.'
)
raise ValueError(msg)

if 'CustomDLDataFolder' in component_database_path:
if custom_model_dir is None:
msg = (
'`custom_model_dir` needs to be specified '
'when `component_database_path` includes CustomDLDataFolder.'
)
raise ValueError(msg)

component_database_path = component_database_path.replace(
'CustomDLDataFolder', custom_model_dir
)
Expand Down Expand Up @@ -1501,14 +1503,14 @@ def load_consequence_info(
conseq_df = pd.DataFrame()

if consequence_database_path is not None:
if custom_model_dir is None:
msg = (
'When `consequence_database_path` is specified, '
'`custom_model_dir` needs to be specified as well.'
)
raise ValueError(msg)

if 'CustomDLDataFolder' in consequence_database_path:
if custom_model_dir is None:
msg = (
'When `consequence_database_path` includes CustomDLDataFolder, '
'`custom_model_dir` needs to be specified as well.'
)
raise ValueError(msg)

consequence_database_path = consequence_database_path.replace(
'CustomDLDataFolder', custom_model_dir
)
Expand Down
5 changes: 5 additions & 0 deletions pelicun/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,11 @@ def dedupe_index(dataframe: pd.DataFrame, dtype: type = str) -> pd.DataFrame:
'Peak Link Beam Chord Rotation': 'LBR',
# Wind Intensity
'Peak Gust Wind Speed': 'PWS',
# Wind Demands
'Peak Wind Force': 'PWF',
'Peak Internal Force': 'PIF',
'Peak Line Force': 'PLF',
'Peak Wind Pressure': 'PWP',
# Inundation Intensity
'Peak Inundation Height': 'PIH',
# Shaking Intensity
Expand Down
7 changes: 7 additions & 0 deletions pelicun/settings/default_units.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
"kip": 4448.2179868,
"kips": 4448.2179868
},
"line_force": {
"Npm": 1.0,
"kNpm": 1000.0,
"lbpft": 14.5939,
"kippft": 14593.9,
"kipspft": 14593.9
},
"pressure": {
"Pa": 1.0,
"kPa": 1000.0,
Expand Down
20 changes: 5 additions & 15 deletions pelicun/settings/input_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,7 @@
},
"required": [
"DemandType",
"CapacityDistribution",
"CapacityMedian",
"Theta_1"
"CapacityMedian"
]
},
"DamageProcess": {
Expand Down Expand Up @@ -322,9 +320,7 @@
},
"required": [
"Unit",
"Median",
"Distribution",
"Theta_1"
"Median"
]
},
"ReplacementCarbon": {
Expand Down Expand Up @@ -359,9 +355,7 @@
},
"required": [
"Unit",
"Median",
"Distribution",
"Theta_1"
"Median"
]
},
"ReplacementTime": {
Expand Down Expand Up @@ -396,9 +390,7 @@
},
"required": [
"Unit",
"Median",
"Distribution",
"Theta_1"
"Median"
]
},
"ReplacementCost": {
Expand Down Expand Up @@ -433,9 +425,7 @@
},
"required": [
"Unit",
"Median",
"Distribution",
"Theta_1"
"Median"
]
}
}
Expand Down
5 changes: 5 additions & 0 deletions pelicun/tests/basic/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ def test_parse_units() -> None:
'lbf': 4.4482179868,
'kip': 4448.2179868,
'kips': 4448.2179868,
'Npm': 1.0,
'kNpm': 1000.0,
'lbpft': 14.5939,
'kippft': 14593.9,
'kipspft': 14593.9,
'Pa': 1.0,
'kPa': 1000.0,
'MPa': 1000000.0,
Expand Down
8 changes: 8 additions & 0 deletions pelicun/tools/DL_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,14 @@ def _parse_config_file( # noqa: C901

# Ensure `DL/Damage/CollapseFragility` contains all required keys.
if is_specified(config, 'DL/Damage/CollapseFragility'):
if is_unspecified(
config, 'DL/Damage/CollapseFragility/CapacityDistribution'
):
config['DL']['Damage']['CollapseFragility']['CapacityDistribution'] = (
'deterministic'
)
config['DL']['Damage']['CollapseFragility']['Theta_1'] = 'N/A'

for thing in ('CapacityDistribution', 'CapacityMedian', 'Theta_1'):
if is_unspecified(config, f'DL/Damage/CollapseFragility/{thing}'):
msg = (
Expand Down