Skip to content

Commit

Permalink
Merge pull request #69 from ioannis-vm/2024-10_capacity_scaling
Browse files Browse the repository at this point in the history
Capacity scaling: available via `DL_calculation.py`
  • Loading branch information
zsarnoczay authored Oct 29, 2024
2 parents 3333110 + 8084275 commit a796075
Show file tree
Hide file tree
Showing 7 changed files with 374 additions and 3 deletions.
18 changes: 15 additions & 3 deletions pelicun/assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ def calculate_damage( # noqa: C901
damage_process_approach: str | None = None,
damage_process_file_path: str | None = None,
custom_model_dir: str | None = None,
scaling_specification: dict | None = None,
*,
is_for_water_network_assessment: bool = False,
) -> None:
Expand All @@ -929,8 +930,6 @@ def calculate_damage( # noqa: C901
Optional path to a component database file.
collapse_fragility: dict or None
Collapse fragility information.
is_for_water_network_assessment: bool
Whether the assessment is for a water network.
irreparable_damage: dict or None
Information for irreparable damage.
damage_process_approach: str or None
Expand All @@ -939,6 +938,16 @@ def calculate_damage( # noqa: C901
Optional path to a damage process file.
custom_model_dir: str or None
Optional directory for custom models.
scaling_specification: dict, optional
A dictionary defining the shift in median.
Example: {'CMP-1-1': '*1.2', 'CMP-1-2': '/1.4'}
The keys are individual components that should be present
in the `capacity_sample`. The values should be strings
containing an operation followed by the value formatted as
a float. The operation can be '+' for addition, '-' for
subtraction, '*' for multiplication, and '/' for division.
is_for_water_network_assessment: bool
Whether the assessment is for a water network.
Raises
------
Expand Down Expand Up @@ -1210,7 +1219,10 @@ def calculate_damage( # noqa: C901
)

# calculate damages
self.damage.calculate(dmg_process=dmg_process)
self.damage.calculate(
dmg_process=dmg_process,
scaling_specification=scaling_specification,
)

def calculate_loss(
self,
Expand Down
87 changes: 87 additions & 0 deletions pelicun/tests/dl_calculation/e1_no_autopop/8000-AIM.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"GeneralInformation": {
"NumberOfStories": 1,
"YearBuilt": 1900,
"StructureType": "C1",
"OccupancyClass": "EDU1",
"units": {
"force": "kips",
"length": "ft",
"time": "sec"
},
"DesignLevel": "LC",
"BuildingRise": "L"
},
"assetType": "Buildings",
"Applications": {
"DL": {
"ApplicationData": {
"ground_failure": false
}
}
},
"DL": {
"Asset": {
"ComponentAssignmentFile": "CMP_QNT.csv",
"ComponentDatabase": "Hazus Earthquake - Buildings",
"NumberOfStories": "1",
"OccupancyType": "EDU1",
"PlanArea": "1"
},
"Damage": {
"DamageProcess": "Hazus Earthquake",
"ScalingSpecification": {"LF.C1.L.LC-1-1": "*1.2", "collapse-0-1": "*1.2"}
},
"Demands": {
"DemandFilePath": "response.csv",
"SampleSize": "100",
"CoupledDemands": true
},
"Losses": {
"Repair": {
"ConsequenceDatabase": "Hazus Earthquake - Buildings",
"MapApproach": "Automatic"
}
},
"Options": {
"NonDirectionalMultipliers": {
"ALL": 1.0
}
},
"Outputs": {
"Demand": {
"Sample": true,
"Statistics": false
},
"Asset": {
"Sample": true,
"Statistics": false
},
"Damage": {
"Sample": false,
"Statistics": false,
"GroupedSample": true,
"GroupedStatistics": true
},
"Loss": {
"Repair": {
"Sample": true,
"Statistics": true,
"GroupedSample": true,
"GroupedStatistics": false,
"AggregateSample": true,
"AggregateStatistics": true
}
},
"Format": {
"CSV": false,
"JSON": true
},
"Settings": {
"CondenseDS": true,
"SimpleIndexInJSON": true,
"AggregateColocatedComponentResults": true
}
}
}
}
2 changes: 2 additions & 0 deletions pelicun/tests/dl_calculation/e1_no_autopop/CMP_QNT.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
,Units,Location,Direction,Theta_0,Family
LF.C1.L.LC,ea,1,1,1,N/A
33 changes: 33 additions & 0 deletions pelicun/tests/dl_calculation/e1_no_autopop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2018 Leland Stanford Junior University
# Copyright (c) 2018 The Regents of the University of California
#
# This file is part of pelicun.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# You should have received a copy of the BSD 3-Clause License along with
# pelicun. If not, see <http://www.opensource.org/licenses/>.
101 changes: 101 additions & 0 deletions pelicun/tests/dl_calculation/e1_no_autopop/response.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
,1-PGA-1-1
0.000000000000000000e+00,6.849029933956130911e+00
1.000000000000000000e+00,1.237134226051886543e+01
2.000000000000000000e+00,1.972131621939452018e+01
3.000000000000000000e+00,9.152152931865703778e+00
4.000000000000000000e+00,4.762545330142875954e+00
5.000000000000000000e+00,5.119594082152485903e+00
6.000000000000000000e+00,8.985259370480688901e+00
7.000000000000000000e+00,5.800429585653212428e+00
8.000000000000000000e+00,6.721154036788936637e+00
9.000000000000000000e+00,1.180442967680789756e+01
1.000000000000000000e+01,1.757573848172475195e+01
1.100000000000000000e+01,2.408892253534509109e+01
1.200000000000000000e+01,5.366956767518109572e+00
1.300000000000000000e+01,6.689460282908749278e+00
1.400000000000000000e+01,9.837892431968002782e+00
1.500000000000000000e+01,3.108201101576595793e+00
1.600000000000000000e+01,7.969306015954598976e+00
1.700000000000000000e+01,6.239227951703175457e+00
1.800000000000000000e+01,1.265503535460110918e+01
1.900000000000000000e+01,5.152699658386873161e+00
2.000000000000000000e+01,8.945841984822743953e+00
2.100000000000000000e+01,5.271650608692700857e+00
2.200000000000000000e+01,1.217883862654925764e+01
2.300000000000000000e+01,4.565064448801355645e+00
2.400000000000000000e+01,2.827185963889101927e+01
2.500000000000000000e+01,8.360633657235220895e+00
2.600000000000000000e+01,1.771275449651086475e+01
2.700000000000000000e+01,1.353470186586244495e+01
2.800000000000000000e+01,1.585083782737845048e+01
2.900000000000000000e+01,7.743412977553257193e+00
3.000000000000000000e+01,1.673262791659537640e+01
3.100000000000000000e+01,1.125514571474493408e+01
3.200000000000000000e+01,6.706408356999864928e+00
3.300000000000000000e+01,7.770377729315534943e+00
3.400000000000000000e+01,9.665443132282717897e+00
3.500000000000000000e+01,1.723980753309739811e+01
3.600000000000000000e+01,1.291221957249968177e+01
3.700000000000000000e+01,5.012730578330669040e+00
3.800000000000000000e+01,1.143700619441758626e+01
3.900000000000000000e+01,1.252350066480562596e+01
4.000000000000000000e+01,6.383801705492390788e+00
4.100000000000000000e+01,8.314748267032781470e+00
4.200000000000000000e+01,8.332817023133479495e+00
4.300000000000000000e+01,7.344179823126522066e+00
4.400000000000000000e+01,1.645381636611937282e+01
4.500000000000000000e+01,1.204983450209533657e+01
4.600000000000000000e+01,1.165673673862969828e+01
4.700000000000000000e+01,7.513555832366318299e+00
4.800000000000000000e+01,2.024437216200684730e+01
4.900000000000000000e+01,8.920834603836945931e+00
5.000000000000000000e+01,1.080188057233199572e+01
5.100000000000000000e+01,6.199736427905365943e+00
5.200000000000000000e+01,1.372165205481582362e+01
5.300000000000000000e+01,7.684718998480578378e+00
5.400000000000000000e+01,5.171043463741079371e+00
5.500000000000000000e+01,2.111664537027713706e+01
5.600000000000000000e+01,1.019006581042710913e+01
5.700000000000000000e+01,4.275116867520939223e+00
5.800000000000000000e+01,1.899195644078132261e+01
5.900000000000000000e+01,1.213049449493617438e+01
6.000000000000000000e+01,4.832690227828255303e+00
6.100000000000000000e+01,3.791254293305350132e+00
6.200000000000000000e+01,8.030002531225640894e+00
6.300000000000000000e+01,1.163245027176597013e+01
6.400000000000000000e+01,2.171715232778592508e+01
6.500000000000000000e+01,7.206784171136174422e+00
6.600000000000000000e+01,4.534544778468278636e+00
6.700000000000000000e+01,8.180354349576319350e+00
6.800000000000000000e+01,2.096016461144264653e+01
6.900000000000000000e+01,1.020904287768493468e+01
7.000000000000000000e+01,3.578274393687075783e+00
7.100000000000000000e+01,1.207216137873451700e+01
7.200000000000000000e+01,1.899808690168648084e+01
7.300000000000000000e+01,1.447931410453573520e+01
7.400000000000000000e+01,4.652951138159096445e+00
7.500000000000000000e+01,9.959855894302648949e+00
7.600000000000000000e+01,4.533117400993131874e+00
7.700000000000000000e+01,7.248896994573899910e+00
7.800000000000000000e+01,8.842184263094427621e+00
7.900000000000000000e+01,4.215076299759047629e+00
8.000000000000000000e+01,1.529557773187450032e+01
8.100000000000000000e+01,4.175349145066248546e+00
8.200000000000000000e+01,1.009543326050395251e+01
8.300000000000000000e+01,8.690186504818180779e+00
8.400000000000000000e+01,1.547032449114289854e+01
8.500000000000000000e+01,7.042901121410118925e+00
8.600000000000000000e+01,4.125904243435575935e+00
8.700000000000000000e+01,1.376223081867616571e+01
8.800000000000000000e+01,7.388148474784416386e+00
8.900000000000000000e+01,1.453892207787288093e+01
9.000000000000000000e+01,1.299062984361380124e+01
9.100000000000000000e+01,6.391741821717948469e+00
9.200000000000000000e+01,8.088304936390127153e+00
9.300000000000000000e+01,2.300799414165177481e+01
9.400000000000000000e+01,1.575348473932006321e+01
9.500000000000000000e+01,1.019287352203471109e+01
9.600000000000000000e+01,1.786715222266329661e+01
9.700000000000000000e+01,1.328402105666898869e+01
9.800000000000000000e+01,5.457579231912252915e+00
9.900000000000000000e+01,5.857004480627420406e+00
Loading

0 comments on commit a796075

Please sign in to comment.