SlideShare a Scribd company logo
1 of 16
Download to read offline
>> IN THE NAME OF GOD <
Pushover Analysis Force Analogy Method with Force Control Based on Timoshenko Beam Theory in C programming
C program is written by Salar Delavar Ghashghaei – Publication Date: 22/October/2018
E-mail: salar.d.ghashghaei@gmail.com
C Code:
#include <stdio.h>
#include <windows.h> // text color
#include <conio.h>
#define NN 6 // Degree of freedom
#define Ne 1 // number of element
#define N 2 // number of node
#define STEP 10000 // number of node
#define ShowText01 "PushoverForceAnalogyMethodTimoshenkoFC-inputDATA.csv"
#define ShowText02 "PushoverForceAnalogyMethodTimoshenkoFC-inputCOORDINATE.csv"
#define ShowText03 "PushoverForceAnalogyMethodTimoshenkoFC-inputHINGE.csv"
#define ShowText04 "Output data is written in Excel and Html file"
#define ShowText05 "PushoverForceAnalogyMethodTimoshenkoFC-outputEXCEL.csv"
#define ShowText06 "PushoverForceAnalogyMethodTimoshenkoFC-outputHTML.html"
#define ShowText07 "Graph-outputHTML.html"
void IMPORT_DATA01(double &Iner,double &Area,double &As,double &Elas,double &Ny,double &Fini,int &M);
void IMPORT_DATA02(double x[],double y[],int &n);
void IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int &k);
void Matrix_Zero(double A[][NN],int n);
void Matrix_Stiffness(double Iner,double Area,double As,double Elas,double Ny,double L[],double lanX[],double lanY[],double A[],double B[],double C[],double D[],double E[],double K[][6],double K_G[][6],int I,int II);
void MatrixDetermination(double A[][NN],int n,double &Product);
void MatrixInverse(double [][NN], double [][NN],int );
void MatrixMulti01(double [][NN], double [], double [],int );
void Matrix_Transpose(double A[6][6],double B[6][6]);
void Matrix_Multiplication(double A[6][6],double B[6][6],double C[6][6]);
void ElementInternalForce(double K[][6],double U[],double lanX[],double lanY[],double ee[][6],int I,int II);// Calculate internal element force
void ELEMNT_FORCE_OUTPUT(double eleF[1][6],double ELE_FORCE[6][STEP],int n);
double ABS(double);
double MIN(double A[],int n);
double SQRT2(double D);
void MessageInitialData(double Iner,double Area,double As,double Elas,double Ny,double Fini,int M,double x[],double y[]);
void MessageAnalysisReport();
void MessageErrorReportTEXT();
void MessageInputDataTEXT();
void MessageCheck_IMPORT_DATA01(double Iner,double Area,double As,double Elas,double Ny,int M);
void MessageCheck_IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int n);
void MessageCheckMk(int M,int K);
void MessageStrCoorTEXT(double X[],double Y[],int n);
void MessagePlasticHingeTEXT(double TET01[],double MOM01[],double TET02[],double MOM02[],int n);
void MessageResult(double output_base01[],double output_base02[],double output_u01[],double output_u02[],double output_u03[],int n);
void OUTPUT_excel(double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n);
void OUTPUT_html(double Iner,double Area,double As,double Elas,double Ny,double Fini,double x[],double y[],double TET[],double MOM[],double TEO[],double SHE[],double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n,int m,int M);
void ANALYSIS(double TET01[],double MOM01[],double TET02[],double MOM02[],int np,double Iner,double Area,double As,double Elas,double Ny,double Fini,double x[],double y[],int M);
void Distance(int);
void textcolor(int ForgC);
void DATE_TIME();
void OUTPUT_HTML_GRAPH(double X[],double Y[],int n,const char text1[],const char text2[],const char text3[]);
double MAX_ABS(double A[],int n);
void PlasticHingeStiffnessCOFF(double A[],double B[],double C[],int n);
void PlasticHingeStiffness(double A[1][6],int I,int II,double B[],double C[],double &MomS,double &KRK,int n);
int main(){
double Elas,Iner,Area,As,Ny,Fini,Dmax,x[2],y[2],TET[10],MOM[10],TEO[10],SHE[10];
int n,np,m,M;
IMPORT_DATA01(Iner,Area,As,Elas,Ny,Fini,M);
IMPORT_DATA02(x,y,n);
IMPORT_DATA03(TET,MOM,TEO,SHE,np);
MessageCheck_IMPORT_DATA01(Iner,Area,As,Elas,Ny,M);
MessageCheck_IMPORT_DATA03(TET,MOM,TEO,SHE,np);
MessageCheckMk(M,np);
textcolor(14);
MessageInitialData(Iner,Area,As,Elas,Ny,Fini,M,x,y);
MessageStrCoorTEXT(x,y,n);
MessagePlasticHingeTEXT(TET,MOM,TEO,SHE,np);
textcolor(11);
MessageAnalysisReport();
ANALYSIS(TET,MOM,TEO,SHE,np,Iner,Area,As,Elas,Ny,Fini,x,y,M);
getch();
return 0;
}
void MatrixInverse(double A[][NN], double C[][NN],int n){
int i,j,l;
double c_A[n][n],B[n][n],m,Sum;
for (i=0;i<n;i++)
for (j=0;j<n;j++)
c_A[i][j]=A[i][j];
// Inverse [Kinit]
for (i=0;i<n;i++)
for (j=0;j<n;j++){
if (i==j)
B[i][j]=1;
else
B[i][j]=0;
}
for (j=0;j<n-1;j++)
for (i=j+1;i<n;i++){
m=c_A[i][j]/c_A[j][j];
for (l=0;l<n;l++){
c_A[i][l] -= m*c_A[j][l];
B[i][l] -= m*B[j][l];
}
}
// backward substitutions
for (i=n-1;i>=0;i--)
for (j=0;j<n;j++){
Sum=0;
for (l=i+1;l<n;l++)
Sum += c_A[i][l]*C[l][j];
C[i][j]=(B[i][j]-Sum)/c_A[i][i];
}
}
void ElementInternalForce(double K[][6],double U[],double lanX[],double lanY[],double ee[][6],int I,int II){
double lan[6][6],UU[6],ff,ll[6][6];
int i,j;
lan[0][0]=lanX[I];lan[0][1]=lanY[I];lan[0][2]=0;lan[0][3]=0;lan[0][4]=0;lan[0][5]=0;
lan[1][0]=-lanY[I];lan[1][1]=lanX[I];lan[1][2]=0;lan[1][3]=0;lan[1][4]=0;lan[1][5]=0;
lan[2][0]=0;lan[2][1]=0;lan[2][2]=1;lan[2][3]=0;lan[2][4]=0;lan[2][5]=0;
lan[3][0]=0;lan[3][1]=0;lan[3][2]=0;lan[3][3]=lanX[I];lan[3][4]=lanY[I];lan[3][5]=0;
lan[4][0]=0;lan[4][1]=0;lan[4][2]=0;lan[4][3]=-lanY[I];lan[4][4]=lanX[I];lan[4][5]=0;
lan[5][0]=0;lan[5][1]=0;lan[5][2]=0;lan[5][3]=0;lan[5][4]=0;lan[5][5]=1;
if (II == 1){
UU[0]=0;UU[1]=0;UU[2]=0;UU[3]=U[0];UU[4]=0;UU[5]=0;
}
if (II == 2){
UU[0]=0;UU[1]=0;UU[2]=U[1];UU[3]=U[0];UU[4]=0;UU[5]=0;
}
if (II == 3){
UU[0]=0;UU[1]=0;UU[2]=U[1];UU[3]=U[0];UU[4]=0;UU[5]=U[2];
}
for (i=0;i<6;i++)
for (j=0;j<6;j++)
ll[i][j]=0;
// [f] = [K] *[lan]* [u]
Matrix_Multiplication(K,lan,ll);
for (i=0; i<6; i++){
ff=0;
for (j=0; j<6; j++)
ff += ll[i][j]*UU[j];
ee[I][i] = ff;
}
}
void MatrixMulti01(double A[][NN], double B[], double C[],int n){
int i,j;
double ff;
// [u] = [Kinv] * [f]
for (i=0; i<n; i++)
{
ff=0;
for (j=0; j<n; j++)
ff += A[i][j]*B[j];
C[i] = ff;
}
}
double ABS(double B){
if (B < 0)
B = -B;//Absolute number
else
B = B;
return B;
}
double MIN(double A[],int n){
int i;
double Cmin;
Cmin = A[0];
// Max of abs
for (i=0;i<n;i++){
if(Cmin > A[i])
Cmin = A[i];
}
return Cmin;
}
void Distance(int i){
if (i < 10)
printf("bt");
if (i >= 10 && i <= 99)
printf("btb");
if (i >= 100 && i <= 999)
printf("btbb");
if (i >= 1000 && i <= 9999)
printf("btbbb");
if (i >= 10000 && i <= 20000)
printf("btbbbb");
}
void MessageInitialData(double Iner,double Area,double As,double Elas,double Ny,double Fini,int M,double x[],double y[]){
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<60;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf("tttt%c >> IN THE NAME OF GOD << %cn",Qf,Qf);
printf("tttt%c Pushover Analysis Force Analogy Method with Force Control %cn",Qf,Qf);
printf("tttt%c Based on Timoshenko Beam Theory %cn",Qf,Qf);
printf("tttt%c UNIT: Free Unit %cn",Qf,Qf);
printf("tttt%c",Qg);
for (i=1;i<60;i++)
printf("%c",Qb);
printf("%cn",Qk);
printf("tttt%c This 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<60;i++)
printf("%c",Qb);
printf("%cn",Qe);
MessageInputDataTEXT();
printf(" Section moment inertia: %.3en",Iner);
printf(" Section area: %.3en",Area);
printf(" Section shear area: %.3en",As);
printf(" Section elasticity modulus: %.3en",Elas);
printf(" Section poisson ratio: %.3en",Ny);
printf(" External Incremental Fx force [DOF(4)]: %.3en",Fini);
printf(" Number of increment: %dn",M);
}
void MessageAnalysisReport(){
int i;
char Ql=176;
printf("n ");
for (i=1;i<64;i++)
printf("%c",Ql);
printf(" Analysis Report ");
for (i=1;i<64;i++)
printf("%c",Ql);
printf("n");
}
void MessageCheck_IMPORT_DATA01(double Iner,double Area,double As,double Elas,double Ny,int M){
if (Iner <= 0 || Area <= 0 || As<= 0 || Elas<= 0 || Ny<= 0 || M <= 0 ){
MessageErrorReportTEXT();
printf(" Section moment inertia: %.3en",Iner);
printf(" Section area: %.3en",Area);
printf(" Section shear area: %.3en",As);
printf(" Section elasticity modulus: %.3en",Elas);
printf(" Section poisson ratio: %.3en",Ny);
printf(" Number of increment: %dn",M);
Sleep(40000);
exit(1);
}
}
void MessageCheck_IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int n){
int i;
for(i=0;i<n;i++){
if (TET[i] < 0|| MOM[i] < 0 || TEO[i] < 0|| SHE[i] < 0){
MessageErrorReportTEXT();
printf(" Please check this file! -> [%s]n",ShowText03);
printf(" Row %d has a negative value.n",i+1);
printf(" *** Negative data input value is not acceptable ***n");
Sleep(40000);
exit(1);
}
}
}
void MessageCheckMk(int M,int K){
if (M < 2 || M > STEP || K < 2 || K > 10){
MessageErrorReportTEXT();
printf(" Please check this file! -> [%s]n",ShowText01);
printf(" Please check this file! -> [%s]n",ShowText02);
printf(" Plastic hinge data: %d - Plastic hinge data must be data -> Minimum : 2 - Maximum : 10n",K);
printf(" Number of increment: %d - Plastic hinge data must be data -> Minimum : 2 - Maximum : %dn",M,STEP);
Sleep(40000);
exit(1);
}
}
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 MessageInputDataTEXT(){
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 OUTPUT_excel(double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n){
// EXCEL OUTPUT
int i,I;
FILE *OutputFile;
OutputFile = fopen(ShowText05, "w");
fprintf(OutputFile," ### Pushover Analysis Force Analogy Method with Force Control Based on Timoshenko Beam Theory ###n");
fprintf(OutputFile,"Element Number %dn",1);
fprintf(OutputFile,"n");
fprintf(OutputFile,"Increment,Base Shear [DOF(1)],Base Moment [DOF(3)],Displacement [DOF(4)],Rotation [DOF(3)],Rotation [DOF(6)]n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%d,%e,%e,%e,%e,%en",i+1,output_base01[i],output_base02[i],output_u01[i],output_u02[i],output_u03[i]);
fprintf(OutputFile,"n");
fprintf(OutputFile,"Increment,axial-i,shear-i,moment-i,axial-j,shear-j,moment-jn");
for(i=0;i<n;i++)
fprintf(OutputFile,"%d,%e,%e,%e,%e,%e,%en",i+1,C[0][i],C[1][i],C[2][i],C[3][i],C[4][i],C[5][i]);
fclose(OutputFile);
}
void Matrix_Zero(double A[][NN],int n){
int i,j;
for (i=0;i<n;i++)
for (j=0;j<n;j++)
A[i][j] = 0;
}
void MatrixDetermination(double A[][NN],int n,double &Product){
// row operations
int i,j,k;
double m,B[n][n];
for (i=0;i<n;i++)
for (j=0;j<n;j++)
B[i][j]=A[i][j];
for (k=0;k<n-1;k++)
for (i=k+1;i<n;i++){
m = B[i][k]/B[k][k];
for (j=0;j<n;j++)
B[i][j] -= m*B[k][j];
}
Product=1;
for (i=0;i<n;i++)
Product *= B[i][i];
// display results
if (Product == 0){
printf("ant ### it Seens that Golobal Matrix is singular or structure is unstable!!! ###n");
//Sleep(40000);
//exit(1);
}
}
void IMPORT_DATA01(double &Iner,double &Area,double &As,double &Elas,double &Ny,double &Fini,int &M){
double Import_Data[7];
int i=0;
FILE *InputFile;
InputFile = fopen(ShowText01, "r");
if (!InputFile){
MessageErrorReportTEXT();
printf(" File is not available! -> [%s] n",ShowText01);
Sleep(6000);
exit(1);
}
char line[100],a[100];
while(i < 8 && fgets(line,sizeof(line),InputFile) != NULL){
sscanf(line,"%s",a);
//printf("a[%d]: %sn",i,a);
Import_Data[i]= atof(a);
i++;
}
Iner=Import_Data[0];
Area=Import_Data[1];
As=Import_Data[2];
Elas=Import_Data[3];
Ny=Import_Data[4];
Fini=Import_Data[5];
M=Import_Data[6];
}
void IMPORT_DATA02(double x[],double y[],int &n){
int i = 0;
FILE *InputFile;
InputFile = fopen(ShowText02, "r");
if (!InputFile){
MessageErrorReportTEXT();
printf(" File is not available! -> [%s] n",ShowText02);
Sleep(6000);
exit(1);
}
char line[1000];
do{
fscanf(InputFile,"%lf,%lf",&x[i],&y[i]);
i++;
}
while(i < 2 && fgets(line,sizeof(line),InputFile) != NULL);
n = i;
//printf("%dn",n);
}
void IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int &k){
int i = 0;
FILE *InputFile;
InputFile = fopen(ShowText03, "r");
if (!InputFile){
MessageErrorReportTEXT();
printf(" File is not available! -> [%sn",ShowText03);
Sleep(6000);
exit(1);
}
char line[1000];
do{
fscanf(InputFile,"%lf,%lf,%lf,%lf",&TET[i],&MOM[i],&TEO[i],&SHE[i]);
//printf("%d - TET01[%d]: %lf - MOM01[%d]: %lf TET02[%d]: %lf - MOM02[%d]: %lfn",i,i,TET[i],i,MOM[i],i,TEO[i],i,SHE[i]);
i++;
}
while(i < 10 && fgets(line,sizeof(line),InputFile) != NULL);
k = i-1;
//printf("%dn",k);
}
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;
}
void ANALYSIS(double TET[],double MOM[],double TEO[],double SHE[],int np,double Iner,double Area,double As,double Elas,double Ny,double Fini,double x[],double y[],int M){
int i,j,z,zMAX;
double Product,MomS01,MomS02,She01,krk01,krk02,krk03,Rk01[10],Rk02[10],K[NN][NN],Kinv[NN][NN],eleF[Ne][6];
double L[Ne],lanX[Ne],lanY[Ne],AA[Ne],BB[Ne],CC[Ne],DD[Ne],EE[Ne],FF[NN],u[NN];
double *output_u01 = new double [STEP];
double *output_u02 = new double [STEP];
double *output_u03 = new double [STEP];
double *output_base01 = new double [STEP];
double *output_base02 = new double [STEP];
double *X = new double [STEP];
double *Y = new double [STEP];
double ELE_FORCE[6][STEP];
double MS[6][6],KG[6][6];
PlasticHingeStiffnessCOFF(TET,MOM,Rk01,np);
PlasticHingeStiffnessCOFF(TET,MOM,Rk02,np);
Matrix_Zero(K,3);
for (i=0;i<3;i++)
u[i] = 0;
for (i=0;i<STEP;i++){
output_u01[i] = 0.0;
output_u02[i] = 0.0;
output_u03[i] = 0.0;
}
for(i=0;i<6*Ne;i++)
for(j=0;j<M;j++)
ELE_FORCE[i][j] = 0;
for (i=0;i<Ne;i++){
L[i] = SQRT2((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i]));
lanX[i] = (x[i+1]-x[i])/L[i];lanY[i] = (y[i+1]-y[i])/L[i];
}
MomS01=0;krk01=0;
MomS02=0;krk02=0;
// STAGE 01
for (z=0;z<M;z++){
u[1]=0;u[2]=0;
FF[0]=Fini*(z+1);
Matrix_Stiffness(Iner,Area,As,Elas,Ny,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); // 0: ele 1 - 1: stiffness matrix: 1
K[0][0]= KG[3][3];//DOF(4)
MatrixDetermination(K,1,Product);
if (Product == 0)
break;
MatrixInverse(K,Kinv,1);// Inverse [Kinit]
MatrixMulti01(Kinv,FF,u,1);
zMAX = z + 1;
ElementInternalForce(MS,u,lanX,lanY,eleF,0,1); // 0: ele 1 - 1: step 1
ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,z);
// for (i=0;i<1;i++)
// printf("t u[%d]: %f n",i,u[i]);
// for (i=0;i<6;i++)
// printf("t %f n",ELE_FORCE[i][z]);
output_u01[z]=u[0];//output displacement DOF(4)
output_base01[z]=-ELE_FORCE[1][z];//output base shear DOF(1)
output_base02[z]=-ELE_FORCE[2][z];//output base moment DOF(3)
if (ABS(eleF[0][1]) >= SHE[0]){
printf("t Shear-1: %f reaached to yield: %f n",ABS(eleF[0][1]),SHE[0]);
break;
}
if (ABS(eleF[0][2]) >= MOM[0]){
printf("t Moment-1: %f reaached to yield: %f n",ABS(eleF[0][2]),MOM[0]);
break;
}
if (ABS(eleF[0][5]) >= MOM[0]){
printf("t Moment-2: %f reaached to yield: %f n",ABS(eleF[0][5]),MOM[0]);
break;
}
if (ABS(u[1]) >= TET[np-1]){
printf("t Rotation-1: %f reaached to yield: %f n",ABS(u[1]),TET[np-1]);
break;
}
if (ABS(u[2]) >= TET[np-1]){
printf("t Rotation-2: %f reaached to yield: %f n",ABS(u[2]),TET[np-1]);
break;
}
}// for
// So plastic hinge has formed in 2 node
// STAGE 02
for (z=zMAX;z<M;z++){
u[2]=0;
PlasticHingeStiffness(eleF,0,2,MOM,Rk01,MomS01,krk01,np); // 5:Moment DOF(6)
FF[0]=Fini*(z+1);
FF[1]=-MomS01;
Matrix_Stiffness(Iner,Area,As,Elas,Ny,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); // 0: ele 1 - 1: stiffness matrix: 1
K[0][0]= KG[3][3];//DOF(4)
K[0][1]= KG[3][2];//DOF(4)
K[1][0]= KG[2][3];//DOF(3)
K[1][1]= KG[2][2]+krk01;//DOF(3)
// for (i=0;i<2;i++){
// for (j=0;j<2;j++)
// printf("t K[%d][%d]: %.4e ",i,j,K[i][j]);
// printf("n");
// }
// printf("n");
MatrixDetermination(K,2,Product);
if (Product == 0)
break;
MatrixInverse(K,Kinv,2);// Inverse [Kinit]
MatrixMulti01(Kinv,FF,u,2);
zMAX = z + 1;
ElementInternalForce(MS,u,lanX,lanY,eleF,0,2); // 2: step 2
// for (i=0;i<2;i++)
// printf("t u[%d]: %f n",i,u[i]);
// for (i=0;i<6;i++)
// printf("t %f n",eleF[0][i]);
ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,z);
output_u01[z]=u[0];//output displacement DOF(4)
output_u02[z]=u[1];//output rotation DOF(3)
output_base01[z]=-ELE_FORCE[1][z];//output base shear DOF(1)
output_base02[z]=-ELE_FORCE[2][z];//output base moment DOF(3)
if (ABS(eleF[0][1]) >= SHE[0]){
printf("t Shear-1: %f reaached to yield: %f n",ABS(eleF[0][1]),SHE[0]);
break;
}
// if (ABS(eleF[0][2]) >= MOM[0]){
// printf("t Moment-1: %f reaached to yield: %f n",ABS(eleF[0][2]),MOM[0]);
// break;
// }
if (ABS(eleF[0][5]) >= MOM[0]){
printf("t Moment-2: %f reaached to yield: %f n",ABS(eleF[0][5]),MOM[0]);
break;
}
if (ABS(u[1]) >= TET[np-1]){
printf("t Rotation-1: %f reaached to yield: %f n",ABS(u[1]),TET[np-1]);
break;
}
if (ABS(u[2]) >= TET[np-1]){
printf("t Rotation-2: %f reaached to yield: %f n",ABS(u[2]),TET[np-1]);
break;
}
}// for
// So plastic hinge has formed in 1 node
// STAGE 03
for (z=zMAX;z<M;z++){
PlasticHingeStiffness(eleF,0,2,MOM,Rk01,MomS01,krk01,np); // 2:Moment DOF(3)
PlasticHingeStiffness(eleF,0,5,MOM,Rk02,MomS02,krk02,np); // 5:Moment DOF(6)
//printf("ttt %.3e %.3e n",MomS01,krk01);
FF[0]=Fini*(z+1);
FF[1]=-MomS01;
FF[2]=-MomS02;
Matrix_Stiffness(Iner,Area,As,Elas,Ny,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); // 0: ele 1 - 1: stiffness matrix: 1
K[0][0]= KG[3][3];//DOF(4)
K[0][1]= KG[3][2];//DOF(4)
K[0][2]= KG[3][5];//DOF(4)
K[1][0]= KG[2][3];//DOF(6)
K[1][1]= KG[2][2]+krk01;//DOF(6)
K[1][2]= KG[2][5];//DOF(6)
K[2][0]= KG[5][3];//DOF(3)
K[2][1]= KG[5][2];//DOF(3)
K[2][2]= KG[5][5]+krk02;//DOF(3)
// for (i=0;i<3;i++){
// for (j=0;j<3;j++)
// printf("t K[%d][%d]: %f ",i,j,K[i][j]);
// printf("n");
// }
// MatrixDetermination(K,3,Product);
// if (Product == 0)
// break;
MatrixInverse(K,Kinv,3);// Inverse [Kinit]
MatrixMulti01(Kinv,FF,u,3);
zMAX = z + 1;
ElementInternalForce(MS,u,lanX,lanY,eleF,0,3);// 3: step 3
// for (i=0;i<3;i++)
// printf("t u[%d]: %f n",i,u[i]);
// for (i=0;i<6;i++)
// printf("t %f n",eleF[0][i]);
ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,z);
output_u01[z]=u[0];//output displacement DOF(4)
output_u02[z]=u[1];//output rotation DOF(3)
output_u03[z]=u[2];//output rotation DOF(6)
output_base01[z]=-ELE_FORCE[1][z];//output base shear DOF(1)
output_base02[z]=-ELE_FORCE[2][z];//output base moment DOF(3)
if (ABS(eleF[0][1]) >= SHE[0]){
printf("t Shear-1: %f reaached to yield: %f n",ABS(eleF[0][1]),SHE[0]);
break;
}
// if (ABS(eleF[0][2]) >= MOM[0]){
// printf("t Moment-1: %f reaached to yield: %f n",ABS(eleF[0][2]),MOM[0]);
// break;
// }
// if (ABS(eleF[0][5]) >= MOM[0]){
// printf("t Moment-2: %f reaached to yield: %f n",ABS(eleF[0][5]),MOM[0]);
// break;
// }
if (ABS(u[1]) >= TET[np-1]){
printf("t Rotation-1: %f reaached to yield: %f n",ABS(u[1]),TET[np-1]);
break;
}
if (ABS(u[2]) >= TET[np-1]){
printf("t Rotation-2: %f reaached to yield: %f n",ABS(u[2]),TET[np-1]);
break;
}
}// for
MessageResult(output_base01,output_base02,output_u01,output_u02,output_u03,zMAX);
OUTPUT_excel(output_u01,output_u02,output_u03,output_base01,output_base02,ELE_FORCE,zMAX);
OUTPUT_html(Iner,Area,As,Elas,Ny,Fini,x,y,TET,MOM,TEO,SHE,output_u01,output_u02,output_u03,output_base01,output_base02,ELE_FORCE,zMAX,np,M);
char text1[30]="Base Shear-Displacement Graph",text2[30]="Displacement [DOF(5)]",text3[30]="Base Shear [DOF(1)]";
for (i=0;i<zMAX;i++){
X[i] = output_u01[i];// Disp. DOF(5)
Y[i] = output_base01[i];// Base Shear DOF(1)
}
OUTPUT_HTML_GRAPH(X,Y,zMAX,text1,text2,text3);
textcolor(15);
printf("na - %s -n",ShowText04);
system("start /w Graph-outputHTML.html");
DATE_TIME();
free(output_u01);free(output_u02);free(output_u03);
free(output_base01);free(output_base02);
free(X);free(Y);
}
void PlasticHingeStiffnessCOFF(double A[],double B[],double C[],int n){
int i;
for (i=0;i<n-1;i++){
C[i]=(B[i+1]-B[i])/(A[i+1]-A[i]);
//printf("%d - Rk[%d]: %fn",i,i,C[i]);
}
}
void PlasticHingeStiffness(double A[1][6],int I,int II,double B[],double C[],double &MomS,double &KRK,int n){
int i;
for (i=0;i<n-1;i++){
if (ABS(A[I][II]) >= B[i] && ABS(A[I][II]) <= B[i+1]){
MomS = B[i];KRK = C[i];//printf("t %.3e %.3e %.3e n",B[i],MomS,KRK);
}
}
if (ABS(A[I][II]) > B[n-1]){
MomS = 0;KRK = 0;
}
}
void DATE_TIME(){
printf("nt");
system("echo %date%");
printf("t");
system("echo %time%");
}
void Matrix_Stiffness(double Iner,double Area,double As,double Elas,double Ny,double L[],double lanX[],double lanY[],double A[],double B[],double C[],double D[],double E[],double K[][6],double K_G[][6],int I,int II){
double g,EI,EA,fi,lan[6][6],lan_Tr[6][6],ans[6][6];
g = Elas/(2*(1+Ny));
EI = Elas*Iner;
EA = Elas*Area;
fi = (12*EI)/(g*As*L[I]*L[I]);// Timoshenko beam coefficient
A[I] = ((4+fi)*EI/L[I])*(1/(1+fi));
B[I] = (6*EI/(L[I]*L[I]))*(1/(1+fi));
C[I] = ((2-fi)*EI/L[I])*(1/(1+fi));
D[I] = (12*EI/(L[I]*L[I]*L[I]))*(1/(1+fi));//printf("tt %f n",D[I]);
E[I] = EA/L[I];
for (int i=0;i<6;i++)
for (int j=0;j<6;j++)
K[i][j] = 0.0;
//I:2 number of element - II: kind of stiffness matrix
if (II==1){// No plastic hinge
K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0;
K[1][0]=0;K[1][1]=D[I];K[1][2]=B[I];K[1][3]=0;K[1][4]=-D[I];K[1][5]=B[I];
K[2][0]=0;K[2][1]=B[I];K[2][2]=A[I];K[2][3]=0;K[2][4]=-B[I];K[2][5]=C[I];
K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0;
K[4][0]=0;K[4][1]=-D[I];K[4][2]=-B[I];K[4][3]=0;K[4][4]=D[I];K[4][5]=-B[I];
K[5][0]=0;K[5][1]=B[I];K[5][2]=C[I];K[5][3]=0;K[5][4]=-B[I];K[5][5]=A[I];
}
if (II==2){// plastic hinge at i
K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0;
K[1][0]=0;K[1][1]=.25*D[I];K[1][2]=0;K[1][3]=0;K[1][4]=-.25*D[I];K[1][5]=.5*B[I];
K[2][0]=0;K[2][1]=0;K[2][2]=0;K[2][3]=0;K[2][4]=0;K[2][5]=0;
K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0;
K[4][0]=0;K[4][1]=-.25*D[I];K[4][2]=0;K[4][3]=0;K[4][4]=.25*D[I];K[4][5]=-.5*B[I];
K[5][0]=0;K[5][1]=.5*B[I];K[5][2]=0;K[5][3]=0;K[5][4]=-.5*B[I];K[5][5]=(3/4)*A[I];
}
if (II==3){// plastic hinge at j
K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0;
K[1][0]=0;K[1][1]=.25*D[I];K[1][2]=.5*B[I];K[1][3]=0;K[1][4]=-.25*D[I];K[1][5]=0;
K[2][0]=0;K[2][1]=.5*B[I];K[2][2]=(3/4)*A[I];K[2][3]=0;K[2][4]=-.5*B[I];K[2][5]=0;
K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0;
K[4][0]=0;K[4][1]=-.25*D[I];K[4][2]=-.5*B[I];K[4][3]=0;K[4][4]=.25*D[I];K[4][5]=0;
K[5][0]=0;K[5][1]=0;K[5][2]=0;K[5][3]=0;K[5][4]=0;K[5][5]=0;
}
if (II==4){// plastic hinge at i and j
K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0;
K[1][0]=0;K[1][1]=0;K[1][2]=0;K[1][3]=0;K[1][4]=0;K[1][5]=0;
K[2][0]=0;K[2][1]=0;K[2][2]=0;K[2][3]=0;K[2][4]=0;K[2][5]=0;
K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0;
K[4][0]=0;K[4][1]=0;K[4][2]=0;K[4][3]=0;K[4][4]=0;K[4][5]=0;
K[5][0]=0;K[5][1]=0;K[5][2]=0;K[5][3]=0;K[5][4]=0;K[5][5]=0;
}
lan[0][0]=lanX[I];lan[0][1]=lanY[I];lan[0][2]=0;lan[0][3]=0;lan[0][4]=0;lan[0][5]=0;
lan[1][0]=-lanY[I];lan[1][1]=lanX[I];lan[1][2]=0;lan[1][3]=0;lan[1][4]=0;lan[1][5]=0;
lan[2][0]=0;lan[2][1]=0;lan[2][2]=1;lan[2][3]=0;lan[2][4]=0;lan[2][5]=0;
lan[3][0]=0;lan[3][1]=0;lan[3][2]=0;lan[3][3]=lanX[I];lan[3][4]=lanY[I];lan[3][5]=0;
lan[4][0]=0;lan[4][1]=0;lan[4][2]=0;lan[4][3]=-lanY[I];lan[4][4]=lanX[I];lan[4][5]=0;
lan[5][0]=0;lan[5][1]=0;lan[5][2]=0;lan[5][3]=0;lan[5][4]=0;lan[5][5]=1;
Matrix_Transpose(lan,lan_Tr);
Matrix_Multiplication(lan_Tr,K,ans);
Matrix_Multiplication(ans,lan,K_G);
}
void ELEMNT_FORCE_OUTPUT(double eleF[1][6],double ELE_FORCE[6][STEP],int n){
int i;
for (i=0;i<6;i++)
ELE_FORCE[i][n]=eleF[0][i];
}
double SQRT2(double D){
int it,itermax;
double residual,tolerance,x,dx,dx_ABS,f,df;
it = 0; // initialize iteration count
itermax = 100000;
residual = 100; // initialize residual
tolerance = 1e-12;
x = 1;// initialize answer
while (residual > tolerance){
f = x*x - D;
df = 2 * x;
dx = f/df;
x= x - dx;
residual = ABS(dx); // abs residual
it = it + 1; // increment iteration count
//printf("f: %f -tdx: %f -tresidual: %fn",f,dx,residual);
if (it == itermax){
//printf("tSQRT2(number,power) : SQRT2(%f) - iteration: %d -> ## The solution is not converged ##n",D,it);
break;
}
}
if (it < itermax){
//printf("tSQRT(number,power) - SQRT(%f,%f) : %f n",D,n, x);
return x;
}
}
void Matrix_Transpose(double A[6][6],double B[6][6]){
int i,j;
for (i=0;i<6;i++)
for (j=0;j<6;j++)
B[j][i]=A[i][j];
}
void Matrix_Multiplication(double A[6][6],double B[6][6],double C[6][6]){
int i,j,k;
double sum;
for (i=0;i<6;i++)
for (j=0;j<6;j++){
sum=0;
for (k=0;k<6;k++)
sum += A[i][k]*B[k][j];
C[i][j] = sum;
}
}
void MessageResult(double output_base01[],double output_base02[],double output_u01[],double output_u02[],double output_u03[],int n){
int i;
printf("t ");
for (i=0;i<120;i++)
printf("-");
printf("n");
printf("t Increment Base Shear[DOF(1)] Base SMoment[DOF(3)] Disp. [DOF(5)] Rotation [DOF(3)] Rotation [DOF(6)]n");
printf("t ");
for (i=0;i<120;i++)
printf("-");
printf("n");
for (i=0;i<n;i++){
//Distance(i+1);
printf("tt %dt %.3et %.3et %.3et %.3et %.3en",i+1,output_base01[i],output_base01[i],output_u01[i],output_u02[i],output_u03[i]);
}
}
void MessageStrCoorTEXT(double X[],double Y[],int n){
int i;
char Qa,Qb,Qc,Qd,Qe,Qf;
Qa=201;Qb=205;Qc=187;Qd=200;Qe=188;Qf=186;
printf(" %c",Qa);
for (i=1;i<33;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf(" %c Structural Coordinate Data %cn",Qf,Qf);
printf(" %c X Y %cn",Qf,Qf);
printf(" %c",Qd);
for (i=1;i<33;i++)
printf("%c",Qb);
printf("%cn",Qe);
for(i=0;i<n;i++)
printf(" %.3e %.3en",X[i],Y[i]);
}
void MessagePlasticHingeTEXT(double TET[],double MOM[],double TEO[],double SHE[],int n){
int i;
char Qa,Qb,Qc,Qd,Qe,Qf;
int BB=201,CC=205,DD=187,EE=200,FF=188,GG=186;
Qa=BB;Qb=CC;Qc=DD;Qd=EE;Qe=FF;Qf=GG;
printf(" %c",Qa);
for (i=1;i<67;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf(" %c Plastic Hinge Data %cn",Qf,Qf);
printf(" %c Plastic Moment Hinge 01 | Plastic Shear Hinge 02 %cn",Qf,Qf);
printf(" %c Rotation Moment | Shear Deformation Shear %cn",Qf,Qf);
printf(" %c",Qd);
for (i=1;i<67;i++)
printf("%c",Qb);
printf("%cn",Qe);
for(i=0;i<n;i++)
printf(" %.3e %.3e %.3e %.3en",TET[i],MOM[i],TEO[i],SHE[i]);
}
void OUTPUT_html(double Iner,double Area,double As,double Elas,double Ny,double Fini,double X[],double Y[],double TET[],double MOM[],double TEO[],double SHE[],double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n,int m,int M){
// HTML OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText06, "w");
fprintf(OutputFile,"<html> <body bgcolor="green">n");
// IMPORT IMAGE
fprintf(OutputFile,"<img src="PushoverForceAnalogyMethodTimoshenkoFC-image01.png" style="width:1000px ; height:500px" alt="analysis"><br><br>n");
// TOP TITLE oF HTML FILE
fprintf(OutputFile,"<table style=”width:100%” border="2px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th bgcolor="cyan"> Pushover Analysis Force Analogy Method with Force Control Based on Timoshenko Beam Theory - Output Report </th> n");
// TABLE 1
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th colspan="2" bgcolor="orange"> Input Data </th> </tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange">Section moment inertia: </th><th> %.3e </th> </tr>n",Iner);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Section area: </th><th> %.3e </th> </tr>n",Area);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Section shear area: </th><th> %.3e </th> </tr>n",As);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Section elasticity modulus: </th><th> %.3e </th> </tr>n",Elas);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Section poisson ratio: </th><th> %.3e </th> </tr>n",Ny);
fprintf(OutputFile,"<tr> <th bgcolor="orange">External Incremental Fx force [DOF(4)]: </th><th> %.3e </th> </tr>n",Fini);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Number of increment: </th><th> %d </th> </tr>n",M);
// TABLE 2
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<th colspan="4" bgcolor="orange"> Hinges Data </th>n");
fprintf(OutputFile,"<tr> <th colspan="2" bgcolor="orange">Hinge[1]: Moment - Rotation </th> <th colspan="2" bgcolor="orange">Hinge[2]: Shear - Shear Deformation </th></tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange"> Rotation </th> <th bgcolor="orange"> Moment </th><th bgcolor="orange"> Shear Deformation </th> <th bgcolor="orange"> Shear</th> </tr>n");
for(i=0;i<m;i++){
fprintf(OutputFile,"<tr> <td align ="center"> %.3e </td> <td align ="center"> %.3e </td><td align ="center"> %.3e </td><td align ="center"> %.3e </td> </tr>n",TET[i],MOM[i],TEO[i],SHE[i]);
}
// TABLE 3
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th colspan="3" bgcolor="orange"> Structral Coordinate </th> </tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange">Node Number </th><th bgcolor="orange">X Coordinate</th> <th bgcolor="orange">Y Coordinate</th> </tr>n");
for(i=0;i<Ne+1;i++){
fprintf(OutputFile,"<tr> <td align ="center"> %d </td><td align ="center"> %.3e </td> <td align ="center"> %.3e </td>n",i+1,X[i],Y[i]);
}
// TABLE 4
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th colspan="6" bgcolor="orange"> Structral Deformation </th> </tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange">Increment</th> <th bgcolor="orange">Base Shear [DOF(1)]</th><th bgcolor="orange">Base Moment [DOF(3)]</th><th bgcolor="orange">Displacement [DOF(5)]</th> <th bgcolor="orange">Rotation [DOF(3)]</th><th bgcolor="orange">Rotation [DOF(6)]</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> <td align ="center"> %.3e </td><td align ="center"> %.3e </td></tr>n",i+1,output_base01[i],output_base02[i],output_u01[i],output_u02[i],output_u03[i]);
}
// TABLE 5
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th colspan="7" bgcolor="orange"> Structral Element Internal Forces </th> </tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange">Increment</th> <th bgcolor="orange">Axial-i</th> <th bgcolor="orange">Shear-i</th> <th bgcolor="orange">Moment-i</th> <th bgcolor="orange">Axial-j</th> <th bgcolor="orange">Shear-j</th> <th bgcolor="orange">Moment-j</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><td align ="center"> %.3e </td><td align ="center"> %.3e </td><td align ="center"> %.3e </td> </tr>n",i+1,C[0][i],C[1][i],C[2][i],C[3][i],C[4][i],C[5][i]);
}
fprintf(OutputFile,"</table></body></html>n");
fclose(OutputFile);
}
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,Xmax,Ymax;
double *Xnew = new double [STEP];
double *Ynew = new double [STEP];
double *NorX = new double [STEP];
double *NorY = new double [STEP];
Xmax=MAX_ABS(X,n);
Ymax=MAX_ABS(Y,n);
Xnew[0]=0;Ynew[0]=0;
for (i=0;i<n;i++){
Xnew[i+1] = ABS(X[i]);
Ynew[i+1] = ABS(Y[i]);
}
for (i=0;i<n+1;i++){
NorX[i] = Xnew[i]/Xmax;
NorY[i] = Ynew[i]/Ymax;
//printf("t %f %f n",NorX[i],NorY[i]);
}
FILE *OutputFile;
OutputFile = fopen(ShowText07, "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;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);
free(Xnew);free(Ynew);free(NorX);free(NorY);
}
double MAX_ABS(double A[],int n){
int i;
double B[STEP];
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;
}
Plot :
Figure(1) Analysis file
Figure(2) Input csv file
Figure(3) Input coordinate of structure csv file
Figure(4) Input plastic hinge (Moment-Rotation & Shear-Shear Deformation) csv file
Figure(5) Output report in csv file
Figure(6) Output report in html file
Figure(7) Base Shear-Displacement Graph in Html

More Related Content

What's hot

Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using cArghodeepPaul
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C LanguageRAJWANT KAUR
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointersSushil Mishra
 
Nonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programmingNonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programmingSalar Delavar Qashqai
 
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
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkarsandeep kumbhkar
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structuresvinay arora
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robinAbdullah Al Naser
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)vinay arora
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
 

What's hot (20)

Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
Common problems solving using c
Common problems solving using cCommon problems solving using c
Common problems solving using c
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
Pnno
PnnoPnno
Pnno
 
programs
programsprograms
programs
 
C Programming
C ProgrammingC Programming
C Programming
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
C programms
C programmsC programms
C programms
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
Nonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programmingNonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programming
 
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 ...
 
All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 

Similar to Pushover analysis force analogy method with force control based on timoshenko beam theory in c programming

Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...Salar Delavar Qashqai
 
Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Kanis Fatema Shanta
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysisVishal Singh
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translationShobhit Saxena
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
CSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxCSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxTasnimSaimaRaita
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solutionyogini sharma
 
Write a program to perform translation.
 Write a program to perform translation. Write a program to perform translation.
Write a program to perform translation.Shobhit Saxena
 
Program to reflecta triangle
Program to reflecta triangleProgram to reflecta triangle
Program to reflecta triangleTanya Makkar
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignmentZenith SVG
 

Similar to Pushover analysis force analogy method with force control based on timoshenko beam theory in c programming (20)

C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
Nonlinear analysis of fixed support beam with hinge by hinge method in c prog...
 
Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]
 
Numerical analysis
Numerical analysisNumerical analysis
Numerical analysis
 
array.ppt
array.pptarray.ppt
array.ppt
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
C-programs
C-programsC-programs
C-programs
 
2D array
2D array2D array
2D array
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translation
 
Progr3
Progr3Progr3
Progr3
 
week-3x
week-3xweek-3x
week-3x
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Function basics
Function basicsFunction basics
Function basics
 
CSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptxCSE 103 Project Presentation.pptx
CSE 103 Project Presentation.pptx
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
Write a program to perform translation.
 Write a program to perform translation. Write a program to perform translation.
Write a program to perform translation.
 
Program to reflecta triangle
Program to reflecta triangleProgram to reflecta triangle
Program to reflecta triangle
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
C programming codes for the class assignment
C programming codes for the class assignmentC programming codes for the class assignment
C programming codes for the class assignment
 
C programs
C programsC programs
C programs
 

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
 
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
 
Elastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programmingElastic response pseudo spectrum in c programming
Elastic response pseudo spectrum 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
 
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
 
1st order pushover analysis of column subjected to compression and tension ax...
1st order pushover analysis of column subjected to compression and tension ax...1st order pushover analysis of column subjected to compression and tension ax...
1st order pushover analysis of column subjected to compression and tension ax...Salar Delavar Qashqai
 
Pushover analysis of steel section beam with semi rigid connection in matlab ...
Pushover analysis of steel section beam with semi rigid connection in matlab ...Pushover analysis of steel section beam with semi rigid connection in matlab ...
Pushover analysis of steel section beam with semi rigid connection in matlab ...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...
 
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
 
Elastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programmingElastic response pseudo spectrum in c programming
Elastic response pseudo spectrum 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
 
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...
 
1st order pushover analysis of column subjected to compression and tension ax...
1st order pushover analysis of column subjected to compression and tension ax...1st order pushover analysis of column subjected to compression and tension ax...
1st order pushover analysis of column subjected to compression and tension ax...
 
Pushover analysis of steel section beam with semi rigid connection in matlab ...
Pushover analysis of steel section beam with semi rigid connection in matlab ...Pushover analysis of steel section beam with semi rigid connection in matlab ...
Pushover analysis of steel section beam with semi rigid connection in matlab ...
 

Recently uploaded

Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 

Recently uploaded (20)

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 

Pushover analysis force analogy method with force control based on timoshenko beam theory in c programming

  • 1. >> IN THE NAME OF GOD < Pushover Analysis Force Analogy Method with Force Control Based on Timoshenko Beam Theory in C programming C program is written by Salar Delavar Ghashghaei – Publication Date: 22/October/2018 E-mail: salar.d.ghashghaei@gmail.com
  • 2. C Code: #include <stdio.h> #include <windows.h> // text color #include <conio.h> #define NN 6 // Degree of freedom #define Ne 1 // number of element #define N 2 // number of node #define STEP 10000 // number of node #define ShowText01 "PushoverForceAnalogyMethodTimoshenkoFC-inputDATA.csv" #define ShowText02 "PushoverForceAnalogyMethodTimoshenkoFC-inputCOORDINATE.csv" #define ShowText03 "PushoverForceAnalogyMethodTimoshenkoFC-inputHINGE.csv" #define ShowText04 "Output data is written in Excel and Html file" #define ShowText05 "PushoverForceAnalogyMethodTimoshenkoFC-outputEXCEL.csv" #define ShowText06 "PushoverForceAnalogyMethodTimoshenkoFC-outputHTML.html" #define ShowText07 "Graph-outputHTML.html" void IMPORT_DATA01(double &Iner,double &Area,double &As,double &Elas,double &Ny,double &Fini,int &M); void IMPORT_DATA02(double x[],double y[],int &n); void IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int &k); void Matrix_Zero(double A[][NN],int n); void Matrix_Stiffness(double Iner,double Area,double As,double Elas,double Ny,double L[],double lanX[],double lanY[],double A[],double B[],double C[],double D[],double E[],double K[][6],double K_G[][6],int I,int II); void MatrixDetermination(double A[][NN],int n,double &Product); void MatrixInverse(double [][NN], double [][NN],int ); void MatrixMulti01(double [][NN], double [], double [],int ); void Matrix_Transpose(double A[6][6],double B[6][6]); void Matrix_Multiplication(double A[6][6],double B[6][6],double C[6][6]); void ElementInternalForce(double K[][6],double U[],double lanX[],double lanY[],double ee[][6],int I,int II);// Calculate internal element force void ELEMNT_FORCE_OUTPUT(double eleF[1][6],double ELE_FORCE[6][STEP],int n); double ABS(double); double MIN(double A[],int n); double SQRT2(double D); void MessageInitialData(double Iner,double Area,double As,double Elas,double Ny,double Fini,int M,double x[],double y[]); void MessageAnalysisReport(); void MessageErrorReportTEXT(); void MessageInputDataTEXT(); void MessageCheck_IMPORT_DATA01(double Iner,double Area,double As,double Elas,double Ny,int M); void MessageCheck_IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int n); void MessageCheckMk(int M,int K); void MessageStrCoorTEXT(double X[],double Y[],int n); void MessagePlasticHingeTEXT(double TET01[],double MOM01[],double TET02[],double MOM02[],int n); void MessageResult(double output_base01[],double output_base02[],double output_u01[],double output_u02[],double output_u03[],int n); void OUTPUT_excel(double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n); void OUTPUT_html(double Iner,double Area,double As,double Elas,double Ny,double Fini,double x[],double y[],double TET[],double MOM[],double TEO[],double SHE[],double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n,int m,int M); void ANALYSIS(double TET01[],double MOM01[],double TET02[],double MOM02[],int np,double Iner,double Area,double As,double Elas,double Ny,double Fini,double x[],double y[],int M); void Distance(int); void textcolor(int ForgC); void DATE_TIME(); void OUTPUT_HTML_GRAPH(double X[],double Y[],int n,const char text1[],const char text2[],const char text3[]); double MAX_ABS(double A[],int n); void PlasticHingeStiffnessCOFF(double A[],double B[],double C[],int n); void PlasticHingeStiffness(double A[1][6],int I,int II,double B[],double C[],double &MomS,double &KRK,int n); int main(){ double Elas,Iner,Area,As,Ny,Fini,Dmax,x[2],y[2],TET[10],MOM[10],TEO[10],SHE[10]; int n,np,m,M; IMPORT_DATA01(Iner,Area,As,Elas,Ny,Fini,M); IMPORT_DATA02(x,y,n); IMPORT_DATA03(TET,MOM,TEO,SHE,np); MessageCheck_IMPORT_DATA01(Iner,Area,As,Elas,Ny,M); MessageCheck_IMPORT_DATA03(TET,MOM,TEO,SHE,np); MessageCheckMk(M,np); textcolor(14); MessageInitialData(Iner,Area,As,Elas,Ny,Fini,M,x,y); MessageStrCoorTEXT(x,y,n); MessagePlasticHingeTEXT(TET,MOM,TEO,SHE,np); textcolor(11); MessageAnalysisReport(); ANALYSIS(TET,MOM,TEO,SHE,np,Iner,Area,As,Elas,Ny,Fini,x,y,M); getch(); return 0; } void MatrixInverse(double A[][NN], double C[][NN],int n){ int i,j,l; double c_A[n][n],B[n][n],m,Sum; for (i=0;i<n;i++) for (j=0;j<n;j++) c_A[i][j]=A[i][j]; // Inverse [Kinit] for (i=0;i<n;i++) for (j=0;j<n;j++){ if (i==j) B[i][j]=1; else B[i][j]=0; } for (j=0;j<n-1;j++) for (i=j+1;i<n;i++){ m=c_A[i][j]/c_A[j][j]; for (l=0;l<n;l++){ c_A[i][l] -= m*c_A[j][l]; B[i][l] -= m*B[j][l]; } } // backward substitutions for (i=n-1;i>=0;i--) for (j=0;j<n;j++){ Sum=0; for (l=i+1;l<n;l++) Sum += c_A[i][l]*C[l][j]; C[i][j]=(B[i][j]-Sum)/c_A[i][i]; } } void ElementInternalForce(double K[][6],double U[],double lanX[],double lanY[],double ee[][6],int I,int II){ double lan[6][6],UU[6],ff,ll[6][6]; int i,j; lan[0][0]=lanX[I];lan[0][1]=lanY[I];lan[0][2]=0;lan[0][3]=0;lan[0][4]=0;lan[0][5]=0; lan[1][0]=-lanY[I];lan[1][1]=lanX[I];lan[1][2]=0;lan[1][3]=0;lan[1][4]=0;lan[1][5]=0; lan[2][0]=0;lan[2][1]=0;lan[2][2]=1;lan[2][3]=0;lan[2][4]=0;lan[2][5]=0; lan[3][0]=0;lan[3][1]=0;lan[3][2]=0;lan[3][3]=lanX[I];lan[3][4]=lanY[I];lan[3][5]=0; lan[4][0]=0;lan[4][1]=0;lan[4][2]=0;lan[4][3]=-lanY[I];lan[4][4]=lanX[I];lan[4][5]=0; lan[5][0]=0;lan[5][1]=0;lan[5][2]=0;lan[5][3]=0;lan[5][4]=0;lan[5][5]=1; if (II == 1){ UU[0]=0;UU[1]=0;UU[2]=0;UU[3]=U[0];UU[4]=0;UU[5]=0; } if (II == 2){ UU[0]=0;UU[1]=0;UU[2]=U[1];UU[3]=U[0];UU[4]=0;UU[5]=0; } if (II == 3){ UU[0]=0;UU[1]=0;UU[2]=U[1];UU[3]=U[0];UU[4]=0;UU[5]=U[2]; } for (i=0;i<6;i++) for (j=0;j<6;j++) ll[i][j]=0; // [f] = [K] *[lan]* [u]
  • 3. Matrix_Multiplication(K,lan,ll); for (i=0; i<6; i++){ ff=0; for (j=0; j<6; j++) ff += ll[i][j]*UU[j]; ee[I][i] = ff; } } void MatrixMulti01(double A[][NN], double B[], double C[],int n){ int i,j; double ff; // [u] = [Kinv] * [f] for (i=0; i<n; i++) { ff=0; for (j=0; j<n; j++) ff += A[i][j]*B[j]; C[i] = ff; } } double ABS(double B){ if (B < 0) B = -B;//Absolute number else B = B; return B; } double MIN(double A[],int n){ int i; double Cmin; Cmin = A[0]; // Max of abs for (i=0;i<n;i++){ if(Cmin > A[i]) Cmin = A[i]; } return Cmin; } void Distance(int i){ if (i < 10) printf("bt"); if (i >= 10 && i <= 99) printf("btb"); if (i >= 100 && i <= 999) printf("btbb"); if (i >= 1000 && i <= 9999) printf("btbbb"); if (i >= 10000 && i <= 20000) printf("btbbbb"); } void MessageInitialData(double Iner,double Area,double As,double Elas,double Ny,double Fini,int M,double x[],double y[]){ 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<60;i++) printf("%c",Qb); printf("%cn",Qc); printf("tttt%c >> IN THE NAME OF GOD << %cn",Qf,Qf); printf("tttt%c Pushover Analysis Force Analogy Method with Force Control %cn",Qf,Qf); printf("tttt%c Based on Timoshenko Beam Theory %cn",Qf,Qf); printf("tttt%c UNIT: Free Unit %cn",Qf,Qf); printf("tttt%c",Qg); for (i=1;i<60;i++) printf("%c",Qb); printf("%cn",Qk); printf("tttt%c This 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<60;i++) printf("%c",Qb); printf("%cn",Qe); MessageInputDataTEXT(); printf(" Section moment inertia: %.3en",Iner); printf(" Section area: %.3en",Area); printf(" Section shear area: %.3en",As); printf(" Section elasticity modulus: %.3en",Elas); printf(" Section poisson ratio: %.3en",Ny); printf(" External Incremental Fx force [DOF(4)]: %.3en",Fini); printf(" Number of increment: %dn",M); } void MessageAnalysisReport(){ int i; char Ql=176; printf("n "); for (i=1;i<64;i++) printf("%c",Ql); printf(" Analysis Report "); for (i=1;i<64;i++) printf("%c",Ql); printf("n"); } void MessageCheck_IMPORT_DATA01(double Iner,double Area,double As,double Elas,double Ny,int M){ if (Iner <= 0 || Area <= 0 || As<= 0 || Elas<= 0 || Ny<= 0 || M <= 0 ){ MessageErrorReportTEXT(); printf(" Section moment inertia: %.3en",Iner); printf(" Section area: %.3en",Area); printf(" Section shear area: %.3en",As); printf(" Section elasticity modulus: %.3en",Elas); printf(" Section poisson ratio: %.3en",Ny); printf(" Number of increment: %dn",M); Sleep(40000); exit(1); } } void MessageCheck_IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int n){ int i; for(i=0;i<n;i++){ if (TET[i] < 0|| MOM[i] < 0 || TEO[i] < 0|| SHE[i] < 0){ MessageErrorReportTEXT(); printf(" Please check this file! -> [%s]n",ShowText03); printf(" Row %d has a negative value.n",i+1); printf(" *** Negative data input value is not acceptable ***n"); Sleep(40000); exit(1); } } } void MessageCheckMk(int M,int K){ if (M < 2 || M > STEP || K < 2 || K > 10){ MessageErrorReportTEXT(); printf(" Please check this file! -> [%s]n",ShowText01); printf(" Please check this file! -> [%s]n",ShowText02); printf(" Plastic hinge data: %d - Plastic hinge data must be data -> Minimum : 2 - Maximum : 10n",K); printf(" Number of increment: %d - Plastic hinge data must be data -> Minimum : 2 - Maximum : %dn",M,STEP); Sleep(40000); exit(1);
  • 4. } } 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 MessageInputDataTEXT(){ 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 OUTPUT_excel(double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n){ // EXCEL OUTPUT int i,I; FILE *OutputFile; OutputFile = fopen(ShowText05, "w"); fprintf(OutputFile," ### Pushover Analysis Force Analogy Method with Force Control Based on Timoshenko Beam Theory ###n"); fprintf(OutputFile,"Element Number %dn",1); fprintf(OutputFile,"n"); fprintf(OutputFile,"Increment,Base Shear [DOF(1)],Base Moment [DOF(3)],Displacement [DOF(4)],Rotation [DOF(3)],Rotation [DOF(6)]n"); for(i=0;i<n;i++) fprintf(OutputFile,"%d,%e,%e,%e,%e,%en",i+1,output_base01[i],output_base02[i],output_u01[i],output_u02[i],output_u03[i]); fprintf(OutputFile,"n"); fprintf(OutputFile,"Increment,axial-i,shear-i,moment-i,axial-j,shear-j,moment-jn"); for(i=0;i<n;i++) fprintf(OutputFile,"%d,%e,%e,%e,%e,%e,%en",i+1,C[0][i],C[1][i],C[2][i],C[3][i],C[4][i],C[5][i]); fclose(OutputFile); } void Matrix_Zero(double A[][NN],int n){ int i,j; for (i=0;i<n;i++) for (j=0;j<n;j++) A[i][j] = 0; } void MatrixDetermination(double A[][NN],int n,double &Product){ // row operations int i,j,k; double m,B[n][n]; for (i=0;i<n;i++) for (j=0;j<n;j++) B[i][j]=A[i][j]; for (k=0;k<n-1;k++) for (i=k+1;i<n;i++){ m = B[i][k]/B[k][k]; for (j=0;j<n;j++) B[i][j] -= m*B[k][j]; } Product=1; for (i=0;i<n;i++) Product *= B[i][i]; // display results if (Product == 0){ printf("ant ### it Seens that Golobal Matrix is singular or structure is unstable!!! ###n"); //Sleep(40000); //exit(1); } } void IMPORT_DATA01(double &Iner,double &Area,double &As,double &Elas,double &Ny,double &Fini,int &M){ double Import_Data[7]; int i=0; FILE *InputFile; InputFile = fopen(ShowText01, "r"); if (!InputFile){ MessageErrorReportTEXT(); printf(" File is not available! -> [%s] n",ShowText01); Sleep(6000); exit(1); } char line[100],a[100]; while(i < 8 && fgets(line,sizeof(line),InputFile) != NULL){ sscanf(line,"%s",a); //printf("a[%d]: %sn",i,a); Import_Data[i]= atof(a); i++; } Iner=Import_Data[0]; Area=Import_Data[1]; As=Import_Data[2]; Elas=Import_Data[3]; Ny=Import_Data[4]; Fini=Import_Data[5]; M=Import_Data[6]; } void IMPORT_DATA02(double x[],double y[],int &n){ int i = 0; FILE *InputFile; InputFile = fopen(ShowText02, "r"); if (!InputFile){ MessageErrorReportTEXT(); printf(" File is not available! -> [%s] n",ShowText02); Sleep(6000); exit(1); } char line[1000]; do{ fscanf(InputFile,"%lf,%lf",&x[i],&y[i]); i++; } while(i < 2 && fgets(line,sizeof(line),InputFile) != NULL); n = i; //printf("%dn",n); } void IMPORT_DATA03(double TET[],double MOM[],double TEO[],double SHE[],int &k){ int i = 0; FILE *InputFile; InputFile = fopen(ShowText03, "r"); if (!InputFile){ MessageErrorReportTEXT(); printf(" File is not available! -> [%sn",ShowText03); Sleep(6000); exit(1); } char line[1000]; do{
  • 5. fscanf(InputFile,"%lf,%lf,%lf,%lf",&TET[i],&MOM[i],&TEO[i],&SHE[i]); //printf("%d - TET01[%d]: %lf - MOM01[%d]: %lf TET02[%d]: %lf - MOM02[%d]: %lfn",i,i,TET[i],i,MOM[i],i,TEO[i],i,SHE[i]); i++; } while(i < 10 && fgets(line,sizeof(line),InputFile) != NULL); k = i-1; //printf("%dn",k); } 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; } void ANALYSIS(double TET[],double MOM[],double TEO[],double SHE[],int np,double Iner,double Area,double As,double Elas,double Ny,double Fini,double x[],double y[],int M){ int i,j,z,zMAX; double Product,MomS01,MomS02,She01,krk01,krk02,krk03,Rk01[10],Rk02[10],K[NN][NN],Kinv[NN][NN],eleF[Ne][6]; double L[Ne],lanX[Ne],lanY[Ne],AA[Ne],BB[Ne],CC[Ne],DD[Ne],EE[Ne],FF[NN],u[NN]; double *output_u01 = new double [STEP]; double *output_u02 = new double [STEP]; double *output_u03 = new double [STEP]; double *output_base01 = new double [STEP]; double *output_base02 = new double [STEP]; double *X = new double [STEP]; double *Y = new double [STEP]; double ELE_FORCE[6][STEP]; double MS[6][6],KG[6][6]; PlasticHingeStiffnessCOFF(TET,MOM,Rk01,np); PlasticHingeStiffnessCOFF(TET,MOM,Rk02,np); Matrix_Zero(K,3); for (i=0;i<3;i++) u[i] = 0; for (i=0;i<STEP;i++){ output_u01[i] = 0.0; output_u02[i] = 0.0; output_u03[i] = 0.0; } for(i=0;i<6*Ne;i++) for(j=0;j<M;j++) ELE_FORCE[i][j] = 0; for (i=0;i<Ne;i++){ L[i] = SQRT2((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i])); lanX[i] = (x[i+1]-x[i])/L[i];lanY[i] = (y[i+1]-y[i])/L[i]; } MomS01=0;krk01=0; MomS02=0;krk02=0; // STAGE 01 for (z=0;z<M;z++){ u[1]=0;u[2]=0; FF[0]=Fini*(z+1); Matrix_Stiffness(Iner,Area,As,Elas,Ny,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); // 0: ele 1 - 1: stiffness matrix: 1 K[0][0]= KG[3][3];//DOF(4) MatrixDetermination(K,1,Product); if (Product == 0) break; MatrixInverse(K,Kinv,1);// Inverse [Kinit] MatrixMulti01(Kinv,FF,u,1); zMAX = z + 1; ElementInternalForce(MS,u,lanX,lanY,eleF,0,1); // 0: ele 1 - 1: step 1 ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,z); // for (i=0;i<1;i++) // printf("t u[%d]: %f n",i,u[i]); // for (i=0;i<6;i++) // printf("t %f n",ELE_FORCE[i][z]); output_u01[z]=u[0];//output displacement DOF(4) output_base01[z]=-ELE_FORCE[1][z];//output base shear DOF(1) output_base02[z]=-ELE_FORCE[2][z];//output base moment DOF(3) if (ABS(eleF[0][1]) >= SHE[0]){ printf("t Shear-1: %f reaached to yield: %f n",ABS(eleF[0][1]),SHE[0]); break; } if (ABS(eleF[0][2]) >= MOM[0]){ printf("t Moment-1: %f reaached to yield: %f n",ABS(eleF[0][2]),MOM[0]); break; } if (ABS(eleF[0][5]) >= MOM[0]){ printf("t Moment-2: %f reaached to yield: %f n",ABS(eleF[0][5]),MOM[0]); break; } if (ABS(u[1]) >= TET[np-1]){ printf("t Rotation-1: %f reaached to yield: %f n",ABS(u[1]),TET[np-1]); break; } if (ABS(u[2]) >= TET[np-1]){ printf("t Rotation-2: %f reaached to yield: %f n",ABS(u[2]),TET[np-1]); break; } }// for // So plastic hinge has formed in 2 node // STAGE 02 for (z=zMAX;z<M;z++){ u[2]=0; PlasticHingeStiffness(eleF,0,2,MOM,Rk01,MomS01,krk01,np); // 5:Moment DOF(6) FF[0]=Fini*(z+1); FF[1]=-MomS01; Matrix_Stiffness(Iner,Area,As,Elas,Ny,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); // 0: ele 1 - 1: stiffness matrix: 1 K[0][0]= KG[3][3];//DOF(4) K[0][1]= KG[3][2];//DOF(4) K[1][0]= KG[2][3];//DOF(3) K[1][1]= KG[2][2]+krk01;//DOF(3) // for (i=0;i<2;i++){ // for (j=0;j<2;j++) // printf("t K[%d][%d]: %.4e ",i,j,K[i][j]); // printf("n"); // } // printf("n"); MatrixDetermination(K,2,Product); if (Product == 0) break; MatrixInverse(K,Kinv,2);// Inverse [Kinit]
  • 6. MatrixMulti01(Kinv,FF,u,2); zMAX = z + 1; ElementInternalForce(MS,u,lanX,lanY,eleF,0,2); // 2: step 2 // for (i=0;i<2;i++) // printf("t u[%d]: %f n",i,u[i]); // for (i=0;i<6;i++) // printf("t %f n",eleF[0][i]); ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,z); output_u01[z]=u[0];//output displacement DOF(4) output_u02[z]=u[1];//output rotation DOF(3) output_base01[z]=-ELE_FORCE[1][z];//output base shear DOF(1) output_base02[z]=-ELE_FORCE[2][z];//output base moment DOF(3) if (ABS(eleF[0][1]) >= SHE[0]){ printf("t Shear-1: %f reaached to yield: %f n",ABS(eleF[0][1]),SHE[0]); break; } // if (ABS(eleF[0][2]) >= MOM[0]){ // printf("t Moment-1: %f reaached to yield: %f n",ABS(eleF[0][2]),MOM[0]); // break; // } if (ABS(eleF[0][5]) >= MOM[0]){ printf("t Moment-2: %f reaached to yield: %f n",ABS(eleF[0][5]),MOM[0]); break; } if (ABS(u[1]) >= TET[np-1]){ printf("t Rotation-1: %f reaached to yield: %f n",ABS(u[1]),TET[np-1]); break; } if (ABS(u[2]) >= TET[np-1]){ printf("t Rotation-2: %f reaached to yield: %f n",ABS(u[2]),TET[np-1]); break; } }// for // So plastic hinge has formed in 1 node // STAGE 03 for (z=zMAX;z<M;z++){ PlasticHingeStiffness(eleF,0,2,MOM,Rk01,MomS01,krk01,np); // 2:Moment DOF(3) PlasticHingeStiffness(eleF,0,5,MOM,Rk02,MomS02,krk02,np); // 5:Moment DOF(6) //printf("ttt %.3e %.3e n",MomS01,krk01); FF[0]=Fini*(z+1); FF[1]=-MomS01; FF[2]=-MomS02; Matrix_Stiffness(Iner,Area,As,Elas,Ny,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); // 0: ele 1 - 1: stiffness matrix: 1 K[0][0]= KG[3][3];//DOF(4) K[0][1]= KG[3][2];//DOF(4) K[0][2]= KG[3][5];//DOF(4) K[1][0]= KG[2][3];//DOF(6) K[1][1]= KG[2][2]+krk01;//DOF(6) K[1][2]= KG[2][5];//DOF(6) K[2][0]= KG[5][3];//DOF(3) K[2][1]= KG[5][2];//DOF(3) K[2][2]= KG[5][5]+krk02;//DOF(3) // for (i=0;i<3;i++){ // for (j=0;j<3;j++) // printf("t K[%d][%d]: %f ",i,j,K[i][j]); // printf("n"); // } // MatrixDetermination(K,3,Product); // if (Product == 0) // break; MatrixInverse(K,Kinv,3);// Inverse [Kinit] MatrixMulti01(Kinv,FF,u,3); zMAX = z + 1; ElementInternalForce(MS,u,lanX,lanY,eleF,0,3);// 3: step 3 // for (i=0;i<3;i++) // printf("t u[%d]: %f n",i,u[i]); // for (i=0;i<6;i++) // printf("t %f n",eleF[0][i]); ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,z); output_u01[z]=u[0];//output displacement DOF(4) output_u02[z]=u[1];//output rotation DOF(3) output_u03[z]=u[2];//output rotation DOF(6) output_base01[z]=-ELE_FORCE[1][z];//output base shear DOF(1) output_base02[z]=-ELE_FORCE[2][z];//output base moment DOF(3) if (ABS(eleF[0][1]) >= SHE[0]){ printf("t Shear-1: %f reaached to yield: %f n",ABS(eleF[0][1]),SHE[0]); break; } // if (ABS(eleF[0][2]) >= MOM[0]){ // printf("t Moment-1: %f reaached to yield: %f n",ABS(eleF[0][2]),MOM[0]); // break; // } // if (ABS(eleF[0][5]) >= MOM[0]){ // printf("t Moment-2: %f reaached to yield: %f n",ABS(eleF[0][5]),MOM[0]); // break; // } if (ABS(u[1]) >= TET[np-1]){ printf("t Rotation-1: %f reaached to yield: %f n",ABS(u[1]),TET[np-1]); break; } if (ABS(u[2]) >= TET[np-1]){ printf("t Rotation-2: %f reaached to yield: %f n",ABS(u[2]),TET[np-1]); break; } }// for MessageResult(output_base01,output_base02,output_u01,output_u02,output_u03,zMAX); OUTPUT_excel(output_u01,output_u02,output_u03,output_base01,output_base02,ELE_FORCE,zMAX); OUTPUT_html(Iner,Area,As,Elas,Ny,Fini,x,y,TET,MOM,TEO,SHE,output_u01,output_u02,output_u03,output_base01,output_base02,ELE_FORCE,zMAX,np,M); char text1[30]="Base Shear-Displacement Graph",text2[30]="Displacement [DOF(5)]",text3[30]="Base Shear [DOF(1)]"; for (i=0;i<zMAX;i++){ X[i] = output_u01[i];// Disp. DOF(5) Y[i] = output_base01[i];// Base Shear DOF(1) } OUTPUT_HTML_GRAPH(X,Y,zMAX,text1,text2,text3); textcolor(15); printf("na - %s -n",ShowText04); system("start /w Graph-outputHTML.html"); DATE_TIME(); free(output_u01);free(output_u02);free(output_u03); free(output_base01);free(output_base02); free(X);free(Y); } void PlasticHingeStiffnessCOFF(double A[],double B[],double C[],int n){ int i; for (i=0;i<n-1;i++){ C[i]=(B[i+1]-B[i])/(A[i+1]-A[i]); //printf("%d - Rk[%d]: %fn",i,i,C[i]); } } void PlasticHingeStiffness(double A[1][6],int I,int II,double B[],double C[],double &MomS,double &KRK,int n){
  • 7. int i; for (i=0;i<n-1;i++){ if (ABS(A[I][II]) >= B[i] && ABS(A[I][II]) <= B[i+1]){ MomS = B[i];KRK = C[i];//printf("t %.3e %.3e %.3e n",B[i],MomS,KRK); } } if (ABS(A[I][II]) > B[n-1]){ MomS = 0;KRK = 0; } } void DATE_TIME(){ printf("nt"); system("echo %date%"); printf("t"); system("echo %time%"); } void Matrix_Stiffness(double Iner,double Area,double As,double Elas,double Ny,double L[],double lanX[],double lanY[],double A[],double B[],double C[],double D[],double E[],double K[][6],double K_G[][6],int I,int II){ double g,EI,EA,fi,lan[6][6],lan_Tr[6][6],ans[6][6]; g = Elas/(2*(1+Ny)); EI = Elas*Iner; EA = Elas*Area; fi = (12*EI)/(g*As*L[I]*L[I]);// Timoshenko beam coefficient A[I] = ((4+fi)*EI/L[I])*(1/(1+fi)); B[I] = (6*EI/(L[I]*L[I]))*(1/(1+fi)); C[I] = ((2-fi)*EI/L[I])*(1/(1+fi)); D[I] = (12*EI/(L[I]*L[I]*L[I]))*(1/(1+fi));//printf("tt %f n",D[I]); E[I] = EA/L[I]; for (int i=0;i<6;i++) for (int j=0;j<6;j++) K[i][j] = 0.0; //I:2 number of element - II: kind of stiffness matrix if (II==1){// No plastic hinge K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0; K[1][0]=0;K[1][1]=D[I];K[1][2]=B[I];K[1][3]=0;K[1][4]=-D[I];K[1][5]=B[I]; K[2][0]=0;K[2][1]=B[I];K[2][2]=A[I];K[2][3]=0;K[2][4]=-B[I];K[2][5]=C[I]; K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0; K[4][0]=0;K[4][1]=-D[I];K[4][2]=-B[I];K[4][3]=0;K[4][4]=D[I];K[4][5]=-B[I]; K[5][0]=0;K[5][1]=B[I];K[5][2]=C[I];K[5][3]=0;K[5][4]=-B[I];K[5][5]=A[I]; } if (II==2){// plastic hinge at i K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0; K[1][0]=0;K[1][1]=.25*D[I];K[1][2]=0;K[1][3]=0;K[1][4]=-.25*D[I];K[1][5]=.5*B[I]; K[2][0]=0;K[2][1]=0;K[2][2]=0;K[2][3]=0;K[2][4]=0;K[2][5]=0; K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0; K[4][0]=0;K[4][1]=-.25*D[I];K[4][2]=0;K[4][3]=0;K[4][4]=.25*D[I];K[4][5]=-.5*B[I]; K[5][0]=0;K[5][1]=.5*B[I];K[5][2]=0;K[5][3]=0;K[5][4]=-.5*B[I];K[5][5]=(3/4)*A[I]; } if (II==3){// plastic hinge at j K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0; K[1][0]=0;K[1][1]=.25*D[I];K[1][2]=.5*B[I];K[1][3]=0;K[1][4]=-.25*D[I];K[1][5]=0; K[2][0]=0;K[2][1]=.5*B[I];K[2][2]=(3/4)*A[I];K[2][3]=0;K[2][4]=-.5*B[I];K[2][5]=0; K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0; K[4][0]=0;K[4][1]=-.25*D[I];K[4][2]=-.5*B[I];K[4][3]=0;K[4][4]=.25*D[I];K[4][5]=0; K[5][0]=0;K[5][1]=0;K[5][2]=0;K[5][3]=0;K[5][4]=0;K[5][5]=0; } if (II==4){// plastic hinge at i and j K[0][0]=E[I];K[0][1]=0;K[0][2]=0;K[0][3]=-E[I];K[0][4]=0;K[0][5]=0; K[1][0]=0;K[1][1]=0;K[1][2]=0;K[1][3]=0;K[1][4]=0;K[1][5]=0; K[2][0]=0;K[2][1]=0;K[2][2]=0;K[2][3]=0;K[2][4]=0;K[2][5]=0; K[3][0]=-E[I];K[3][1]=0;K[3][2]=0;K[3][3]=E[I];K[3][4]=0;K[3][5]=0; K[4][0]=0;K[4][1]=0;K[4][2]=0;K[4][3]=0;K[4][4]=0;K[4][5]=0; K[5][0]=0;K[5][1]=0;K[5][2]=0;K[5][3]=0;K[5][4]=0;K[5][5]=0; } lan[0][0]=lanX[I];lan[0][1]=lanY[I];lan[0][2]=0;lan[0][3]=0;lan[0][4]=0;lan[0][5]=0; lan[1][0]=-lanY[I];lan[1][1]=lanX[I];lan[1][2]=0;lan[1][3]=0;lan[1][4]=0;lan[1][5]=0; lan[2][0]=0;lan[2][1]=0;lan[2][2]=1;lan[2][3]=0;lan[2][4]=0;lan[2][5]=0; lan[3][0]=0;lan[3][1]=0;lan[3][2]=0;lan[3][3]=lanX[I];lan[3][4]=lanY[I];lan[3][5]=0; lan[4][0]=0;lan[4][1]=0;lan[4][2]=0;lan[4][3]=-lanY[I];lan[4][4]=lanX[I];lan[4][5]=0; lan[5][0]=0;lan[5][1]=0;lan[5][2]=0;lan[5][3]=0;lan[5][4]=0;lan[5][5]=1; Matrix_Transpose(lan,lan_Tr); Matrix_Multiplication(lan_Tr,K,ans); Matrix_Multiplication(ans,lan,K_G); } void ELEMNT_FORCE_OUTPUT(double eleF[1][6],double ELE_FORCE[6][STEP],int n){ int i; for (i=0;i<6;i++) ELE_FORCE[i][n]=eleF[0][i]; } double SQRT2(double D){ int it,itermax; double residual,tolerance,x,dx,dx_ABS,f,df; it = 0; // initialize iteration count itermax = 100000; residual = 100; // initialize residual tolerance = 1e-12; x = 1;// initialize answer while (residual > tolerance){ f = x*x - D; df = 2 * x; dx = f/df; x= x - dx; residual = ABS(dx); // abs residual it = it + 1; // increment iteration count //printf("f: %f -tdx: %f -tresidual: %fn",f,dx,residual); if (it == itermax){ //printf("tSQRT2(number,power) : SQRT2(%f) - iteration: %d -> ## The solution is not converged ##n",D,it); break; } } if (it < itermax){ //printf("tSQRT(number,power) - SQRT(%f,%f) : %f n",D,n, x); return x; } } void Matrix_Transpose(double A[6][6],double B[6][6]){ int i,j; for (i=0;i<6;i++) for (j=0;j<6;j++) B[j][i]=A[i][j]; } void Matrix_Multiplication(double A[6][6],double B[6][6],double C[6][6]){ int i,j,k; double sum; for (i=0;i<6;i++) for (j=0;j<6;j++){ sum=0; for (k=0;k<6;k++) sum += A[i][k]*B[k][j]; C[i][j] = sum; } } void MessageResult(double output_base01[],double output_base02[],double output_u01[],double output_u02[],double output_u03[],int n){ int i; printf("t "); for (i=0;i<120;i++) printf("-"); printf("n"); printf("t Increment Base Shear[DOF(1)] Base SMoment[DOF(3)] Disp. [DOF(5)] Rotation [DOF(3)] Rotation [DOF(6)]n"); printf("t "); for (i=0;i<120;i++) printf("-"); printf("n");
  • 8. for (i=0;i<n;i++){ //Distance(i+1); printf("tt %dt %.3et %.3et %.3et %.3et %.3en",i+1,output_base01[i],output_base01[i],output_u01[i],output_u02[i],output_u03[i]); } } void MessageStrCoorTEXT(double X[],double Y[],int n){ int i; char Qa,Qb,Qc,Qd,Qe,Qf; Qa=201;Qb=205;Qc=187;Qd=200;Qe=188;Qf=186; printf(" %c",Qa); for (i=1;i<33;i++) printf("%c",Qb); printf("%cn",Qc); printf(" %c Structural Coordinate Data %cn",Qf,Qf); printf(" %c X Y %cn",Qf,Qf); printf(" %c",Qd); for (i=1;i<33;i++) printf("%c",Qb); printf("%cn",Qe); for(i=0;i<n;i++) printf(" %.3e %.3en",X[i],Y[i]); } void MessagePlasticHingeTEXT(double TET[],double MOM[],double TEO[],double SHE[],int n){ int i; char Qa,Qb,Qc,Qd,Qe,Qf; int BB=201,CC=205,DD=187,EE=200,FF=188,GG=186; Qa=BB;Qb=CC;Qc=DD;Qd=EE;Qe=FF;Qf=GG; printf(" %c",Qa); for (i=1;i<67;i++) printf("%c",Qb); printf("%cn",Qc); printf(" %c Plastic Hinge Data %cn",Qf,Qf); printf(" %c Plastic Moment Hinge 01 | Plastic Shear Hinge 02 %cn",Qf,Qf); printf(" %c Rotation Moment | Shear Deformation Shear %cn",Qf,Qf); printf(" %c",Qd); for (i=1;i<67;i++) printf("%c",Qb); printf("%cn",Qe); for(i=0;i<n;i++) printf(" %.3e %.3e %.3e %.3en",TET[i],MOM[i],TEO[i],SHE[i]); } void OUTPUT_html(double Iner,double Area,double As,double Elas,double Ny,double Fini,double X[],double Y[],double TET[],double MOM[],double TEO[],double SHE[],double output_u01[],double output_u02[],double output_u03[],double output_base01[],double output_base02[],double C[6][STEP],int n,int m,int M){ // HTML OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText06, "w"); fprintf(OutputFile,"<html> <body bgcolor="green">n"); // IMPORT IMAGE fprintf(OutputFile,"<img src="PushoverForceAnalogyMethodTimoshenkoFC-image01.png" style="width:1000px ; height:500px" alt="analysis"><br><br>n"); // TOP TITLE oF HTML FILE fprintf(OutputFile,"<table style=”width:100%” border="2px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th bgcolor="cyan"> Pushover Analysis Force Analogy Method with Force Control Based on Timoshenko Beam Theory - Output Report </th> n"); // TABLE 1 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th colspan="2" bgcolor="orange"> Input Data </th> </tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange">Section moment inertia: </th><th> %.3e </th> </tr>n",Iner); fprintf(OutputFile,"<tr> <th bgcolor="orange">Section area: </th><th> %.3e </th> </tr>n",Area); fprintf(OutputFile,"<tr> <th bgcolor="orange">Section shear area: </th><th> %.3e </th> </tr>n",As); fprintf(OutputFile,"<tr> <th bgcolor="orange">Section elasticity modulus: </th><th> %.3e </th> </tr>n",Elas); fprintf(OutputFile,"<tr> <th bgcolor="orange">Section poisson ratio: </th><th> %.3e </th> </tr>n",Ny); fprintf(OutputFile,"<tr> <th bgcolor="orange">External Incremental Fx force [DOF(4)]: </th><th> %.3e </th> </tr>n",Fini); fprintf(OutputFile,"<tr> <th bgcolor="orange">Number of increment: </th><th> %d </th> </tr>n",M); // TABLE 2 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<th colspan="4" bgcolor="orange"> Hinges Data </th>n"); fprintf(OutputFile,"<tr> <th colspan="2" bgcolor="orange">Hinge[1]: Moment - Rotation </th> <th colspan="2" bgcolor="orange">Hinge[2]: Shear - Shear Deformation </th></tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange"> Rotation </th> <th bgcolor="orange"> Moment </th><th bgcolor="orange"> Shear Deformation </th> <th bgcolor="orange"> Shear</th> </tr>n"); for(i=0;i<m;i++){ fprintf(OutputFile,"<tr> <td align ="center"> %.3e </td> <td align ="center"> %.3e </td><td align ="center"> %.3e </td><td align ="center"> %.3e </td> </tr>n",TET[i],MOM[i],TEO[i],SHE[i]); } // TABLE 3 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th colspan="3" bgcolor="orange"> Structral Coordinate </th> </tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange">Node Number </th><th bgcolor="orange">X Coordinate</th> <th bgcolor="orange">Y Coordinate</th> </tr>n"); for(i=0;i<Ne+1;i++){ fprintf(OutputFile,"<tr> <td align ="center"> %d </td><td align ="center"> %.3e </td> <td align ="center"> %.3e </td>n",i+1,X[i],Y[i]); } // TABLE 4 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th colspan="6" bgcolor="orange"> Structral Deformation </th> </tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange">Increment</th> <th bgcolor="orange">Base Shear [DOF(1)]</th><th bgcolor="orange">Base Moment [DOF(3)]</th><th bgcolor="orange">Displacement [DOF(5)]</th> <th bgcolor="orange">Rotation [DOF(3)]</th><th bgcolor="orange">Rotation [DOF(6)]</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> <td align ="center"> %.3e </td><td align ="center"> %.3e </td></tr>n",i+1,output_base01[i],output_base02[i],output_u01[i],output_u02[i],output_u03[i]); } // TABLE 5 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th colspan="7" bgcolor="orange"> Structral Element Internal Forces </th> </tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange">Increment</th> <th bgcolor="orange">Axial-i</th> <th bgcolor="orange">Shear-i</th> <th bgcolor="orange">Moment-i</th> <th bgcolor="orange">Axial-j</th> <th bgcolor="orange">Shear-j</th> <th bgcolor="orange">Moment-j</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><td align ="center"> %.3e </td><td align ="center"> %.3e </td><td align ="center"> %.3e </td> </tr>n",i+1,C[0][i],C[1][i],C[2][i],C[3][i],C[4][i],C[5][i]); } fprintf(OutputFile,"</table></body></html>n"); fclose(OutputFile); } 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,Xmax,Ymax; double *Xnew = new double [STEP]; double *Ynew = new double [STEP]; double *NorX = new double [STEP]; double *NorY = new double [STEP]; Xmax=MAX_ABS(X,n); Ymax=MAX_ABS(Y,n); Xnew[0]=0;Ynew[0]=0; for (i=0;i<n;i++){ Xnew[i+1] = ABS(X[i]); Ynew[i+1] = ABS(Y[i]); } for (i=0;i<n+1;i++){ NorX[i] = Xnew[i]/Xmax; NorY[i] = Ynew[i]/Ymax; //printf("t %f %f n",NorX[i],NorY[i]); } FILE *OutputFile; OutputFile = fopen(ShowText07, "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;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");
  • 9. 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); free(Xnew);free(Ynew);free(NorX);free(NorY); } double MAX_ABS(double A[],int n){ int i; double B[STEP]; 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; }
  • 12. Figure(3) Input coordinate of structure csv file
  • 13. Figure(4) Input plastic hinge (Moment-Rotation & Shear-Shear Deformation) csv file
  • 14. Figure(5) Output report in csv file
  • 15. Figure(6) Output report in html file