Home ] Up ]

C-Codes For Empirical Relationships for PGA

//PGAValues.cpp: to estimate Maximum values of PGA Using Empirical Relationships.

#include <stdio.h>

#include <math.h>

main()

{

 double pgavalue(int,double,double,double ,double);

 double xm,re;

 double s;//1.0 for rock sites and 0.0 for soil sites

 double depth;//depth of the earthquake

 char* erlist[20];

 

      erlist[0] =" 1.Milne & Davenport (1969)";

      erlist[1] =" 2.Mickey (1971)";

      erlist[2] =" 3.Davenport (1972)";

      erlist[3] =" 4.Donovan,Worldwide (1973)";

      erlist[4] =" 5.Donovan,Western North America (1974)";

      erlist[5] =" 6.McGuire (1974)";

      erlist[6] =" 7.Orphal & Lahoud (1974)";

      erlist[7] =" 8.Esteva & Villaverde (1974)";

      erlist[8] =" 9.McGuire (1978)";

      erlist[9]="10.Cornell, Banon & Shakal (1979)";

      erlist[10]="11.Espinosa (1980)";

      erlist[11]="12.Batis, California (1981)";

      erlist[12]="13.Campbell (1981)";

      erlist[13]="14.Hasegava, Basham & Berry,E.Canada (1981)";

      erlist[14]="15.Hasegava, Basham & Berry ,W.Canada(1981)";

      erlist[15]="16.Joyner & Boore (1981)";

      erlist[16]="17.Nuttli & Herman (1984)";

 

      printf(" Enter Earthquake Parameters: \n");

      printf("       Magnitude: ");

      scanf("%lf",&xm);

      printf("       Epicentral Distance: ");

      scanf("%lf",&re);

      printf("       Depth of focus: ",&depth);

      scanf("%d",&depth);

      printf(" Enter 1 for rock site 0 for soil site: ");

      int sc;

      scanf("%d",&sc);

      s=(long)sc;

      for (int i=1;i<17;i++)

      {

            double aa=pgavalue(i,xm,re,depth,s);

            printf(" %50s   aa= %lf \n",erlist[i-1],aa);

      }

 

      return 0;

}

double pgavalue(int ernumber,double xm,double re,double depth,double s)

{

    double aa,rh;

    rh=sqrt(re*re+depth*depth);

      switch(ernumber)

      {

      case 1:

    aa=(0.69/100.0)*exp(1.64*xm)/(1.1*exp(1.1*xm)+re*re);

    break;

      case 2:

        aa=3.04*pow(10.0,(0.74*xm-4.0))/pow(rh,1.4);

          break;

      case 3:

        aa=(0.279/1000.0)*exp(1.8*xm)/pow(re,1.64);

          break;

      case 4:

          aa=(1320.0/1000.0)*exp(0.58*xm)/pow(re+25.0,1.52);

          break;

      case 5:

        aa=(1080.0/1000.0)*exp(0.5*xm)/pow(rh,1.32);

          break;

      case 6:

        aa=(472.0/1000.0)*pow(10.0,0.28*xm)/pow(rh+25.0,1.3);

          break;

      case 7:

        aa=0.066*pow(10.0,0.4*xm)/pow(rh,1.39);

          break;

      case 8:

        aa=(5600.0/1000.0)*exp(0.8*xm)/pow(rh+40.0,2.0);

          break;

      case 9:

          aa=(0.0306*exp(0.89*xm)/(pow(rh,1.17)))*exp(-0.2*s);

          break;

      case 10:

            aa=0.863*exp(0.86*xm)/pow(rh+25.0,1.80);

            break;

      case 11:

            aa=(1.776/pow(10.0,5.0))*exp(2.3*xm)/pow(re,1.59);

            break;

      case 12:

            aa=0.3480*exp(1.21*xm)/pow(re+25.0,2.08);

            break;

      case 13:

            aa=0.0159*exp(0.868*xm)/pow(re+0.0606*exp(0.7*xm),1.09);

            break;

      case 14:

            aa=(1.02/100.0)*exp(1.3*xm)/pow(rh,1.5);

            break;

      case 15:

            aa=(3.47/1000.0)*exp(1.3*xm)/pow(rh,1.1);

            break;

      case 16:

            aa=pow(10.0,(-1.02+0.249*xm-log10(sqrt(re*re+7.3*7.3))-   0.00255*sqrt(re*re+7.3*7.3)));

            break;

      case 17:

            aa=3.379*0.001*exp(1.15*xm);

            aa=aa*(pow(re*re+pow((0.0186*exp(1.05*xm),2.0),0.5),-0.83)*exp(-0.0759));

      }

            return (aa);}