Newer
Older
%% nshmp-haz Ground Motion Model (GMM) calculator example script
% =========================================================================

Powers, Peter M.
committed
% This script provides instruction on how to access ground motion models
% (GMMs) implemented in the nshmp-haz library.

Powers, Peter M.
committed
% See the README for instructions on how to set up Matlab to use nshmp-haz.
% =========================================================================
% Specify path to nshmp-haz library:
nshmpHaz = '/path/to/repository/nshmp-haz/dist/nshmp-haz.jar';
% Make Matlab aware of nshmp-haz by adding it to the 'dynamic' classpath:
javaaddpath(nshmpHaz);
% Alternatively, one can add nshmp-haz to the faster 'static' classpath by
% saving a file with the name `javaclasspath.txt` to the Matlab preferences
% directory, as specified by the `prefdir` command, and with single line:
%
% /path/to/repository/nshmp-haz/dist/nshmp-haz.jar
%
% Although the static classpath is generally a little faster, you must
% restart Matlab any time nshmp-haz.jar is rebuilt with updated code.

Powers, Peter M.
committed
% =========================================================================
% Single model ground motion calculation:
% Initialize calculator:
hazMat = HazMat.init(nshmpHaz);

Powers, Peter M.
committed
% Note that hazMat is stateless and reusable and should therefore be
% initialized external to this script if doing many calculations.

Powers, Peter M.
committed
% Set up a GMM input parameter object. These data are a source and site
% parameterization that will satisfy all currently implemented Gmms. Note
% that not all models will necessarily use all parameters.
input = GmmParams();
input.Mw = 6.5; % moment magnitude
input.rJB = 5.0; % Joyner-Boore distance
input.rRup = 5.1; % distance to closest point on rupture surface
input.rX = 5.1; % distance from source trace; hanging (+); foot (-) wall
input.dip = 90.0; % in degrees
input.width = 10.0; % in km
input.zTop = 1.0; % in km
input.zHyp = 6.0; % in km
input.rake = 0.0; % in degrees
input.vs30 = 760.0; % in m/s
input.z2p5 = NaN; % in km; NaN triggers default basin depth model
input.z1p0 = NaN; % in km; NaN triggers default basin depth model

Powers, Peter M.
committed
% Specify a ground motion model. GMM identifiers:
% https://earthquake.usgs.gov/nshmp/docs/nshmp-lib/gov/usgs/earthquake/nshmp/gmm/Gmm.html
% Specify an intensity measure type (IMT). IMT identifiers:
% https://earthquake.usgs.gov/nshmp/docs/nshmp-lib/gov/usgs/earthquake/nshmp/gmm/Imt.html

Powers, Peter M.
committed
% Do a calculation. The MatUtil.calc(gmm, imt, gmmInput) method returns an
result = hazMat.gmmMean(gmm, imt, input)
% =========================================================================
% Determinisitic response spectrum calculation:

Powers, Peter M.
committed
% The object returned by the MatUtil.spectrum(gmm, gmmInput) method may
% be dumped into a struct.
spectrumResult = struct(hazMat.gmmSpectrum(gmm, input))
% =========================================================================