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

Add Attenuation Model of Campbell Bozorgnia 2003 For All Conditions #10114

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions doc/api-reference/openquake.hazardlib.gsim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,14 @@ campbell_bozorgnia_2003
:undoc-members:
:show-inheritance:

campbell_bozorgnia_2003_world
-------------------------------------------------------

.. automodule:: openquake.hazardlib.gsim.campbell_bozorgnia_2003_world
:members:
:undoc-members:
:show-inheritance:

campbell_bozorgnia_2008
-------------------------------------------------------

Expand Down
237 changes: 237 additions & 0 deletions openquake/hazardlib/gsim/campbell_bozorgnia_2003_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
# -*- coding: utf-8 -*-
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (C) 2014-2023 GEM Foundation
#
# OpenQuake is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenQuake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with OpenQuake. If not, see <http://www.gnu.org/licenses/>.

"""
Module exports :class:`CampbellBozorgnia2003`
class:`CampbellBozorgnia2003Vertical`.
"""
import numpy as np

from openquake.hazardlib.gsim.base import GMPE, CoeffsTable
from openquake.hazardlib import const
from openquake.hazardlib.imt import PGA, SA


def _get_mean(C, mag, rake, dip, rrup, rjb, vs30):
"""
Return mean value (eq. 1, page 319).
"""
f1 = _compute_magnitude_scaling(C, mag)
f2 = _compute_distance_scaling(C, mag, rrup, vs30)
f3 = _compute_faulting_mechanism(C, rake, dip)
f4 = _compute_far_source_soil_effect(C, vs30)
f5 = _compute_hanging_wall_effect(C, rjb, rrup, dip, mag, rake, vs30)
return C['c1'] + f1 + C['c4'] * np.log(np.sqrt(f2)) + f3 + f4 + f5


def _compute_magnitude_scaling(C, mag):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function seems a repetition of https://github.com/gem/oq-engine/blob/master/openquake/hazardlib/gsim/campbell_bozorgnia_2003.py#L41 Another possibility would have been to import this function rather than repeating it

"""
Compute and return magnitude scaling term (eq.2, page 319)
"""
return C['c2'] * mag + C['c3'] * (8.5 - mag) ** 2


def _compute_distance_scaling(C, mag, rrup, vs30):
"""
Compute distance scaling term (eq.3, page 319).

"""
svfs , ssr, sfr = _get_site_type_dummy_variables(vs30)
g = C['c5'] + C['c6'] * (svfs + ssr) + C['c7'] * sfr

return rrup ** 2 + (np.exp(
C['c8'] * mag + C['c9'] * (8.5 - mag) ** 2) * g) ** 2

def _get_site_type_dummy_variables(vs30):

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls remove this space

"""
Get site type dummy variables, four site types are considered
based on the shear wave velocity intervals in the uppermost 30 m, Vs30:
firm soil: 298 < Vs30 <= 368 m/s
very firm soil: 368 < Vs30 <= 421 m/s
soft rock: 421 < Vs30 <= 830 m/s
firm rock: Vs30 > 830 m/s
"""
svfs = np.zeros(len(vs30))
ssr = np.zeros(len(vs30))
sfr = np.zeros(len(vs30))

# very firm soil
idx = (vs30 >= 368) & (vs30 <= 421)
svfs[idx] = 1.0
# soft rock
idx = (vs30 > 421) & (vs30 <= 830)
ssr[idx] = 1.0
# firm rock
idx = (vs30 > 830)
sfr[idx] = 1.0
return svfs, ssr ,sfr

def _compute_faulting_mechanism(C, rake, dip):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"""
Compute faulting mechanism term (see eq. 5, page 319).

Reverse faulting is defined as occurring on steep faults (dip > 45)
and rake in (22.5, 157.5).

Thrust faulting is defined as occurring on shallow dipping faults
(dip <=45) and rake in (22.5, 157.5)
"""
# flag for reverse faulting
frv = (dip > 45) & (22.5 <= rake) & (rake <= 157.5)
# flag for thrust faulting
fth = (dip <= 45) & (22.5 <= rake) & (rake <= 157.5)
return C['c10'] * frv + C['c11'] * fth

def _compute_far_source_soil_effect(C, vs30):
"""
Compute far-source effect of local site conditions (see eq. 6,
page 319).
"""
svfs , ssr, sfr = _get_site_type_dummy_variables(vs30)
return C['c12']*svfs + C['c13']*ssr + C['c14']*sfr


def _compute_hanging_wall_effect(C, rjb, rrup, dip, mag, rake, vs30):
"""
Compute hanging-wall effect (see eq. 7, 8, 9 and 10 page 319).
Considers correct version of equation 8 as given in the erratum and not
in the original paper.
"""
# flag for reverse faulting
frv = (dip > 45) & (22.5 <= rake) & (rake <= 157.5)
# flag for thrust faulting
fth = (dip <= 45) & (22.5 <= rake) & (rake <= 157.5)

svfs , ssr, sfr = _get_site_type_dummy_variables(vs30)

# eq. 8
hw = np.zeros_like(rjb)

idx1 = rjb < 5
svfs = ((svfs*((5 - rjb) / 5))*idx1 + 0.0)*(dip <= 70)
ssr = ((ssr*((5 - rjb) / 5))*idx1 + 0.0)*(dip <= 70)
sfr = ((sfr*((5 - rjb) / 5))*idx1 + 0.0)*(dip <= 70)
hw = svfs+ssr+sfr

# eq. 9
f_m = np.where(mag>6.5, 1, np.where(mag<5.5, 0, mag-5.5))

# eq. 10
f_rrup = C['c15'] + np.zeros_like(rrup)
idx = rrup < 8
f_rrup[idx] *= rrup[idx] / 8

# eq. 7
f_hw = (hw * f_m * f_rrup * (frv + fth))

return f_hw


class CampbellBozorgnia2003(GMPE):
"""
Implements GMPE developed by Kenneth W. Campbell and Yousef Bozorgnia and
published as "Updated Near-Source Ground-Motion (Attenuation) Relations for
the Horizontal and Vertical Components of Peak Ground Acceleration and
Acceleration Response Spectra", Bulletin of the Seismological Society of
America, Vol. 93, No. 1, pp. 314-331, 2003.
"""
#: Supported tectonic region type is 'active shallow crust' (see Abstract)
DEFINED_FOR_TECTONIC_REGION_TYPE = const.TRT.ACTIVE_SHALLOW_CRUST

#: Supported intensity measure types are PGA and SA (see Abstract)
DEFINED_FOR_INTENSITY_MEASURE_TYPES = {PGA, SA}

#: Supported intensity measure component is the geometric mean of two
#: horizontal components (see paragraph 'Strong-Motion Database', page 316)
DEFINED_FOR_INTENSITY_MEASURE_COMPONENT = const.IMC.GEOMETRIC_MEAN

#: Supported standard deviation type is Total (see equations 11, 12 pp. 319
#: 320)
DEFINED_FOR_STANDARD_DEVIATION_TYPES = {const.StdDev.TOTAL}

#: Required site parameter is only Vs30
REQUIRES_SITES_PARAMETERS = {'vs30'}

#: Required rupture parameters are magnitude, rake and dip (eq. 1 and
#: following, page 319).
REQUIRES_RUPTURE_PARAMETERS = {'mag', 'rake', 'dip'}

#: Required distance measure are RRup and Rjb (eq. 1 and following,
#: page 319).
REQUIRES_DISTANCES = {'rrup', 'rjb'}

def compute(self, ctx: np.recarray, imts, mean, sig, tau, phi):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.compute>`
for spec of input and result values.
"""
for m, imt in enumerate(imts):
C = self.COEFFS[imt]
mean[m] = _get_mean(
C, ctx.mag, ctx.rake, ctx.dip, ctx.rrup, ctx.rjb, ctx.vs30)
sig[m] = C['c16'] - np.where(ctx.mag < 7.4, 0.07 * ctx.mag, 0.518)

#: Coefficient table (table 4, page 321. Coefficients for horizontal
#: component SA and for corrected PGA)
COEFFS = CoeffsTable(sa_damping=5, table="""\
IMT c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16
PGA -4.033 0.812 0.036 -1.061 0.041 -0.005 -0.018 0.766 0.034 0.343 0.351 -0.123 -0.138 -0.289 0.370 0.920
0.05 -3.740 0.812 0.036 -1.121 0.058 -0.004 -0.028 0.724 0.032 0.302 0.362 -0.140 -0.158 -0.205 0.370 0.940
0.08 -3.076 0.812 0.050 -1.252 0.121 -0.005 -0.051 0.648 0.040 0.243 0.333 -0.150 -0.196 -0.208 0.370 0.952
0.10 -2.661 0.812 0.060 -1.308 0.166 -0.009 -0.068 0.621 0.046 0.224 0.313 -0.146 -0.253 -0.258 0.370 0.958
0.15 -2.270 0.812 0.041 -1.324 0.212 -0.033 -0.081 0.613 0.031 0.318 0.344 -0.176 -0.267 -0.284 0.370 0.974
0.20 -2.771 0.812 0.030 -1.153 0.098 -0.014 -0.038 0.704 0.026 0.296 0.342 -0.148 -0.183 -0.359 0.370 0.981
0.30 -2.999 0.812 0.007 -1.080 0.059 -0.007 -0.022 0.752 0.007 0.359 0.385 -0.162 -0.157 -0.585 0.370 0.984
0.40 -3.511 0.812 -0.015 -0.964 0.024 -0.002 -0.005 0.842 -0.016 0.379 0.438 -0.078 -0.129 -0.557 0.370 0.987
0.50 -3.556 0.812 -0.035 -0.964 0.023 -0.002 -0.004 0.842 -0.036 0.406 0.479 -0.122 -0.130 -0.701 0.370 0.990
0.75 -3.709 0.812 -0.071 -0.964 0.021 -0.002 -0.002 0.842 -0.074 0.347 0.419 -0.108 -0.124 -0.796 0.331 1.021
1.00 -3.867 0.812 -0.101 -0.964 0.019 0.000 0.000 0.842 -0.105 0.329 0.338 -0.073 -0.072 -0.858 0.281 1.021
1.50 -4.093 0.812 -0.150 -0.964 0.019 0.000 0.000 0.842 -0.155 0.217 0.188 -0.079 -0.056 -0.954 0.210 1.021
2.00 -4.311 0.812 -0.180 -0.964 0.019 0.000 0.000 0.842 -0.187 0.060 0.064 -0.124 -0.116 -0.916 0.160 1.021
3.00 -4.817 0.812 -0.193 -0.964 0.019 0.000 0.000 0.842 -0.200 -0.079 0.021 -0.154 -0.117 -0.873 0.089 1.021
4.00 -5.211 0.812 -0.202 -0.964 0.019 0.000 0.000 0.842 -0.209 -0.061 0.057 -0.054 -0.261 -0.889 0.039 1.021
""")


class CampbellBozorgnia2003Vertical(CampbellBozorgnia2003):

#: Supported intensity measure component is vertical
DEFINED_FOR_INTENSITY_MEASURE_COMPONENT = const.IMC.VERTICAL

#: Coefficient table (table 4, page 321. Coefficients for vertical
#: component SA and for corrected PGA)
COEFFS = CoeffsTable(sa_damping=5, table="""\
IMT c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16
PGA -3.108 0.756 0.000 -1.287 0.142 0.046 -0.040 0.587 0.000 0.253 0.173 -0.135 -0.138 -0.256 0.630 0.975
0.05 -1.918 0.756 0.000 -1.517 0.309 0.069 -0.023 0.498 0.000 0.058 0.100 -0.195 -0.274 -0.219 0.630 1.031
0.08 -1.504 0.756 0.000 -1.551 0.343 0.083 0.000 0.487 0.000 0.135 0.182 -0.224 -0.303 -0.263 0.630 1.031
0.10 -1.672 0.756 0.000 -1.473 0.282 0.062 0.001 0.513 0.000 0.168 0.210 -0.198 -0.275 -0.252 0.630 1.031
0.15 -2.323 0.756 0.000 -1.280 0.171 0.045 0.008 0.591 0.000 0.223 0.238 -0.170 -0.175 -0.270 0.630 1.031
0.20 -2.998 0.756 0.000 -1.131 0.089 0.028 0.004 0.668 0.000 0.234 0.256 -0.098 -0.041 -0.311 0.571 1.031
0.30 -3.721 0.756 0.007 -1.028 0.050 0.010 0.004 0.736 0.007 0.249 0.328 -0.026 0.082 -0.265 0.488 1.031
0.40 -4.536 0.756 -0.015 -0.812 0.012 0.000 0.000 0.931 -0.018 0.299 0.317 -0.017 0.022 -0.257 0.428 1.031
0.50 -4.651 0.756 -0.035 -0.812 0.012 0.000 0.000 0.931 -0.043 0.243 0.354 -0.020 0.092 -0.293 0.383 1.031
0.75 -4.903 0.756 -0.071 -0.812 0.012 0.000 0.000 0.931 -0.087 0.295 0.418 0.078 0.091 -0.349 0.299 1.031
1.00 -4.950 0.756 -0.101 -0.812 0.012 0.000 0.000 0.931 -0.124 0.266 0.315 0.043 0.101 -0.481 0.240 1.031
1.50 -5.073 0.756 -0.150 -0.812 0.012 0.000 0.000 0.931 -0.184 0.171 0.211 -0.038 -0.018 -0.518 0.240 1.031
2.00 -5.292 0.756 -0.180 -0.812 0.012 0.000 0.000 0.931 -0.222 0.114 0.115 0.033 -0.022 -0.503 0.240 1.031
3.00 -5.748 0.756 -0.193 -0.812 0.012 0.000 0.000 0.931 -0.238 0.179 0.159 -0.010 -0.047 -0.539 0.240 1.031
4.00 -6.042 0.756 -0.202 -0.812 0.012 0.000 0.000 0.931 -0.248 0.237 0.134 -0.059 -0.267 -0.606 0.240 1.031
""")
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# The Hazard Library
# Copyright (C) 2013-2023 GEM Foundation
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from openquake.hazardlib.gsim.campbell_bozorgnia_2003_world import (CampbellBozorgnia2003,
CampbellBozorgnia2003Vertical)
from openquake.hazardlib.tests.gsim.utils import BaseGSIMTestCase


class CampbellBozorgnia2003TestCase(BaseGSIMTestCase):
GSIM_CLASS = CampbellBozorgnia2003

# Tables created using EZ-FRISK and an excel calculation file

def test_mean_r(self):
self.check('CB03_W/CB03_MEAN_R_H.csv',
max_discrep_percentage=0.1)

def test_mean_ss(self):
self.check('CB03_W/CB03_MEAN_SS_H.csv',
max_discrep_percentage=0.1)

def test_mean_t(self):
self.check('CB03_W/CB03_MEAN_T_H.csv',
max_discrep_percentage=0.1)

def test_std_tot(self):
self.check('CB03_W/CB03_STD_TOT_H.csv',
max_discrep_percentage=0.1)


class CampbellBozorgnia2003VerticalTestCase(BaseGSIMTestCase):
GSIM_CLASS = CampbellBozorgnia2003Vertical

# Tables created using EZ-FRISK

def test_mean_r(self):
self.check('CB03_W/CB03_MEAN_R_V.csv',
max_discrep_percentage=0.1)

def test_mean_ss(self):
self.check('CB03_W/CB03_MEAN_SS_V.csv',
max_discrep_percentage=0.1)

def test_mean_t(self):
self.check('CB03_W/CB03_MEAN_T_V.csv',
max_discrep_percentage=0.1)

def test_std_tot(self):
self.check('CB03_W/CB03_STD_TOT_V.csv',
max_discrep_percentage=0.1)
31 changes: 31 additions & 0 deletions openquake/hazardlib/tests/gsim/data/CB03_W/CB03_MEAN_R_H.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
rup_mag,rup_rake,rup_dip,dist_rrup,dist_rjb,site_vs30,result_type,damping,PGA,0.1,0.2,0.5,0.75,1,2,4
5,90,50,5,5,400,MEAN,5,0.320054238,0.608846558,0.72222906,0.298806942,0.159394492,0.096120479,0.017046312,0.005030747
5,90,50,10,10,400,MEAN,5,0.167364865,0.364300747,0.393728285,0.15498644,0.082025232,0.049363483,0.008740631,0.002579295
5,90,50,30,30,500,MEAN,5,0.052898215,0.093413714,0.115123106,0.053506741,0.028025307,0.017144613,0.003055649,0.000727236
5,90,50,45,45,500,MEAN,5,0.034474914,0.055786128,0.072519423,0.036204577,0.018959764,0.011598234,0.002067063,0.000491954
5,90,50,60,60,840,MEAN,5,0.02187349,0.038462279,0.043782455,0.015501958,0.00733767,0.004004987,0.000703846,0.000198952
5.5,90,50,5,5,400,MEAN,5,0.397442777,0.657084498,0.857524725,0.488120029,0.297165796,0.198603467,0.045820574,0.014534964
5.5,90,50,10,10,400,MEAN,5,0.218500384,0.421607948,0.509095492,0.258654909,0.154508806,0.10264774,0.023533643,0.007460614
5.5,90,50,30,30,500,MEAN,5,0.070435236,0.114215171,0.15567272,0.089900349,0.052956136,0.035719385,0.008231191,0.002104239
5.5,90,50,45,45,500,MEAN,5,0.045972175,0.068578627,0.098427317,0.0608587,0.035833882,0.024167191,0.005568365,0.00142349
5.5,90,50,60,60,840,MEAN,5,0.029195073,0.047449445,0.059552338,0.026063633,0.013869231,0.008345565,0.001896082,0.000575679
6,90,50,5,5,400,MEAN,5,0.482358074,0.70400581,0.982764521,0.750278309,0.518725541,0.380797968,0.111286027,0.037616331
6,90,50,10,10,400,MEAN,5,0.285536304,0.488901969,0.647377326,0.418750916,0.278589176,0.201643448,0.057741367,0.019461806
6,90,50,30,30,500,MEAN,5,0.095271876,0.143067071,0.212555485,0.148203208,0.096484361,0.070702498,0.020257901,0.005502236
6,90,50,45,45,500,MEAN,5,0.062353003,0.086635024,0.135279833,0.100458989,0.065336484,0.047861802,0.013707318,0.003722809
6,90,50,60,60,840,MEAN,5,0.039665678,0.060281847,0.082167941,0.043047514,0.025294549,0.016531031,0.004667824,0.001505644
6.5,90,50,5,5,400,MEAN,5,0.56484987,0.745945865,1.084780395,1.045710632,0.812498423,0.647625732,0.234639248,0.084037543
6.5,90,50,10,10,400,MEAN,5,0.369027561,0.562721965,0.798552136,0.646262329,0.47358676,0.368791148,0.12766926,0.045325381
6.5,90,50,30,30,500,MEAN,5,0.130623464,0.182885387,0.291760886,0.239142392,0.169181407,0.13272634,0.045492629,0.012986949
6.5,90,50,45,45,500,MEAN,5,0.085932023,0.112253511,0.187879797,0.162664322,0.114828943,0.090020094,0.030816242,0.008795302
6.5,90,50,60,60,840,MEAN,5,0.054844341,0.07883196,0.114929499,0.0698085,0.044491256,0.031112974,0.010498089,0.003558333
7,90,50,5,5,400,MEAN,5,0.633784108,0.780254971,1.158127167,1.292043917,1.092336827,0.92076354,0.392187086,0.147252553
7,90,50,10,10,400,MEAN,5,0.463844997,0.636821035,0.944062307,0.923228939,0.735831295,0.60711526,0.245237174,0.090877633
7,90,50,30,30,500,MEAN,5,0.1807486,0.237033628,0.399456653,0.375592791,0.284104574,0.235129607,0.092772593,0.027540663
7,90,50,45,45,500,MEAN,5,0.120086041,0.148662507,0.262601727,0.257693302,0.194093694,0.160433658,0.06313532,0.018732044
7,90,50,60,60,840,MEAN,5,0.07713402,0.106024611,0.162755104,0.111016103,0.075378132,0.055567912,0.021543447,0.007589979
7.5,90,50,5,5,400,MEAN,5,0.682984019,0.805943571,1.205481898,1.442791591,1.272343071,1.09786913,0.502081533,0.19279511
7.5,90,50,10,10,400,MEAN,5,0.557324696,0.703621142,1.064546786,1.187175064,1.007089086,0.861054719,0.384085884,0.146482045
7.5,90,50,30,30,500,MEAN,5,0.250296532,0.308219613,0.538503951,0.567434781,0.451946875,0.388519344,0.169521125,0.051758769
7.5,90,50,45,45,500,MEAN,5,0.169441445,0.199991259,0.366632306,0.397093332,0.3138774,0.269428903,0.117143276,0.035735618
7.5,90,50,60,60,840,MEAN,5,0.11022932,0.146415886,0.232763294,0.172648055,0.122637656,0.093876565,0.040195341,0.014558568
Loading
Loading