diff --git a/pelicun/tests/basic/data/model/test_DamageModel/load_model_parameters_with_truncation/damage_db.csv b/pelicun/tests/basic/data/model/test_DamageModel/load_model_parameters_with_truncation/damage_db.csv new file mode 100644 index 000000000..9a0646d98 --- /dev/null +++ b/pelicun/tests/basic/data/model/test_DamageModel/load_model_parameters_with_truncation/damage_db.csv @@ -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, diff --git a/pelicun/tests/basic/test_damage_model.py b/pelicun/tests/basic/test_damage_model.py index 655d51b95..e5cce9de5 100644 --- a/pelicun/tests/basic/test_damage_model.py +++ b/pelicun/tests/basic/test_damage_model.py @@ -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: