SlideShare a Scribd company logo
1 of 12
Download to read offline
>> IN THE NAME OF GOD <<
Elastic Pseudo Response Spectrum in C programming
C program is written by Salar Delavar Ghashghaei – Publication Date: 21/March/2019
E-mail: salar.d.ghashghaei@gmail.com
C code :/* Elastic Response Spectra
This is a function to generate elastic response specra including Displacement
Spectrum, Pseudo Acceleration Spectrum and Pseudo Velocity Spectrum which
are needed in "Response Spectrum Analysis" of Structures. In this function
to solve "Equation of Motions" for different periods, Newmark Linear Method
has been used.
SPEC Function Help:
INPUTS:
dt: Time Interval (Sampling Time) of Record
Ag: Ground Motion Acceleration in g
zet: Damping Ratio in percent (%); e.g. 5
g: Gravitational Constant; e.g. 9.81 m/s/s
endp: End Period of Spectra; e.g. 4 sec
OUTPUTS:
T: Period of Structures (sec)
Spa: Elastic Pseudo Acceleration Spectrum
Spv: Elastic Pseudo Velocity Spectrum
Sd: Elastic Displacement Spectrum
*/
#include <graphics.h>
#include <windows.h> // text color
#define N 10000 // number of increment
#define NN 1 // number of degree of freedom
#define Ne 1 // number of element
#define PI 3.1415926535898
#define ShowText01 "ElasticResponseSpectrum-input.csv"
#define ShowText02 "ElasticResponseSpectrum-inputACCELERATION.csv"
#define ShowText03 "ElasticResponseSpectrum-outputEXCEL.csv"
#define ShowText04 "ElasticResponseSpectrum-outputHTML.html"
#define ShowText05 "Graph-outputHTML.html"
void MessageErrorReportTEXT();
void MessageAnalysisReportTEXT();
void MessageCheckInput(int M);
void MessageInitialData(double GRAVITY,double zet,double endp);
void MessageCheck_IMPORT_DATA01(double GRAVITY,double zet,double endp);
void ANALYSIS(double t[],double Ag[],double T[],double Sd[],double Spa[],double GRAVITY,double zet,double endp,int &kn,int &STEP);
void IMPORT_GRAPH(double data[8],double DATA1[],double DATA2[],double NORMAL_DATA1[],double NORMAL_DATA2[],int n);
void GRAPHICS(double data[8],double NORMAL_DATA1[],double NORMAL_DATA2[],int n,int kind);
double ABS(double);
double MAX(double A[],int n);
double MIN(double A[],int n);
double MAX_ABS(double A[],int n);
void OUTPUT_EXCEL(double time[],double Sd[],double Spa[],int n);
void OUTPUT_html(double GRAVITY,double zet,double endp,double time[],double Sd[],double Spa[],int n);
void IMPORT_DATA01(double &GRAVITY,double &zet,double &endp);
void IMPORT_DATA02(double t[],double Ag[],double GRAVITY,int &kn);
void textcolor(int ForgC);
double MAX_ABS(double A[],int n);
void OUTPUT_HTML_GRAPH(double X[],double Y[],int n,const char text1[],const char text2[],const char text3[]);
int main(){
int i,kn,STEP;
double GRAVITY,zet,endp;
double *t = new double [N];
double *Ag = new double [N];
double *time = new double [N];
double *Sd = new double [N];
double *Spa = new double [N];
double *NORMAL_DATA1 = new double [N];
double *NORMAL_DATA2 = new double [N];
double data[8];
IMPORT_DATA01(GRAVITY,zet,endp);
IMPORT_DATA02(t,Ag,GRAVITY,kn);
MessageCheck_IMPORT_DATA01(GRAVITY,zet,endp);
textcolor(11);
MessageInitialData(GRAVITY,zet,endp);
ANALYSIS(t,Ag,time,Sd,Spa,GRAVITY,zet,endp,kn,STEP);
MessageCheckInput(kn);
OUTPUT_EXCEL(time,Sd,Spa,STEP);
OUTPUT_html(GRAVITY,zet,endp,time,Sd,Spa,STEP);
IMPORT_GRAPH(data,time,Sd,NORMAL_DATA1,NORMAL_DATA2,STEP);
GRAPHICS(data,NORMAL_DATA1,NORMAL_DATA2,STEP,0);
IMPORT_GRAPH(data,time,Spa,NORMAL_DATA1,NORMAL_DATA2,STEP);
GRAPHICS(data,NORMAL_DATA1,NORMAL_DATA2,STEP,1);
char text1[40]="Elastic Pseudo Acceleration Spectrum",text2[20]="Peroid (sec)",text3[20]="Spa (g)";
OUTPUT_HTML_GRAPH(time,Spa,STEP,text1,text2,text3);
textcolor(15);
printf("na - Output data is written in Text, Excel and Html file -");
system("start /w Graph-outputHTML.html");
free(t);free(Ag);free(time);free(Sd);free(Spa);
free(NORMAL_DATA1);free(NORMAL_DATA2);
getch();
return 0;
}
void ANALYSIS(double t[],double Ag[],double T[],double Sd[],double Spa[],double GRAVITY,double zet,double endp,int &kn,int &STEP){
double dt,m,k,c,K,a,b,df,dv,du,dac;
double *u = new double [N];
double *v = new double [N];
double *ac = new double [N];
double *omega = new double [N];
double *Sv = new double [N];
double *Sa = new double [N];
double *Spv = new double [N];
int i,j;
dt = t[2] - t[1];
STEP = endp/dt;
//Ag[end+1]=0;
T[0]=0.00;
for (j=0;j<= STEP;j++){// equation of motion(Newmark linear method)
omega[j]=2*PI/T[j]; // Natural Frequency
m=1;
k=omega[j]*omega[j]*m;
c=2*m*omega[j]*zet/100;
K=k+3*c/dt+6*m/(dt*dt);
a=6*m/dt+3*c;
b=3*m+dt*c/2;
for (i=0;i<= kn-1;i++){
u[0]=0; //initial conditions
v[0]=0;
ac[0]=0;
df=-(Ag[i+1]-Ag[i])+a*v[i]+b*ac[i]; // delta Force
du=df/K;
dv=3*du/dt-3*v[i]-dt*ac[i]/2;
dac=6*(du-dt*v[i])/(dt*dt)-3*ac[i];
u[i+1]=u[i]+du;
v[i+1]=v[i]+dv;
ac[i+1]=ac[i]+dac;
}
Sd[j] = MAX_ABS(u,kn);
//Sv[j] = MAX_ABS(v,kn);
//Sa[j] = MAX_ABS(ac,kn);
Spv[j] =Sd[j]*omega[j];
Spa[j] = Sd[j]*(omega[j]*omega[j])/GRAVITY;
T[j+1]=T[j]+dt;
//cout<<T[j]<<" "<< Spa[j]<<endl;
}
Sd[1]=0; Spv[0]=0;Spv[1]=0;Spa[0]=MAX_ABS(Ag,kn)/GRAVITY;Spa[1]=MAX_ABS(Ag,kn)/GRAVITY;
free(u);free(v);free(ac);free(omega);
free(Sv);free(Sa);free(Spv);
}
void MessageInitialData(double GRAVITY,double zet,double endp){
char Qa,Qb,Qc,Qd,Qe,Qf,Qg,Qk;
int i;Qa=201;Qb=205;Qc=187;Qd=200;Qe=188,Qf=186,Qg=204,Qk=185;
printf("tttt%c",Qa);
for (i=1;i<61;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf("tttt%c >> IN THE NAME OF GOD << %cn",Qf,Qf);
printf("tttt%c Elastic Response Spectrum %cn",Qf,Qf);
printf("tttt%c",Qg);
for (i=1;i<61;i++)
printf("%c",Qb);
printf("%cn",Qk);
printf("tttt%c Unit: Free unit %cn",Qf,Qf);
printf("tttt%c Notice: All input values must be positive %cn",Qf,Qf);
printf("tttt%c",Qg);
for (i=1;i<61;i++)
printf("%c",Qb);
printf("%cn",Qk);
printf("tttt%c Program is written by Salar Delavar Ghashghaei %cn",Qf,Qf);
printf("tttt%c E-mail: salar.d.ghashghaei@gmail.com %cn",Qf,Qf);
printf("tttt%c",Qd);
for (i=1;i<61;i++)
printf("%c",Qb);
printf("%cn",Qe);
MessageAnalysisReportTEXT();
printf(" Gravitational Constant: %fn",GRAVITY);
printf(" Damping Ratio in percent (%): %fn",zet);
printf(" End Period of Spectrum (sec): %fn",endp);
}
void IMPORT_GRAPH(double data[8],double DATA1[],double DATA2[],double NORMAL_DATA1[],double NORMAL_DATA2[],int n){
double DATA1NorMin,DATA1NorMax,DATA2NorMin,DATA2NorMax,DATA1_min,DATA1_max,DATA2_min,DATA2_max;
DATA1_min=MIN(DATA1,n);
DATA1_max=MAX(DATA1,n);
DATA2_min=MIN(DATA2,n);
DATA2_max=MAX(DATA2,n);
for (int i=1;i<n;i++){
NORMAL_DATA1[i]=DATA1[i]/(DATA1_max-DATA1_min); // Normalize DATA1
NORMAL_DATA2[i]=DATA2[i]/(DATA2_max-DATA2_min); // Normalize DATA2
}
DATA1NorMin=MIN(NORMAL_DATA1,n);//Minimum Normalize DATA1
DATA2NorMin=MIN(NORMAL_DATA2,n);//Minimum Normalize DATA2
DATA1NorMax=MAX(NORMAL_DATA1,n);//Maximum Normalize DATA1
DATA2NorMax=MAX(NORMAL_DATA2,n);//Maximum Normalize DATA2
data[0]=DATA1NorMin;
data[1]=DATA1NorMax;
data[2]=DATA2NorMin;
data[3]=DATA2NorMax;
data[4]=DATA1_min;
data[5]=DATA1_max;
data[6]=DATA2_min;
data[7]=DATA2_max;
}
void GRAPHICS(double data[8],double NORMAL_DATA1[],double NORMAL_DATA2[],int n,int kind){
double DATA1NorMin,DATA1NorMax,DATA2NorMin,DATA2NorMax,DATA1_min,DATA1_max,DATA2_min,DATA2_max;
DATA1NorMin=data[0];
DATA1NorMax=data[1];
DATA2NorMin=data[2];
DATA2NorMax=data[3];
DATA1_min=data[4];
DATA1_max=data[5];
DATA2_min=data[6];
DATA2_max=data[7];
int gd = DETECT, gm, color;
DWORD screenWidth = GetSystemMetrics(SM_CXSCREEN);
DWORD screenHeight = GetSystemMetrics(SM_CYSCREEN);
initwindow(screenWidth,screenHeight,"",-3,-3);// init window graphics
//initwindow(getmaxx( ),getmaxy( )); // initial window graphics
//initgraph(&gd, &gm, "C:TCBGI");
int i,j,a,x1,y1,x2,y2,Lx,Ly;
//initwindow(300, 300);
x1=95;
y1=85;
x2=x1+1250;
y2=y1+500;
Lx=x2-x1;
Ly=y2-y1;
setbkcolor(0);// set background
//setcolor(9); // color rectangle line
//setlinestyle(0,0,2);// (style,pattern,thickness)
//rectangle( x1, y1, x2,y2);
//setcolor(10);
//bar( x1, y1, x2, y2);
setlinestyle(0,0,1);// (style,pattern,thickness)
setcolor(9); // color dash line
if (DATA1NorMin < 0 && DATA1NorMax > 0){
a=y1*1/20;// Y - Coordinate Axis - 10 steps
for (i=1;i<=19;i++)
for (j=0;j<=124;j=j+2)
line(Lx*i/20 +x1,y1+j*a,Lx*i/20 +x1,y1+(j+1)*a);
a=x1*1/20; // X - Coordinate Axis - 10 steps
for (i=1;i<=19;i++)
for (j=0;j<=310;j=j+2)
line( x1+j*a,Ly*i/20 +y1,x1+(j+1)*a,Ly*i/20 +y1);
a=y1*1/5;// Y - Coordinate Axis - 5 steps
for (i=1;i<=10;i++)
line(Lx*i/10 +x1,y2,Lx*i/10 +x1,y2-a);
a=x1*1/5; // X - Coordinate Axis - 5 steps
for (i=1;i<=10;i++)
line( x1,y2-Ly*i/10,x1+a,y2-Ly*i/10);
}
else if (DATA2NorMin < 0 && DATA2NorMax > 0){
a=y1*1/20;// Y - Coordinate Axis - 10 steps
for (i=1;i<=19;i++)
for (j=0;j<=124;j=j+2)
line(Lx*i/20 +x1,y1+j*a,Lx*i/20 +x1,y1+(j+1)*a);
a=x1*1/20; // X - Coordinate Axis - 10 steps
for (i=1;i<=19;i++)
for (j=0;j<=310;j=j+2)
line( x1+j*a,Ly*i/20 +y1,x1+(j+1)*a,Ly*i/20 +y1);
a=y1*1/5;// Y - Coordinate Axis - 5 steps
for (i=1;i<=10;i++)
line(Lx*i/10 +x1,y2,Lx*i/10 +x1,y2-a);
a=x1*1/5; // X - Coordinate Axis - 5 steps
for (i=1;i<=10;i++)
line( x1,y2-Ly*i/10,x1+a,y2-Ly*i/10);
}
else{
a=y1*1/20;// Y - Coordinate Axis - 10 steps
for (i=1;i<=9;i++)
for (j=0;j<=120;j=j+2)
line(Lx*i/10 +x1,y1+j*a,Lx*i/10 +x1,y1+(j+1)*a);
a=x1*1/20; // X - Coordinate Axis - 10 steps
for (i=1;i<=9;i++)
for (j=0;j<=310;j=j+2)
line( x1+j*a,Ly*i/10 +y1,x1+(j+1)*a,Ly*i/10 +y1);
a=y1*1/5;// Y - Middle Coordinate Axis - 5 steps
for (i=1;i<=19;i++)
line(Lx*i/20 +x1,y2,Lx*i/20 +x1,y2-a);
a=x1*1/5; // X - Middle Coordinate Axis - 5 steps
for (i=1;i<=19;i++)
line( x1,y2-Ly*i/20,x1+a,y2-Ly*i/20);
a=y1*1/10;// Y - Middle Coordinate Axis - 100 steps
for (i=1;i<=99;i++)
line(Lx*i/100 +x1,y2,Lx*i/100 +x1,y2-a);
a=x1*1/7; // X - Middle Coordinate Axis - 100 steps
for (i=1;i<=99;i++)
line( x1,y2-Ly*i/100,x1+a,y2-Ly*i/100);
}
//cleardevice();
setcolor(WHITE);// set text color
if (kind == 0){
settextstyle(1, 0, 5);settextjustify(10, 5);
outtextxy(x2/2 -400,25,"Elastic Displacement Spectrum");// print text in window subtitle
settextstyle(1, 1, 1);settextjustify(10, 5);
outtextxy(x1/10 -10,.5*Ly+y1,"Sd");// print text in window graphics y
}
else if(kind == 1){
settextstyle(1, 0, 5);settextjustify(10, 5);
outtextxy(x2/2 -500,25,"Elastic Pseudo Acceleration Spectrum");// print text in window subtitle
settextstyle(1, 1, 1);settextjustify(10, 5);
outtextxy(x1/10 -10,.6*Ly+y1,"Spa (g)");// print text in window graphics y
}
settextjustify(50, 5);settextstyle(1, 0, 1);
outtextxy(x2/2 -10,y2 +50,"Peroid (sec)");// print text in window graphics x
char bufferX[10][100],bufferY[10][100];
double dXdata,dYdata;
settextstyle(-1, 0,-3);settextjustify(10, 5);
sprintf(bufferX[1], "%.3e" , DATA1_min);
outtextxy(x1-45,y2+10,bufferX[1]);// print text in window graphic x axis point
sprintf(bufferX[1], "%.3e" , DATA2_min);
outtextxy(x1-69,y2 -5,bufferX[1]);// print text in window graphic y axis point
for (i=1;i<=10;i++){
dXdata = DATA1_min + 0.1*i*(DATA1_max - DATA1_min);
if (ABS(dXdata) <= 1e-20) dXdata = 0.0; // if number is very low, got it zero
sprintf(bufferX[i], "%.3e" ,dXdata);
outtextxy(x1+Lx*i*.1-45,y2+10,bufferX[i]);// print text in window graphic x axis point -> max
}
for (i=1;i<=10;i++){
dYdata = DATA2_min + 0.1*i*(DATA2_max - DATA2_min);
if (ABS(dYdata) <= 1e-20) dYdata = 0.0; // if number is very low, got it zero
sprintf(bufferY[i], "%.3e" , dYdata);
outtextxy(x1-69,y2-Ly*i*.1 -5,bufferY[i]);// print text in window graphic y axis point -> max
}
double *X = new double [N];
double *Y = new double [N];
//Absolute data
double DATA1NorMin_Abs,DATA2NorMin_Abs;
DATA1NorMin_Abs=ABS(DATA1NorMin);DATA2NorMin_Abs=ABS(DATA2NorMin);
/*
setcolor(9);
setlinestyle(0,0,2);// (style,pattern,thickness)
line(Lx*(DATA1NorMin_Abs/(DATA1NorMax-DATA1NorMin)) +x1,y1,Lx*(DATA1NorMin_Abs/(DATA1NorMax-DATA1NorMin)) +x1,y2); //Middle axis -X
line(x1,y2-Ly*(DATA2NorMin_Abs/(DATA2NorMax-DATA2NorMin)),x2,y2-Ly*(DATA2NorMin_Abs/(DATA2NorMax-DATA2NorMin))); // Middle axis -Y
*/
if (DATA2NorMin < 0 && DATA2NorMax > 0 && DATA1NorMin >= 0)
X[0]=x2,Y[0]=y2;//First point
else if (DATA2NorMin <= 0 && DATA2NorMax <= 0)
X[0]=x2,Y[0]=y2;//First point
else
X[0]=x1,Y[0]= y2-Ly*(NORMAL_DATA2[1]/(DATA2NorMax-DATA2NorMin));//First point
// Draw line
setcolor(YELLOW);
setlinestyle(0,0,2);// (style,pattern,thickness)
for (i=1;i<=n-1;i++){
NORMAL_DATA1[i] = NORMAL_DATA1[i] + DATA1NorMin_Abs;//Absolute DATA1
NORMAL_DATA2[i] = NORMAL_DATA2[i] + DATA2NorMin_Abs;//Absolute DATA2
X[i] = x1+Lx*(NORMAL_DATA1[i]/(DATA1NorMax-DATA1NorMin));
Y[i] = y2-Ly*(NORMAL_DATA2[i]/(DATA2NorMax-DATA2NorMin));
line(X[i-1],Y[i-1],X[i],Y[i]);
}
// Covering error ;-)
setcolor(9);
settextstyle(1, 0,1);
rectangle( x1, y1, x2,y2);
/*
// Middle axis
double dXdata_abs,dYdata_abs;
int Ix,Iy;
if (DATA1NorMin < 0 && DATA1NorMax > 0)
for (i=1;i<=10;i++)
{
dXdata = DATA1_min + 0.1*i*(DATA1_max - DATA1_min);//cout<<dXdata<<endl;
if (dXdata > 0 && dXdata < .00001)
Ix=i;//cout<<"Ix: "<<Ix<<endl;
}
line(Lx*Ix/10 +x1,y1,Lx*Ix/10 +x1,y2);
if (DATA2NorMin < 0 && DATA2NorMax > 0)
for (i=1;i<=10;i++)
{
dYdata = DATA2_min + 0.1*i*(DATA2_max - DATA2_min);//cout<<dYdata<<endl;
if (dYdata > 0 && dYdata < .00001)
Iy=i;//cout<<"Iy: "<<Iy<<endl;
}
line(x1,Ly*Iy/10 +y1,x2,Ly*Iy/10 +y1);
*/
/* Box text */
/*
setcolor(9);
settextstyle(1, 0,1);
rectangle( x1+350, y2+50, x1+900,y2+80);
setlinestyle(1,0,3);settextjustify(10, 5);// (style,pattern,thickness)
outtextxy(x1+355,y2+55,"Analysis");// print text in box
setlinestyle(1,0,3);settextjustify(10, 5);// (style,pattern,thickness)
outtextxy(x1+620,y2+55,"Bilinear");// print text in box
setcolor(YELLOW);line(x1+500,y2+65,x1+600,y2+65);
setcolor(10);line(x1+765,y2+65,x1+850,y2+65);
*/
getch();
closegraph();
}
double ABS(double B){
double B_abs;
if (B < 0)
B_abs = -B;//Absolute number
else
B_abs = B;
return B_abs;
}
double MIN(double A[],int n){
int i;
double Amin;
Amin = A[0];
for (i=1;i<n;i++){
if (Amin > A[i])
Amin=A[i];
}
return Amin;//Minimum DATA
}
double MAX(double A[],int n){
int i;
double Amax;
Amax = A[0];
for (i=1;i<n;i++){
if (Amax < A[i])
Amax=A[i];
}
return Amax;//Maximum DATA
}
void MessageErrorReportTEXT(){
int i;
char Ql;
Ql=176;
textcolor(12);
printf("an ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf(" Error Report ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf("n");
}
void OUTPUT_EXCEL(double time[],double Sd[],double Spa[],int n){
// EXCEL OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText03, "w");
fprintf(OutputFile," ### Output Elastic Response Spectrum ###n");
fprintf(OutputFile,"Step,Time,Spectral Displacement,Pseudo Acceleration Spectrumn");
for(i=0;i<n;i++)
fprintf(OutputFile,"%d,%f,%f,%fn",i+1,time[i],Sd[i],Spa[i]);
fclose(OutputFile);
}
void OUTPUT_html(double GRAVITY,double zet,double endp,double time[],double Sd[],double Spa[],int n){
// HTML OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText04, "w");
fprintf(OutputFile,"<html> <body bgcolor="green">n");
// TOP TITLE oF HTML FILE
fprintf(OutputFile,"<table style=”width:100%” border="2px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<th bgcolor="cyan"> Elastic Response Spectrum - Output Report </th> n");
// TABLE 1
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<th colspan="2" bgcolor="orange"> Input Data </th> n");
fprintf(OutputFile,"<tr> <th bgcolor="orange"> Gravitational Constant: </th><th> %.3e </th></tr>n",GRAVITY);
fprintf(OutputFile,"<tr> <th bgcolor="orange"> Damping Ratio in percent (%): </th><th> %.3e </th></tr>n",zet);
fprintf(OutputFile,"<tr> <th bgcolor="orange"> End Period of Spectrum (sec): </th><th> %.3e </th></tr>n",endp);
// TABLE 2
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<th colspan="4" bgcolor="orange"> Displacement and Pseudo Acceleration Spectrum</th> n");
fprintf(OutputFile,"<tr> <th bgcolor="orange"> Step </th><th bgcolor="orange"> Time(Period) </th> <th bgcolor="orange"> Spectral Displacement </th> <th bgcolor="orange"> Pseudo Acceleration Spectrum </th></tr>n");
for(i=0;i<n;i++){
fprintf(OutputFile,"<tr> <td align ="center"> %d </td> <td align ="center"> %.3e </td> <td align ="center"> %.3e </td> <td align ="center"> %.3e </td></tr>n",i+1,time[i],Sd[i],Spa[i]);
}
fprintf(OutputFile,"</table></body></html>n");
fclose(OutputFile);
}
void MessageCheckInput(int M){
if (M>N || M<2){
MessageErrorReportTEXT();
printf(" Please check this file! -> [ ElasticResponseSpectrum-inputACCELERATION.csv ]n");
printf(" Number of data : %d - Minimum : 3 - Maximum : 20000",M);
Sleep(40000);
exit(1);
}
}
void MessageAnalysisReportTEXT(){
int i;
char Ql=176;
printf("n ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf(" Input Data ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf("n");
}
void MessageCheck_IMPORT_DATA01(double GRAVITY,double zet,double endp){
if ( GRAVITY < 0 || zet < 0 || endp< 0 ){
MessageErrorReportTEXT();
printf(" Please check this file! -> [%s]n",ShowText01);
printf(" *** Negative data input value is not acceptable ***n");
printf(" Gravitational Constant: %f",GRAVITY);
printf(" Damping Ratio in percent (%): %f",zet);
printf(" End Period of Spectrum (sec): %f",endp);
Sleep(40000);
exit(1);
}
}
/*
void IMPORT_DATA01(double &GRAVITY,double &zet,double &endp){
ifstream IN1;IN1.open("ElasticResponseSpectrum-input.csv");
IN1>>GRAVITY>>zet>>endp;
IN1.close();
}
void IMPORT_DATA02(double t[],double Ag[],double GRAVITY,int &kn){
double Time,Acceleration,dt;char CHAR;
int i=0;
ifstream IN2;IN2.open("ElasticResponseSpectrum-inputACCELERATION.csv");//import strain-stress of elements
while(IN2 >> Time >> CHAR >> Acceleration){
t[i]=Time;Ag[i]=Acceleration*GRAVITY;
//cout<<"t["<<i<<"]:"<<t[i]<<" - Ag["<<i<<"]:"<<Ag[i]<<endl;
i++;
}
kn=i;
IN2.close();
}
*/
void IMPORT_DATA01(double &GRAVITY,double &zet,double &endp){
int i=0;
double AA[3];
FILE *InputFile;
InputFile = fopen(ShowText01, "r");
if (!InputFile){
MessageErrorReportTEXT();
printf(" File is not available! -> [%s] n",ShowText01);
}
char line[100],a[100];
while(i < N && fgets(line,sizeof(line),InputFile) != NULL){
sscanf(line,"%s",a);
//printf("a[%d]: %sn",i,a);
AA[i]= atof(a);
i++;
}
GRAVITY=AA[0];zet=AA[1];endp=AA[2];
}
void IMPORT_DATA02(double t[],double Ag[],double GRAVITY,int &kn){
int i = 0;
FILE *InputFile;
InputFile = fopen(ShowText02, "r");
if (!InputFile){
MessageErrorReportTEXT();
printf(" File is not available! -> [%s] n",ShowText02);
exit(1);
}
char line[1000];
double Time,Acceleration;
do{
fscanf(InputFile,"%lf,%lf",&Time,&Acceleration);
t[i]=Time;Ag[i]=Acceleration*GRAVITY;
//printf("%d - t[%d]: %lf - Ag[%d]: %lfn",i,i,t[i],i,Ag[i]);
i++;
}
while(i < N && fgets(line,sizeof(line),InputFile) != NULL);
kn = i;
}
void textcolor(int ForgC){
WORD wColor;
//This handle is needed to get the current background attribute
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
//csbi is used for wAttributes word
if(GetConsoleScreenBufferInfo(hStdOut, &csbi)){
//To mask out all but the background attribute, and to add the color
wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
SetConsoleTextAttribute(hStdOut, wColor);
}
return;
}
double MAX_ABS(double A[],int n){
int i;
double B[N];
double Amax;
// abs value
for (i=0;i<n;i++){
B[i] = A[i];
if(B[i] < 0)
B[i] = -B[i];
}
// Max of abs
Amax = B[0];
for (i=1;i<n;i++){
if(Amax < B[i])
Amax = B[i];
}
return Amax;
}
void OUTPUT_HTML_GRAPH(double X[],double Y[],int n,const char text1[],const char text2[],const char text3[]){
// HTML GRAPH OUTPUT
int i;
double x,y,NorX[N],NorY[N],Xmax,Ymax;
Xmax=MAX_ABS(X,n);
Ymax=MAX_ABS(Y,n);
for (i=0;i<n;i++){
NorX[i] = X[i]/Xmax;
NorY[i] = Y[i]/Ymax;
//printf("t %f %f n",NorX[i],NorY[i]);
}
FILE *OutputFile;
OutputFile = fopen(ShowText05, "w");
fprintf(OutputFile,"<!DOCTYPE HTML><html><body style="background-color:black;"><font color="white"><head><script> n");
fprintf(OutputFile,"window.onload = function(){ n");
fprintf(OutputFile,"var canvas = document.getElementById("myCanvas");var s1 = canvas.getContext("2d");var s2 = canvas.getContext('2d'); n");
fprintf(OutputFile,"var s3 = canvas.getContext("2d");var s4 = canvas.getContext("2d");var s5 = canvas.getContext("2d"); n");
fprintf(OutputFile,"var x=120,y=80,X,Y,Lx=1100,Ly=500,i; n");
fprintf(OutputFile,"s3.beginPath();s3.lineWidth = 3;s3.strokeStyle = "cyan";s3.rect(x,y,Lx,Ly); n");
fprintf(OutputFile,"for(i=0;i<9;i++){s3.moveTo(x+Lx*(i+1)*.1,y+Ly);s3.lineTo(x+Lx*(i+1)*.1,y+Ly-10);}; n");
fprintf(OutputFile,"for(i=0;i<9;i++){s3.moveTo(x,y+Ly*(i+1)*.1);s3.lineTo(x+10,y+Ly*(i+1)*.1);};s3.stroke();n");
fprintf(OutputFile,"s1.beginPath();s1.lineWidth = 3;s1.strokeStyle = "yellow"; n");
for (i=0;i<n-1;i++){
fprintf(OutputFile,"s1.moveTo(%f,%f);",120+NorX[i]*1100,80+500-NorY[i]*500);
fprintf(OutputFile,"s1.lineTo(%f,%f); n",120+NorX[i+1]*1100,80+500-NorY[i+1]*500);
}
fprintf(OutputFile,"s1.stroke(); n");
fprintf(OutputFile,"s2.beginPath();s2.lineWidth = 1;s2.strokeStyle = "cyan";s2.setLineDash([5, 5]); n");
fprintf(OutputFile,"for(i=0;i<19;i++){s2.moveTo(x+Lx*(i+1)*.05,y);s2.lineTo(x+Lx*(i+1)*.05,y+Ly);} n");
fprintf(OutputFile,"s2.lineWidth = 1;s2.strokeStyle = "cyan";for(i=0;i<19;i++){s2.moveTo(x,y+Ly*(i+1)*.05);s2.lineTo(x+Lx,y+Ly*(i+1)*.05);} s2.stroke();n");
fprintf(OutputFile,"X=x+.25*Lx;Y=.7*y;s4.translate(X,Y);s4.font="50px serif";s4.fillStyle = "#7fff00";s4.fillText("%s",0,0); n",text1);
fprintf(OutputFile,"s4.save();X=-X+.2*x;Y=-Y+y+.6*Ly;s4.translate(X,Y);s4.rotate(3*Math.PI/2);s4.font="15px serif"; n");
fprintf(OutputFile,"s4.fillStyle = "#7fff00";s4.textAlign = "left";s4.fillText("%s",0,0);s4.restore(); n",text3);
fprintf(OutputFile,"s4.save();X=.2*Lx;Y=y+Ly-20;s4.translate(X,Y);s4.rotate(2*Math.PI);s4.font="15px serif";s4.fillStyle = "#7fff00"; n");
fprintf(OutputFile,"s4.textAlign = "left";s4.fillText("%s",0,0);s4.restore(); n",text2);
for(i=0;i<10;i++){
x=.1*(i+1)*Xmax;
fprintf(OutputFile,"s5.save();X=-.29*Lx+Lx*(%d+1)*.1;Y=.3*y+Ly+20;s5.rotate(2*Math.PI);s5.font="16px serif"; n",i);
fprintf(OutputFile,"s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText("%.3e",X,Y);s5.restore(); n",x);
}
for(i=0;i<10;i++){
y=.1*(i+1)*Ymax;
fprintf(OutputFile,"s5.save();X=-.28*Lx-50;Y=Ly+.3*y-Ly*(%d+1)*.1;s5.rotate(2*Math.PI);s5.font="16px serif"; n",i);
fprintf(OutputFile,"s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText("%.3e",X,Y);s5.restore(); n",y);
}
fprintf(OutputFile,"s5.save();X=-.25*Lx;Y=.3*y+Ly+20;s5.rotate(2*Math.PI);s5.font="16px serif";s5.fillStyle = "#7fff00";s5.fillText(0,X,Y);s5.restore(); n");
fprintf(OutputFile,"s5.save();X=-.25*Lx-50;Y=Ly+.3*y;s5.rotate(2*Math.PI);s5.font="16px serif";s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText(0,X,Y);s5.restore();}; n");
fprintf(OutputFile,"</script></head><body><canvas id="myCanvas" width="1300" height="1300" style="border:1px solid black;"></canvas></body></html> n");
fclose(OutputFile);
}
Figure(1) Input csv file
Figure(2) Input time acceleration
Figure(3) Analysis file
Figure(4) Elastic displacement spectrum
Figure(5) Elastic pseudo acceleration spectrum
Figure(6) HTML output
Figure(7) EXCEL output

More Related Content

What's hot

Mining Geo-referenced Data: Location-based Services and the Sharing Economy
Mining Geo-referenced Data: Location-based Services and the Sharing EconomyMining Geo-referenced Data: Location-based Services and the Sharing Economy
Mining Geo-referenced Data: Location-based Services and the Sharing Economytnoulas
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryptionsecurityxploded
 
Forward secure asynchronous messaging from puncturable encryption
Forward secure asynchronous messaging from puncturable encryptionForward secure asynchronous messaging from puncturable encryption
Forward secure asynchronous messaging from puncturable encryptionNational Chengchi University
 
The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210Mahmoud Samir Fayed
 
Apache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsApache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsFlink Forward
 
"Используем MetricKit в бою" / Марина Звягина (Vivid Money)
"Используем MetricKit в бою" / Марина Звягина (Vivid Money)"Используем MetricKit в бою" / Марина Звягина (Vivid Money)
"Используем MetricKit в бою" / Марина Звягина (Vivid Money)Egor Petrov
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and GraphicsAndreas Jakl
 
Time Series Analysis by JavaScript LL matsuri 2013
Time Series Analysis by JavaScript LL matsuri 2013 Time Series Analysis by JavaScript LL matsuri 2013
Time Series Analysis by JavaScript LL matsuri 2013 Daichi Morifuji
 
GeoMesa on Apache Spark SQL with Anthony Fox
GeoMesa on Apache Spark SQL with Anthony FoxGeoMesa on Apache Spark SQL with Anthony Fox
GeoMesa on Apache Spark SQL with Anthony FoxDatabricks
 
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...CodiLime
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185Mahmoud Samir Fayed
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: DeanonymizingDavid Evans
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactorXiaojun REN
 

What's hot (20)

Mining Geo-referenced Data: Location-based Services and the Sharing Economy
Mining Geo-referenced Data: Location-based Services and the Sharing EconomyMining Geo-referenced Data: Location-based Services and the Sharing Economy
Mining Geo-referenced Data: Location-based Services and the Sharing Economy
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryption
 
Forward secure asynchronous messaging from puncturable encryption
Forward secure asynchronous messaging from puncturable encryptionForward secure asynchronous messaging from puncturable encryption
Forward secure asynchronous messaging from puncturable encryption
 
Dun ddd
Dun dddDun ddd
Dun ddd
 
The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210
 
Apache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsApache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API Basics
 
"Используем MetricKit в бою" / Марина Звягина (Vivid Money)
"Используем MetricKit в бою" / Марина Звягина (Vivid Money)"Используем MetricKit в бою" / Марина Звягина (Vivid Money)
"Используем MetricKit в бою" / Марина Звягина (Vivid Money)
 
05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics05 - Qt External Interaction and Graphics
05 - Qt External Interaction and Graphics
 
Time Series Analysis by JavaScript LL matsuri 2013
Time Series Analysis by JavaScript LL matsuri 2013 Time Series Analysis by JavaScript LL matsuri 2013
Time Series Analysis by JavaScript LL matsuri 2013
 
GeoMesa on Apache Spark SQL with Anthony Fox
GeoMesa on Apache Spark SQL with Anthony FoxGeoMesa on Apache Spark SQL with Anthony Fox
GeoMesa on Apache Spark SQL with Anthony Fox
 
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
CodiLime Tech Talk - Katarzyna Ziomek-Zdanowicz: RxJS main concepts and real ...
 
C++ programming
C++ programmingC++ programming
C++ programming
 
LCS35
LCS35LCS35
LCS35
 
Procesos
ProcesosProcesos
Procesos
 
Ns2 by khan
Ns2 by khan Ns2 by khan
Ns2 by khan
 
Data Analysis
Data AnalysisData Analysis
Data Analysis
 
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: Deanonymizing
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactor
 
OpenGL L05-Texturing
OpenGL L05-TexturingOpenGL L05-Texturing
OpenGL L05-Texturing
 

Similar to Elastic response pseudo spectrum in c programming

Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Salar Delavar Qashqai
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignmentAbdullah Al Shiam
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxFinal Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxvoversbyobersby
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaFerdinand Jamitzky
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdfsutharbharat59
 
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Salar Delavar Qashqai
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualUma mohan
 
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Salar Delavar Qashqai
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfanyacarpets
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
Task based Programming with OmpSs and its Application
Task based Programming with OmpSs and its ApplicationTask based Programming with OmpSs and its Application
Task based Programming with OmpSs and its ApplicationFacultad de Informática UCM
 
Data structures notes for college students btech.pptx
Data structures notes for college students btech.pptxData structures notes for college students btech.pptx
Data structures notes for college students btech.pptxKarthikVijay59
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineersvarun arora
 
Sequential radar tracking
Sequential radar trackingSequential radar tracking
Sequential radar trackingAssignmentpedia
 

Similar to Elastic response pseudo spectrum in c programming (20)

Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...Geometric and material nonlinearity analysis of 2 d truss with force and duct...
Geometric and material nonlinearity analysis of 2 d truss with force and duct...
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxFinal Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cuda
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
 
array
arrayarray
array
 
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
week-3x
week-3xweek-3x
week-3x
 
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...Critical buckling load geometric nonlinearity analysis of springs with rigid ...
Critical buckling load geometric nonlinearity analysis of springs with rigid ...
 
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdfimport java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
import java.awt.;import java.awt.event.MouseAdaptor;import java.pdf
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
04 Algorithms
04 Algorithms04 Algorithms
04 Algorithms
 
Task based Programming with OmpSs and its Application
Task based Programming with OmpSs and its ApplicationTask based Programming with OmpSs and its Application
Task based Programming with OmpSs and its Application
 
Data structures notes for college students btech.pptx
Data structures notes for college students btech.pptxData structures notes for college students btech.pptx
Data structures notes for college students btech.pptx
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
Computer graphics File for Engineers
Computer graphics File for EngineersComputer graphics File for Engineers
Computer graphics File for Engineers
 
Ping to Pong
Ping to PongPing to Pong
Ping to Pong
 
Clock For My
Clock For MyClock For My
Clock For My
 
Sequential radar tracking
Sequential radar trackingSequential radar tracking
Sequential radar tracking
 

More from Salar Delavar Qashqai

Pushover 2order (p delta effect) analysis force analogy method with force con...
Pushover 2order (p delta effect) analysis force analogy method with force con...Pushover 2order (p delta effect) analysis force analogy method with force con...
Pushover 2order (p delta effect) analysis force analogy method with force con...Salar Delavar Qashqai
 
Pushover analysis of frame by force analogy method with force control based o...
Pushover analysis of frame by force analogy method with force control based o...Pushover analysis of frame by force analogy method with force control based o...
Pushover analysis of frame by force analogy method with force control based o...Salar Delavar Qashqai
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Salar Delavar Qashqai
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingSalar Delavar Qashqai
 
Truss optimization with excel solver
Truss optimization with excel solverTruss optimization with excel solver
Truss optimization with excel solverSalar Delavar Qashqai
 
Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...Salar Delavar Qashqai
 
Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...Salar Delavar Qashqai
 
Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...Salar Delavar Qashqai
 
Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000Salar Delavar Qashqai
 
Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...Salar Delavar Qashqai
 
Moment curvature analysis unconfined concrete section with different tension...
Moment curvature analysis unconfined concrete section  with different tension...Moment curvature analysis unconfined concrete section  with different tension...
Moment curvature analysis unconfined concrete section with different tension...Salar Delavar Qashqai
 
Optimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductilityOptimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductilitySalar Delavar Qashqai
 
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...Salar Delavar Qashqai
 
Import data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingSalar Delavar Qashqai
 
Structural eigen value analysis in c programming
Structural eigen value analysis in c programmingStructural eigen value analysis in c programming
Structural eigen value analysis in c programmingSalar Delavar Qashqai
 
Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...Salar Delavar Qashqai
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...Salar Delavar Qashqai
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...Salar Delavar Qashqai
 
Moment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlabMoment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlabSalar Delavar Qashqai
 
Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...Salar Delavar Qashqai
 

More from Salar Delavar Qashqai (20)

Pushover 2order (p delta effect) analysis force analogy method with force con...
Pushover 2order (p delta effect) analysis force analogy method with force con...Pushover 2order (p delta effect) analysis force analogy method with force con...
Pushover 2order (p delta effect) analysis force analogy method with force con...
 
Pushover analysis of frame by force analogy method with force control based o...
Pushover analysis of frame by force analogy method with force control based o...Pushover analysis of frame by force analogy method with force control based o...
Pushover analysis of frame by force analogy method with force control based o...
 
Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...Geometric nonlinearity analysis of springs with rigid element displacement co...
Geometric nonlinearity analysis of springs with rigid element displacement co...
 
Nonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programmingNonlinear analysis of braced frame with hinge by hinge method in c programming
Nonlinear analysis of braced frame with hinge by hinge method in c programming
 
Truss optimization with excel solver
Truss optimization with excel solverTruss optimization with excel solver
Truss optimization with excel solver
 
Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...
 
Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...
 
Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...
 
Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000
 
Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...
 
Moment curvature analysis unconfined concrete section with different tension...
Moment curvature analysis unconfined concrete section  with different tension...Moment curvature analysis unconfined concrete section  with different tension...
Moment curvature analysis unconfined concrete section with different tension...
 
Optimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductilityOptimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductility
 
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
 
Import data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programming
 
Structural eigen value analysis in c programming
Structural eigen value analysis in c programmingStructural eigen value analysis in c programming
Structural eigen value analysis in c programming
 
Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
 
Moment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlabMoment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlab
 
Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...
 

Recently uploaded

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 

Recently uploaded (20)

IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 

Elastic response pseudo spectrum in c programming

  • 1. >> IN THE NAME OF GOD << Elastic Pseudo Response Spectrum in C programming C program is written by Salar Delavar Ghashghaei – Publication Date: 21/March/2019 E-mail: salar.d.ghashghaei@gmail.com
  • 2. C code :/* Elastic Response Spectra This is a function to generate elastic response specra including Displacement Spectrum, Pseudo Acceleration Spectrum and Pseudo Velocity Spectrum which are needed in "Response Spectrum Analysis" of Structures. In this function to solve "Equation of Motions" for different periods, Newmark Linear Method has been used. SPEC Function Help: INPUTS: dt: Time Interval (Sampling Time) of Record Ag: Ground Motion Acceleration in g zet: Damping Ratio in percent (%); e.g. 5 g: Gravitational Constant; e.g. 9.81 m/s/s endp: End Period of Spectra; e.g. 4 sec OUTPUTS: T: Period of Structures (sec) Spa: Elastic Pseudo Acceleration Spectrum Spv: Elastic Pseudo Velocity Spectrum Sd: Elastic Displacement Spectrum */ #include <graphics.h> #include <windows.h> // text color #define N 10000 // number of increment #define NN 1 // number of degree of freedom #define Ne 1 // number of element #define PI 3.1415926535898 #define ShowText01 "ElasticResponseSpectrum-input.csv" #define ShowText02 "ElasticResponseSpectrum-inputACCELERATION.csv" #define ShowText03 "ElasticResponseSpectrum-outputEXCEL.csv" #define ShowText04 "ElasticResponseSpectrum-outputHTML.html" #define ShowText05 "Graph-outputHTML.html" void MessageErrorReportTEXT(); void MessageAnalysisReportTEXT(); void MessageCheckInput(int M); void MessageInitialData(double GRAVITY,double zet,double endp); void MessageCheck_IMPORT_DATA01(double GRAVITY,double zet,double endp); void ANALYSIS(double t[],double Ag[],double T[],double Sd[],double Spa[],double GRAVITY,double zet,double endp,int &kn,int &STEP); void IMPORT_GRAPH(double data[8],double DATA1[],double DATA2[],double NORMAL_DATA1[],double NORMAL_DATA2[],int n); void GRAPHICS(double data[8],double NORMAL_DATA1[],double NORMAL_DATA2[],int n,int kind); double ABS(double); double MAX(double A[],int n); double MIN(double A[],int n); double MAX_ABS(double A[],int n); void OUTPUT_EXCEL(double time[],double Sd[],double Spa[],int n); void OUTPUT_html(double GRAVITY,double zet,double endp,double time[],double Sd[],double Spa[],int n); void IMPORT_DATA01(double &GRAVITY,double &zet,double &endp); void IMPORT_DATA02(double t[],double Ag[],double GRAVITY,int &kn); void textcolor(int ForgC); double MAX_ABS(double A[],int n); void OUTPUT_HTML_GRAPH(double X[],double Y[],int n,const char text1[],const char text2[],const char text3[]); int main(){ int i,kn,STEP; double GRAVITY,zet,endp; double *t = new double [N]; double *Ag = new double [N]; double *time = new double [N]; double *Sd = new double [N]; double *Spa = new double [N]; double *NORMAL_DATA1 = new double [N]; double *NORMAL_DATA2 = new double [N]; double data[8]; IMPORT_DATA01(GRAVITY,zet,endp); IMPORT_DATA02(t,Ag,GRAVITY,kn); MessageCheck_IMPORT_DATA01(GRAVITY,zet,endp); textcolor(11); MessageInitialData(GRAVITY,zet,endp); ANALYSIS(t,Ag,time,Sd,Spa,GRAVITY,zet,endp,kn,STEP); MessageCheckInput(kn); OUTPUT_EXCEL(time,Sd,Spa,STEP); OUTPUT_html(GRAVITY,zet,endp,time,Sd,Spa,STEP); IMPORT_GRAPH(data,time,Sd,NORMAL_DATA1,NORMAL_DATA2,STEP); GRAPHICS(data,NORMAL_DATA1,NORMAL_DATA2,STEP,0); IMPORT_GRAPH(data,time,Spa,NORMAL_DATA1,NORMAL_DATA2,STEP); GRAPHICS(data,NORMAL_DATA1,NORMAL_DATA2,STEP,1); char text1[40]="Elastic Pseudo Acceleration Spectrum",text2[20]="Peroid (sec)",text3[20]="Spa (g)"; OUTPUT_HTML_GRAPH(time,Spa,STEP,text1,text2,text3); textcolor(15); printf("na - Output data is written in Text, Excel and Html file -"); system("start /w Graph-outputHTML.html"); free(t);free(Ag);free(time);free(Sd);free(Spa); free(NORMAL_DATA1);free(NORMAL_DATA2); getch(); return 0; } void ANALYSIS(double t[],double Ag[],double T[],double Sd[],double Spa[],double GRAVITY,double zet,double endp,int &kn,int &STEP){ double dt,m,k,c,K,a,b,df,dv,du,dac; double *u = new double [N]; double *v = new double [N]; double *ac = new double [N]; double *omega = new double [N]; double *Sv = new double [N]; double *Sa = new double [N]; double *Spv = new double [N]; int i,j; dt = t[2] - t[1]; STEP = endp/dt; //Ag[end+1]=0; T[0]=0.00; for (j=0;j<= STEP;j++){// equation of motion(Newmark linear method) omega[j]=2*PI/T[j]; // Natural Frequency m=1; k=omega[j]*omega[j]*m; c=2*m*omega[j]*zet/100; K=k+3*c/dt+6*m/(dt*dt); a=6*m/dt+3*c; b=3*m+dt*c/2; for (i=0;i<= kn-1;i++){ u[0]=0; //initial conditions v[0]=0; ac[0]=0; df=-(Ag[i+1]-Ag[i])+a*v[i]+b*ac[i]; // delta Force du=df/K; dv=3*du/dt-3*v[i]-dt*ac[i]/2; dac=6*(du-dt*v[i])/(dt*dt)-3*ac[i]; u[i+1]=u[i]+du; v[i+1]=v[i]+dv; ac[i+1]=ac[i]+dac; } Sd[j] = MAX_ABS(u,kn); //Sv[j] = MAX_ABS(v,kn); //Sa[j] = MAX_ABS(ac,kn); Spv[j] =Sd[j]*omega[j]; Spa[j] = Sd[j]*(omega[j]*omega[j])/GRAVITY; T[j+1]=T[j]+dt; //cout<<T[j]<<" "<< Spa[j]<<endl; } Sd[1]=0; Spv[0]=0;Spv[1]=0;Spa[0]=MAX_ABS(Ag,kn)/GRAVITY;Spa[1]=MAX_ABS(Ag,kn)/GRAVITY; free(u);free(v);free(ac);free(omega); free(Sv);free(Sa);free(Spv); } void MessageInitialData(double GRAVITY,double zet,double endp){ char Qa,Qb,Qc,Qd,Qe,Qf,Qg,Qk; int i;Qa=201;Qb=205;Qc=187;Qd=200;Qe=188,Qf=186,Qg=204,Qk=185; printf("tttt%c",Qa); for (i=1;i<61;i++) printf("%c",Qb); printf("%cn",Qc); printf("tttt%c >> IN THE NAME OF GOD << %cn",Qf,Qf); printf("tttt%c Elastic Response Spectrum %cn",Qf,Qf); printf("tttt%c",Qg); for (i=1;i<61;i++) printf("%c",Qb); printf("%cn",Qk); printf("tttt%c Unit: Free unit %cn",Qf,Qf); printf("tttt%c Notice: All input values must be positive %cn",Qf,Qf); printf("tttt%c",Qg); for (i=1;i<61;i++) printf("%c",Qb); printf("%cn",Qk); printf("tttt%c Program is written by Salar Delavar Ghashghaei %cn",Qf,Qf); printf("tttt%c E-mail: salar.d.ghashghaei@gmail.com %cn",Qf,Qf); printf("tttt%c",Qd); for (i=1;i<61;i++) printf("%c",Qb); printf("%cn",Qe); MessageAnalysisReportTEXT(); printf(" Gravitational Constant: %fn",GRAVITY); printf(" Damping Ratio in percent (%): %fn",zet); printf(" End Period of Spectrum (sec): %fn",endp); } void IMPORT_GRAPH(double data[8],double DATA1[],double DATA2[],double NORMAL_DATA1[],double NORMAL_DATA2[],int n){ double DATA1NorMin,DATA1NorMax,DATA2NorMin,DATA2NorMax,DATA1_min,DATA1_max,DATA2_min,DATA2_max; DATA1_min=MIN(DATA1,n); DATA1_max=MAX(DATA1,n); DATA2_min=MIN(DATA2,n); DATA2_max=MAX(DATA2,n); for (int i=1;i<n;i++){ NORMAL_DATA1[i]=DATA1[i]/(DATA1_max-DATA1_min); // Normalize DATA1 NORMAL_DATA2[i]=DATA2[i]/(DATA2_max-DATA2_min); // Normalize DATA2
  • 3. } DATA1NorMin=MIN(NORMAL_DATA1,n);//Minimum Normalize DATA1 DATA2NorMin=MIN(NORMAL_DATA2,n);//Minimum Normalize DATA2 DATA1NorMax=MAX(NORMAL_DATA1,n);//Maximum Normalize DATA1 DATA2NorMax=MAX(NORMAL_DATA2,n);//Maximum Normalize DATA2 data[0]=DATA1NorMin; data[1]=DATA1NorMax; data[2]=DATA2NorMin; data[3]=DATA2NorMax; data[4]=DATA1_min; data[5]=DATA1_max; data[6]=DATA2_min; data[7]=DATA2_max; } void GRAPHICS(double data[8],double NORMAL_DATA1[],double NORMAL_DATA2[],int n,int kind){ double DATA1NorMin,DATA1NorMax,DATA2NorMin,DATA2NorMax,DATA1_min,DATA1_max,DATA2_min,DATA2_max; DATA1NorMin=data[0]; DATA1NorMax=data[1]; DATA2NorMin=data[2]; DATA2NorMax=data[3]; DATA1_min=data[4]; DATA1_max=data[5]; DATA2_min=data[6]; DATA2_max=data[7]; int gd = DETECT, gm, color; DWORD screenWidth = GetSystemMetrics(SM_CXSCREEN); DWORD screenHeight = GetSystemMetrics(SM_CYSCREEN); initwindow(screenWidth,screenHeight,"",-3,-3);// init window graphics //initwindow(getmaxx( ),getmaxy( )); // initial window graphics //initgraph(&gd, &gm, "C:TCBGI"); int i,j,a,x1,y1,x2,y2,Lx,Ly; //initwindow(300, 300); x1=95; y1=85; x2=x1+1250; y2=y1+500; Lx=x2-x1; Ly=y2-y1; setbkcolor(0);// set background //setcolor(9); // color rectangle line //setlinestyle(0,0,2);// (style,pattern,thickness) //rectangle( x1, y1, x2,y2); //setcolor(10); //bar( x1, y1, x2, y2); setlinestyle(0,0,1);// (style,pattern,thickness) setcolor(9); // color dash line if (DATA1NorMin < 0 && DATA1NorMax > 0){ a=y1*1/20;// Y - Coordinate Axis - 10 steps for (i=1;i<=19;i++) for (j=0;j<=124;j=j+2) line(Lx*i/20 +x1,y1+j*a,Lx*i/20 +x1,y1+(j+1)*a); a=x1*1/20; // X - Coordinate Axis - 10 steps for (i=1;i<=19;i++) for (j=0;j<=310;j=j+2) line( x1+j*a,Ly*i/20 +y1,x1+(j+1)*a,Ly*i/20 +y1); a=y1*1/5;// Y - Coordinate Axis - 5 steps for (i=1;i<=10;i++) line(Lx*i/10 +x1,y2,Lx*i/10 +x1,y2-a); a=x1*1/5; // X - Coordinate Axis - 5 steps for (i=1;i<=10;i++) line( x1,y2-Ly*i/10,x1+a,y2-Ly*i/10); } else if (DATA2NorMin < 0 && DATA2NorMax > 0){ a=y1*1/20;// Y - Coordinate Axis - 10 steps for (i=1;i<=19;i++) for (j=0;j<=124;j=j+2) line(Lx*i/20 +x1,y1+j*a,Lx*i/20 +x1,y1+(j+1)*a); a=x1*1/20; // X - Coordinate Axis - 10 steps for (i=1;i<=19;i++) for (j=0;j<=310;j=j+2) line( x1+j*a,Ly*i/20 +y1,x1+(j+1)*a,Ly*i/20 +y1); a=y1*1/5;// Y - Coordinate Axis - 5 steps for (i=1;i<=10;i++) line(Lx*i/10 +x1,y2,Lx*i/10 +x1,y2-a); a=x1*1/5; // X - Coordinate Axis - 5 steps for (i=1;i<=10;i++) line( x1,y2-Ly*i/10,x1+a,y2-Ly*i/10); } else{ a=y1*1/20;// Y - Coordinate Axis - 10 steps for (i=1;i<=9;i++) for (j=0;j<=120;j=j+2) line(Lx*i/10 +x1,y1+j*a,Lx*i/10 +x1,y1+(j+1)*a); a=x1*1/20; // X - Coordinate Axis - 10 steps for (i=1;i<=9;i++) for (j=0;j<=310;j=j+2) line( x1+j*a,Ly*i/10 +y1,x1+(j+1)*a,Ly*i/10 +y1); a=y1*1/5;// Y - Middle Coordinate Axis - 5 steps for (i=1;i<=19;i++) line(Lx*i/20 +x1,y2,Lx*i/20 +x1,y2-a); a=x1*1/5; // X - Middle Coordinate Axis - 5 steps for (i=1;i<=19;i++) line( x1,y2-Ly*i/20,x1+a,y2-Ly*i/20); a=y1*1/10;// Y - Middle Coordinate Axis - 100 steps for (i=1;i<=99;i++) line(Lx*i/100 +x1,y2,Lx*i/100 +x1,y2-a); a=x1*1/7; // X - Middle Coordinate Axis - 100 steps for (i=1;i<=99;i++) line( x1,y2-Ly*i/100,x1+a,y2-Ly*i/100); } //cleardevice(); setcolor(WHITE);// set text color if (kind == 0){ settextstyle(1, 0, 5);settextjustify(10, 5); outtextxy(x2/2 -400,25,"Elastic Displacement Spectrum");// print text in window subtitle settextstyle(1, 1, 1);settextjustify(10, 5); outtextxy(x1/10 -10,.5*Ly+y1,"Sd");// print text in window graphics y } else if(kind == 1){ settextstyle(1, 0, 5);settextjustify(10, 5); outtextxy(x2/2 -500,25,"Elastic Pseudo Acceleration Spectrum");// print text in window subtitle settextstyle(1, 1, 1);settextjustify(10, 5); outtextxy(x1/10 -10,.6*Ly+y1,"Spa (g)");// print text in window graphics y } settextjustify(50, 5);settextstyle(1, 0, 1); outtextxy(x2/2 -10,y2 +50,"Peroid (sec)");// print text in window graphics x char bufferX[10][100],bufferY[10][100]; double dXdata,dYdata; settextstyle(-1, 0,-3);settextjustify(10, 5); sprintf(bufferX[1], "%.3e" , DATA1_min); outtextxy(x1-45,y2+10,bufferX[1]);// print text in window graphic x axis point sprintf(bufferX[1], "%.3e" , DATA2_min); outtextxy(x1-69,y2 -5,bufferX[1]);// print text in window graphic y axis point for (i=1;i<=10;i++){ dXdata = DATA1_min + 0.1*i*(DATA1_max - DATA1_min); if (ABS(dXdata) <= 1e-20) dXdata = 0.0; // if number is very low, got it zero sprintf(bufferX[i], "%.3e" ,dXdata); outtextxy(x1+Lx*i*.1-45,y2+10,bufferX[i]);// print text in window graphic x axis point -> max } for (i=1;i<=10;i++){ dYdata = DATA2_min + 0.1*i*(DATA2_max - DATA2_min); if (ABS(dYdata) <= 1e-20) dYdata = 0.0; // if number is very low, got it zero sprintf(bufferY[i], "%.3e" , dYdata); outtextxy(x1-69,y2-Ly*i*.1 -5,bufferY[i]);// print text in window graphic y axis point -> max } double *X = new double [N]; double *Y = new double [N]; //Absolute data double DATA1NorMin_Abs,DATA2NorMin_Abs; DATA1NorMin_Abs=ABS(DATA1NorMin);DATA2NorMin_Abs=ABS(DATA2NorMin); /* setcolor(9); setlinestyle(0,0,2);// (style,pattern,thickness) line(Lx*(DATA1NorMin_Abs/(DATA1NorMax-DATA1NorMin)) +x1,y1,Lx*(DATA1NorMin_Abs/(DATA1NorMax-DATA1NorMin)) +x1,y2); //Middle axis -X line(x1,y2-Ly*(DATA2NorMin_Abs/(DATA2NorMax-DATA2NorMin)),x2,y2-Ly*(DATA2NorMin_Abs/(DATA2NorMax-DATA2NorMin))); // Middle axis -Y */ if (DATA2NorMin < 0 && DATA2NorMax > 0 && DATA1NorMin >= 0) X[0]=x2,Y[0]=y2;//First point else if (DATA2NorMin <= 0 && DATA2NorMax <= 0) X[0]=x2,Y[0]=y2;//First point else X[0]=x1,Y[0]= y2-Ly*(NORMAL_DATA2[1]/(DATA2NorMax-DATA2NorMin));//First point // Draw line setcolor(YELLOW); setlinestyle(0,0,2);// (style,pattern,thickness) for (i=1;i<=n-1;i++){ NORMAL_DATA1[i] = NORMAL_DATA1[i] + DATA1NorMin_Abs;//Absolute DATA1 NORMAL_DATA2[i] = NORMAL_DATA2[i] + DATA2NorMin_Abs;//Absolute DATA2
  • 4. X[i] = x1+Lx*(NORMAL_DATA1[i]/(DATA1NorMax-DATA1NorMin)); Y[i] = y2-Ly*(NORMAL_DATA2[i]/(DATA2NorMax-DATA2NorMin)); line(X[i-1],Y[i-1],X[i],Y[i]); } // Covering error ;-) setcolor(9); settextstyle(1, 0,1); rectangle( x1, y1, x2,y2); /* // Middle axis double dXdata_abs,dYdata_abs; int Ix,Iy; if (DATA1NorMin < 0 && DATA1NorMax > 0) for (i=1;i<=10;i++) { dXdata = DATA1_min + 0.1*i*(DATA1_max - DATA1_min);//cout<<dXdata<<endl; if (dXdata > 0 && dXdata < .00001) Ix=i;//cout<<"Ix: "<<Ix<<endl; } line(Lx*Ix/10 +x1,y1,Lx*Ix/10 +x1,y2); if (DATA2NorMin < 0 && DATA2NorMax > 0) for (i=1;i<=10;i++) { dYdata = DATA2_min + 0.1*i*(DATA2_max - DATA2_min);//cout<<dYdata<<endl; if (dYdata > 0 && dYdata < .00001) Iy=i;//cout<<"Iy: "<<Iy<<endl; } line(x1,Ly*Iy/10 +y1,x2,Ly*Iy/10 +y1); */ /* Box text */ /* setcolor(9); settextstyle(1, 0,1); rectangle( x1+350, y2+50, x1+900,y2+80); setlinestyle(1,0,3);settextjustify(10, 5);// (style,pattern,thickness) outtextxy(x1+355,y2+55,"Analysis");// print text in box setlinestyle(1,0,3);settextjustify(10, 5);// (style,pattern,thickness) outtextxy(x1+620,y2+55,"Bilinear");// print text in box setcolor(YELLOW);line(x1+500,y2+65,x1+600,y2+65); setcolor(10);line(x1+765,y2+65,x1+850,y2+65); */ getch(); closegraph(); } double ABS(double B){ double B_abs; if (B < 0) B_abs = -B;//Absolute number else B_abs = B; return B_abs; } double MIN(double A[],int n){ int i; double Amin; Amin = A[0]; for (i=1;i<n;i++){ if (Amin > A[i]) Amin=A[i]; } return Amin;//Minimum DATA } double MAX(double A[],int n){ int i; double Amax; Amax = A[0]; for (i=1;i<n;i++){ if (Amax < A[i]) Amax=A[i]; } return Amax;//Maximum DATA } void MessageErrorReportTEXT(){ int i; char Ql; Ql=176; textcolor(12); printf("an "); for (i=1;i<50;i++) printf("%c",Ql); printf(" Error Report "); for (i=1;i<50;i++) printf("%c",Ql); printf("n"); } void OUTPUT_EXCEL(double time[],double Sd[],double Spa[],int n){ // EXCEL OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText03, "w"); fprintf(OutputFile," ### Output Elastic Response Spectrum ###n"); fprintf(OutputFile,"Step,Time,Spectral Displacement,Pseudo Acceleration Spectrumn"); for(i=0;i<n;i++) fprintf(OutputFile,"%d,%f,%f,%fn",i+1,time[i],Sd[i],Spa[i]); fclose(OutputFile); } void OUTPUT_html(double GRAVITY,double zet,double endp,double time[],double Sd[],double Spa[],int n){ // HTML OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText04, "w"); fprintf(OutputFile,"<html> <body bgcolor="green">n"); // TOP TITLE oF HTML FILE fprintf(OutputFile,"<table style=”width:100%” border="2px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<th bgcolor="cyan"> Elastic Response Spectrum - Output Report </th> n"); // TABLE 1 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<th colspan="2" bgcolor="orange"> Input Data </th> n"); fprintf(OutputFile,"<tr> <th bgcolor="orange"> Gravitational Constant: </th><th> %.3e </th></tr>n",GRAVITY); fprintf(OutputFile,"<tr> <th bgcolor="orange"> Damping Ratio in percent (%): </th><th> %.3e </th></tr>n",zet); fprintf(OutputFile,"<tr> <th bgcolor="orange"> End Period of Spectrum (sec): </th><th> %.3e </th></tr>n",endp); // TABLE 2 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<th colspan="4" bgcolor="orange"> Displacement and Pseudo Acceleration Spectrum</th> n"); fprintf(OutputFile,"<tr> <th bgcolor="orange"> Step </th><th bgcolor="orange"> Time(Period) </th> <th bgcolor="orange"> Spectral Displacement </th> <th bgcolor="orange"> Pseudo Acceleration Spectrum </th></tr>n"); for(i=0;i<n;i++){ fprintf(OutputFile,"<tr> <td align ="center"> %d </td> <td align ="center"> %.3e </td> <td align ="center"> %.3e </td> <td align ="center"> %.3e </td></tr>n",i+1,time[i],Sd[i],Spa[i]); } fprintf(OutputFile,"</table></body></html>n"); fclose(OutputFile); } void MessageCheckInput(int M){ if (M>N || M<2){ MessageErrorReportTEXT(); printf(" Please check this file! -> [ ElasticResponseSpectrum-inputACCELERATION.csv ]n"); printf(" Number of data : %d - Minimum : 3 - Maximum : 20000",M); Sleep(40000); exit(1); } } void MessageAnalysisReportTEXT(){ int i; char Ql=176; printf("n "); for (i=1;i<50;i++) printf("%c",Ql); printf(" Input Data "); for (i=1;i<50;i++) printf("%c",Ql); printf("n"); } void MessageCheck_IMPORT_DATA01(double GRAVITY,double zet,double endp){ if ( GRAVITY < 0 || zet < 0 || endp< 0 ){ MessageErrorReportTEXT(); printf(" Please check this file! -> [%s]n",ShowText01); printf(" *** Negative data input value is not acceptable ***n"); printf(" Gravitational Constant: %f",GRAVITY); printf(" Damping Ratio in percent (%): %f",zet); printf(" End Period of Spectrum (sec): %f",endp); Sleep(40000); exit(1); } } /* void IMPORT_DATA01(double &GRAVITY,double &zet,double &endp){ ifstream IN1;IN1.open("ElasticResponseSpectrum-input.csv"); IN1>>GRAVITY>>zet>>endp; IN1.close(); } void IMPORT_DATA02(double t[],double Ag[],double GRAVITY,int &kn){ double Time,Acceleration,dt;char CHAR; int i=0; ifstream IN2;IN2.open("ElasticResponseSpectrum-inputACCELERATION.csv");//import strain-stress of elements while(IN2 >> Time >> CHAR >> Acceleration){ t[i]=Time;Ag[i]=Acceleration*GRAVITY; //cout<<"t["<<i<<"]:"<<t[i]<<" - Ag["<<i<<"]:"<<Ag[i]<<endl; i++; } kn=i; IN2.close(); } */
  • 5. void IMPORT_DATA01(double &GRAVITY,double &zet,double &endp){ int i=0; double AA[3]; FILE *InputFile; InputFile = fopen(ShowText01, "r"); if (!InputFile){ MessageErrorReportTEXT(); printf(" File is not available! -> [%s] n",ShowText01); } char line[100],a[100]; while(i < N && fgets(line,sizeof(line),InputFile) != NULL){ sscanf(line,"%s",a); //printf("a[%d]: %sn",i,a); AA[i]= atof(a); i++; } GRAVITY=AA[0];zet=AA[1];endp=AA[2]; } void IMPORT_DATA02(double t[],double Ag[],double GRAVITY,int &kn){ int i = 0; FILE *InputFile; InputFile = fopen(ShowText02, "r"); if (!InputFile){ MessageErrorReportTEXT(); printf(" File is not available! -> [%s] n",ShowText02); exit(1); } char line[1000]; double Time,Acceleration; do{ fscanf(InputFile,"%lf,%lf",&Time,&Acceleration); t[i]=Time;Ag[i]=Acceleration*GRAVITY; //printf("%d - t[%d]: %lf - Ag[%d]: %lfn",i,i,t[i],i,Ag[i]); i++; } while(i < N && fgets(line,sizeof(line),InputFile) != NULL); kn = i; } void textcolor(int ForgC){ WORD wColor; //This handle is needed to get the current background attribute HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_SCREEN_BUFFER_INFO csbi; //csbi is used for wAttributes word if(GetConsoleScreenBufferInfo(hStdOut, &csbi)){ //To mask out all but the background attribute, and to add the color wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F); SetConsoleTextAttribute(hStdOut, wColor); } return; } double MAX_ABS(double A[],int n){ int i; double B[N]; double Amax; // abs value for (i=0;i<n;i++){ B[i] = A[i]; if(B[i] < 0) B[i] = -B[i]; } // Max of abs Amax = B[0]; for (i=1;i<n;i++){ if(Amax < B[i]) Amax = B[i]; } return Amax; } void OUTPUT_HTML_GRAPH(double X[],double Y[],int n,const char text1[],const char text2[],const char text3[]){ // HTML GRAPH OUTPUT int i; double x,y,NorX[N],NorY[N],Xmax,Ymax; Xmax=MAX_ABS(X,n); Ymax=MAX_ABS(Y,n); for (i=0;i<n;i++){ NorX[i] = X[i]/Xmax; NorY[i] = Y[i]/Ymax; //printf("t %f %f n",NorX[i],NorY[i]); } FILE *OutputFile; OutputFile = fopen(ShowText05, "w"); fprintf(OutputFile,"<!DOCTYPE HTML><html><body style="background-color:black;"><font color="white"><head><script> n"); fprintf(OutputFile,"window.onload = function(){ n"); fprintf(OutputFile,"var canvas = document.getElementById("myCanvas");var s1 = canvas.getContext("2d");var s2 = canvas.getContext('2d'); n"); fprintf(OutputFile,"var s3 = canvas.getContext("2d");var s4 = canvas.getContext("2d");var s5 = canvas.getContext("2d"); n"); fprintf(OutputFile,"var x=120,y=80,X,Y,Lx=1100,Ly=500,i; n"); fprintf(OutputFile,"s3.beginPath();s3.lineWidth = 3;s3.strokeStyle = "cyan";s3.rect(x,y,Lx,Ly); n"); fprintf(OutputFile,"for(i=0;i<9;i++){s3.moveTo(x+Lx*(i+1)*.1,y+Ly);s3.lineTo(x+Lx*(i+1)*.1,y+Ly-10);}; n"); fprintf(OutputFile,"for(i=0;i<9;i++){s3.moveTo(x,y+Ly*(i+1)*.1);s3.lineTo(x+10,y+Ly*(i+1)*.1);};s3.stroke();n"); fprintf(OutputFile,"s1.beginPath();s1.lineWidth = 3;s1.strokeStyle = "yellow"; n"); for (i=0;i<n-1;i++){ fprintf(OutputFile,"s1.moveTo(%f,%f);",120+NorX[i]*1100,80+500-NorY[i]*500); fprintf(OutputFile,"s1.lineTo(%f,%f); n",120+NorX[i+1]*1100,80+500-NorY[i+1]*500); } fprintf(OutputFile,"s1.stroke(); n"); fprintf(OutputFile,"s2.beginPath();s2.lineWidth = 1;s2.strokeStyle = "cyan";s2.setLineDash([5, 5]); n"); fprintf(OutputFile,"for(i=0;i<19;i++){s2.moveTo(x+Lx*(i+1)*.05,y);s2.lineTo(x+Lx*(i+1)*.05,y+Ly);} n"); fprintf(OutputFile,"s2.lineWidth = 1;s2.strokeStyle = "cyan";for(i=0;i<19;i++){s2.moveTo(x,y+Ly*(i+1)*.05);s2.lineTo(x+Lx,y+Ly*(i+1)*.05);} s2.stroke();n"); fprintf(OutputFile,"X=x+.25*Lx;Y=.7*y;s4.translate(X,Y);s4.font="50px serif";s4.fillStyle = "#7fff00";s4.fillText("%s",0,0); n",text1); fprintf(OutputFile,"s4.save();X=-X+.2*x;Y=-Y+y+.6*Ly;s4.translate(X,Y);s4.rotate(3*Math.PI/2);s4.font="15px serif"; n"); fprintf(OutputFile,"s4.fillStyle = "#7fff00";s4.textAlign = "left";s4.fillText("%s",0,0);s4.restore(); n",text3); fprintf(OutputFile,"s4.save();X=.2*Lx;Y=y+Ly-20;s4.translate(X,Y);s4.rotate(2*Math.PI);s4.font="15px serif";s4.fillStyle = "#7fff00"; n"); fprintf(OutputFile,"s4.textAlign = "left";s4.fillText("%s",0,0);s4.restore(); n",text2); for(i=0;i<10;i++){ x=.1*(i+1)*Xmax; fprintf(OutputFile,"s5.save();X=-.29*Lx+Lx*(%d+1)*.1;Y=.3*y+Ly+20;s5.rotate(2*Math.PI);s5.font="16px serif"; n",i); fprintf(OutputFile,"s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText("%.3e",X,Y);s5.restore(); n",x); } for(i=0;i<10;i++){ y=.1*(i+1)*Ymax; fprintf(OutputFile,"s5.save();X=-.28*Lx-50;Y=Ly+.3*y-Ly*(%d+1)*.1;s5.rotate(2*Math.PI);s5.font="16px serif"; n",i); fprintf(OutputFile,"s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText("%.3e",X,Y);s5.restore(); n",y); } fprintf(OutputFile,"s5.save();X=-.25*Lx;Y=.3*y+Ly+20;s5.rotate(2*Math.PI);s5.font="16px serif";s5.fillStyle = "#7fff00";s5.fillText(0,X,Y);s5.restore(); n"); fprintf(OutputFile,"s5.save();X=-.25*Lx-50;Y=Ly+.3*y;s5.rotate(2*Math.PI);s5.font="16px serif";s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText(0,X,Y);s5.restore();}; n"); fprintf(OutputFile,"</script></head><body><canvas id="myCanvas" width="1300" height="1300" style="border:1px solid black;"></canvas></body></html> n"); fclose(OutputFile); }
  • 7. Figure(2) Input time acceleration
  • 10. Figure(5) Elastic pseudo acceleration spectrum