SlideShare a Scribd company logo
>> 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 Economy
tnoulas
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryption
securityxploded
 
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
National Chengchi University
 
Dun ddd
Dun dddDun 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
Mahmoud Samir Fayed
 
Apache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API BasicsApache Flink Training: DataSet API Basics
Apache Flink Training: DataSet API Basics
Flink 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 Graphics
Andreas 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 Fox
Databricks
 
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
 
C++ programming
C++ programmingC++ programming
C++ programming
Pranav Ghildiyal
 
LCS35
LCS35LCS35
Procesos
ProcesosProcesos
Procesos
PublioScipion
 
Ns2 by khan
Ns2 by khan Ns2 by khan
Data Analysis
Data AnalysisData Analysis
Data Analysis
Assignmentpedia
 
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
Mahmoud Samir Fayed
 
Class 31: Deanonymizing
Class 31: DeanonymizingClass 31: Deanonymizing
Class 31: Deanonymizing
David Evans
 
Embracing the-power-of-refactor
Embracing the-power-of-refactorEmbracing the-power-of-refactor
Embracing the-power-of-refactor
Xiaojun REN
 
OpenGL L05-Texturing
OpenGL L05-TexturingOpenGL L05-Texturing
OpenGL L05-Texturing
Mohammad Shaker
 

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 assignment
Abdullah 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.docx
voversbyobersby
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cuda
Ferdinand 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.pdf
sutharbharat59
 
array
arrayarray
array
teach4uin
 
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 manual
Uma mohan
 
week-3x
week-3xweek-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 ...
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.pdf
anyacarpets
 
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
Moriyoshi Koizumi
 
04 Algorithms
04 Algorithms04 Algorithms
04 Algorithms
Omid Djoudi
 
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
Facultad 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.pptx
KarthikVijay59
 
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 Engineers
varun arora
 
Ping to Pong
Ping to PongPing to Pong
Ping to Pong
Matt Provost
 
Clock For My
Clock For MyClock For My
Clock For My
shamalanamnam
 
Sequential radar tracking
Sequential radar trackingSequential radar tracking
Sequential radar tracking
Assignmentpedia
 

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 programming
Salar Delavar Qashqai
 
Truss optimization with excel solver
Truss optimization with excel solverTruss optimization with excel solver
Truss optimization with excel solver
Salar 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 sap2000
Salar 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 ductility
Salar 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 programming
Salar 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 programming
Salar 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 matlab
Salar 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

bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
VICTOR MAESTRE RAMIREZ
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
University of Maribor
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
Madhumitha Jayaram
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
RadiNasr
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
JamalHussainArman
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 

Recently uploaded (20)

bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student MemberIEEE Aerospace and Electronic Systems Society as a Graduate Student Member
IEEE Aerospace and Electronic Systems Society as a Graduate Student Member
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
Presentation of IEEE Slovenia CIS (Computational Intelligence Society) Chapte...
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Wearable antenna for antenna applications
Wearable antenna for antenna applicationsWearable antenna for antenna applications
Wearable antenna for antenna applications
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdfIron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
Iron and Steel Technology Roadmap - Towards more sustainable steelmaking.pdf
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptxML Based Model for NIDS MSc Updated Presentation.v2.pptx
ML Based Model for NIDS MSc Updated Presentation.v2.pptx
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 

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