Source code for openquake.hazardlib.gsim.campbell_bozorgnia_2003_world
# -*- 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`."""importnumpyasnpfromopenquake.hazardlib.gsim.baseimportGMPE,CoeffsTablefromopenquake.hazardlibimportconstfromopenquake.hazardlib.imtimportPGA,SAfromopenquake.hazardlib.gsim.campbell_bozorgnia_2003import(_compute_magnitude_scaling,_compute_faulting_mechanism)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)returnC['c1']+f1+C['c4']*np.log(np.sqrt(f2))+f3+f4+f5def_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']*sfrreturnrrup**2+(np.exp(C['c8']*mag+C['c9']*(8.5-mag)**2)*g)**2def_get_site_type_dummy_variables(vs30):""" 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 soilidx=(vs30>=368)&(vs30<=421)svfs[idx]=1.0# soft rockidx=(vs30>421)&(vs30<=830)ssr[idx]=1.0# firm rockidx=(vs30>830)sfr[idx]=1.0returnsvfs,ssr,sfrdef_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)returnC['c12']*svfs+C['c13']*ssr+C['c14']*sfrdef_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 faultingfrv=(dip>45)&(22.5<=rake)&(rake<=157.5)# flag for thrust faultingfth=(dip<=45)&(22.5<=rake)&(rake<=157.5)svfs,ssr,sfr=_get_site_type_dummy_variables(vs30)# eq. 8hw=np.zeros_like(rjb)idx1=rjb<5svfs=((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. 9f_m=np.where(mag>6.5,1,np.where(mag<5.5,0,mag-5.5))# eq. 10f_rrup=C['c15']+np.zeros_like(rrup)idx=rrup<8f_rrup[idx]*=rrup[idx]/8# eq. 7f_hw=(hw*f_m*f_rrup*(frv+fth))returnf_hw
[docs]classCampbellBozorgnia2003(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 Vs30REQUIRES_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'}
[docs]defcompute(self,ctx:np.recarray,imts,mean,sig,tau,phi):""" See :meth:`superclass method <.base.GroundShakingIntensityModel.compute>` for spec of input and result values. """form,imtinenumerate(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)