Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
Adds damage model test case with tuncation limits.
  • Loading branch information
ioannis-vm committed Dec 18, 2024
1 parent ac03c43 commit 85cc691
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,john_vm,Precision-5530,18.12.2024 07:45,file:///home/john_vm/.config/libreoffice/4;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ID,Incomplete,Demand-Type,Demand-Unit,Demand-Offset,Demand-Directional,LS1-Family,LS1-Theta_0,LS1-Theta_1,LS1-TruncateLower,LS1-TruncateUpper,LS1-DamageStateWeights,LS2-Family,LS2-Theta_0,LS2-Theta_1,LS2-TruncateLower,LS2-TruncateUpper,LS2-DamageStateWeights,LS3-Family,LS3-Theta_0,LS3-Theta_1,LS3-TruncateLower,LS3-TruncateUpper,LS3-DamageStateWeights
component.A,0,Peak Interstory Drift Ratio,unitless,0,1,lognormal,0.02,0.3,0.01,0.03,0.950000 | 0.050000,lognormal,0.04,0.3,0.03,0.05,,lognormal,0.08,0.3,0.06,0.1,
35 changes: 35 additions & 0 deletions pelicun/tests/basic/test_damage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,41 @@ def test__load_model_parameters(self, assessment_instance: Assessment) -> None:
),
)

def test__load_model_parameters_with_truncation(
self, assessment_instance: Assessment
) -> None:
damage_model = assessment_instance.damage
path = (
'pelicun/tests/basic/data/model/test_DamageModel/'
'load_model_parameters_with_truncation/damage_db.csv'
)
cmp_set = {
'component.A',
}
damage_model.load_model_parameters([path], cmp_set, warn_missing=False)
pgb = pd.DataFrame(
[[1]], index=(('component.A', '1', '1', '1'),), columns=['Blocks']
)
capacity_sample, _ = damage_model.ds_model._generate_dmg_sample(
sample_size=100, pgb=pgb, scaling_specification=None
)
np.all(
capacity_sample[
'component.A', # cmp
'1', # loc
'1', # dir
'1', # uid
'1', # block
'1', # ls
]
> 0.01
)
np.all(capacity_sample['component.A', '1', '1', '1', '1', '1'] < 0.03)
np.all(capacity_sample['component.A', '1', '1', '1', '1', '2'] > 0.03)
np.all(capacity_sample['component.A', '1', '1', '1', '1', '2'] < 0.05)
np.all(capacity_sample['component.A', '1', '1', '1', '1', '3'] > 0.06)
np.all(capacity_sample['component.A', '1', '1', '1', '1', '3'] < 0.10)

def test__convert_damage_parameter_units(
self, assessment_instance: Assessment
) -> None:
Expand Down

0 comments on commit 85cc691

Please sign in to comment.