From 88a754568b9f60f3b51ccf53d5c06b6b776d505d Mon Sep 17 00:00:00 2001
From: Peter Powers <pmpowers@usgs.gov>
Date: Thu, 12 May 2022 15:27:45 -0600
Subject: [PATCH] sp16 and hashash nonlin fixes

---
 .../usgs/earthquake/nshmp/gmm/NgaEast.java    | 34 ++++++++++++++-----
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java b/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java
index 4fd40b2b..9c0ef56c 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/gmm/NgaEast.java
@@ -389,12 +389,28 @@ public abstract class NgaEast implements GroundMotionModel {
 
   public static void main(String[] args) {
     GmmInput in1 = GmmInput.builder().withDefaults().build();
-    GmmInput in2 = GmmInput.builder().withDefaults().zSed(10).build();
-    GroundMotionModel gmm = Gmm.NGA_EAST_2023.instance(Imt.SA1P0);
-    GroundMotion gm1 = GroundMotions.combine(gmm.calc(in1));
-    GroundMotion gm2 = GroundMotions.combine(gmm.calc(in2));
-    System.out.println(gm1);
-    System.out.println(gm2);
+    // GmmInput in2 = GmmInput.builder().withDefaults().zSed(10).build();
+
+    Imt imt = Imt.PGA;
+
+    GroundMotionModel gmm18 = Gmm.NGA_EAST_SEEDS_2018.instance(imt);
+    GroundMotionModel gmm23 = Gmm.NGA_EAST_SEEDS_2023.instance(imt);
+
+    LogicTree<GroundMotion> gmm18lt = gmm18.calc(in1);
+    LogicTree<GroundMotion> gmm23lt = gmm23.calc(in1);
+    System.out.println(gmm18lt);
+    System.out.println(gmm23lt);
+
+    GroundMotion gm18 = GroundMotions.combine(gmm18lt);
+    GroundMotion gm23 = GroundMotions.combine(gmm23lt);
+
+    System.out.println(gm18);
+    System.out.println(gm23);
+
+    // GroundMotion gm1 = GroundMotions.combine(gmm.calc(in1));
+    // GroundMotion gm2 = GroundMotions.combine(gmm.calc(in2));
+    // System.out.println(gm1);
+    // System.out.println(gm2);
   }
 
   /*
@@ -591,8 +607,8 @@ public abstract class NgaEast implements GroundMotionModel {
         double μPga;
 
         if (seed == Gmm.NGA_EAST_SEED_SP16) {
-          μ = sp16.calcMeanRock(in.Mw, in.rRup);
-          μPga = sp16pga.calcMeanRock(in.Mw, in.rRup);
+          μ = sp16.calcMeanRock(in.Mw, in.rJB);
+          μPga = exp(sp16pga.calcMeanRock(in.Mw, in.rJB));
         } else if (imt == Imt.PGV && noPgvSeeds.contains(seed)) {
           // note rock input; TODO this doesn't really work as the PGV
           // is conditioned on vs30 so site should already be applied
@@ -1026,7 +1042,7 @@ public abstract class NgaEast implements GroundMotionModel {
 
       double fNonlin = 0.0;
       if (vs30 < c.vc) {
-        double f2 = c.f4 * (exp(c.f5 * (min(vs30, vRefNl) - 360.0)) -
+        double f2 = calcF4() * (exp(c.f5 * (min(vs30, vRefNl) - 360.0)) -
             exp(c.f5 * (vRefNl - 360.0)));
         fNonlin = f2 * rkRefTerm;
       }
-- 
GitLab