SlideShare a Scribd company logo
1 of 19
Download to read offline
>> IN THE NAME OF GOD << 
Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method in C programming 
 
C program is written by Salar Delavar Ghashghaei – Publication Date: 01/July/2018 
E‐mail: salar.d.ghashghaei@gmail.com 
C Code:
#include <stdio.h>
#include <windows.h> // text color
#include <conio.h>
#define NN 3 // Degree of freedom
#define Ne 2 // number of element
void IMPORT_DATA01(double &Length,double &EA,double &EI,double &Ultimate_Mom);
void Matrix_Stiffness(double EA,double EI,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 [][NN],int );
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);// Calculate internal element force
void ELEMNT_FORCE_OUTPUT(double eleF[2][6],double ELE_FORCE[3][12],double SUM_ELE_FORCE[12],double u[],double sum_u[], int I);
double ABS(double);
double MIN(double A[],int n);
double SQRT2(double D);
void MessageInitialData(double L,double EI,double EA,double Ultimate_Moment);
void MessageAnalysisReport();
void MessageErrorReportTEXT();
void MessageInputDataTEXT();
void MessageCheck_IMPORT_DATA01(double Length,double EA,double EI,double Ultimate_Mom);
void MessageResult(double A[],double B[3][3],int n);
void OUTPUT_excel(double A[3][3],double B[3],double C[3][12],int n);
void OUTPUT_matlab(double A[3][3],double B[3],double C[3][12],int n);
void ANALYSIS(double Length,double EI,double EA,double Ultimate_Moment);
void Distance(int);
void textcolor(int ForgC);
void DATE_TIME();
int main(){
double Length,EI,EA,Ultimate_Moment;
IMPORT_DATA01(Length,EA,EI,Ultimate_Moment);
MessageCheck_IMPORT_DATA01(Length,EI,EA,Ultimate_Moment);
textcolor(14);
MessageInitialData(Length,EI,EA,Ultimate_Moment);
textcolor(11);
MessageAnalysisReport();
ANALYSIS(Length,EI,EA,Ultimate_Moment);
getch();
return 0;
}
void MatrixInverse(double A[][NN], double C[][NN],int n){
int i,j,l;
double c_A[NN][NN],B[NN][NN],m,Sum;
for (i=0;i<NN;i++)
for (j=0;j<NN;j++)
c_A[i][j]=A[i][j];
// Inverse [Kinit]
for (i=0;i<NN;i++)
for (j=0;j<NN;j++){
if (i==j)
B[i][j]=1;
else
B[i][j]=0;
}
for (j=0;j<NN-1;j++)
for (i=j+1;i<NN;i++){
m=c_A[i][j]/c_A[j][j];
for (l=0;l<NN;l++){
c_A[i][l] -= m*c_A[j][l];
B[i][l] -= m*B[j][l];
}
}
// backward substitutions
for (i=NN-1;i>=0;i--)
for (j=0;j<NN;j++){
Sum=0;
for (l=i+1;l<NN;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){
double lan[6][6],UU[6],ff,ll[6][6];
int II;
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 (I == 0){
UU[0]=0;UU[1]=0;UU[2]=0;UU[3]=U[0];UU[4]=U[1];UU[5]=U[2];
}
if (I == 1){
UU[0]=U[0];UU[1]=U[1];UU[2]=U[2];UU[3]=0;UU[4]=0;UU[5]=0;
}
int i,j;
// [f] = [K] * [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 L,double EI,double EA,double Ultimate_Moment){
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<72;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf("tttt%c >> IN THE NAME OF GOD << %cn",Qf,Qf);
printf("tttt%c Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method %cn",Qf,Qf);
printf("tttt%c UNIT: Free Unit %cn",Qf,Qf);
printf("tttt%c",Qg);
for (i=1;i<72;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<72;i++)
printf("%c",Qb);
printf("%cn",Qe);
MessageInputDataTEXT();
printf(" Length : %.3en",L);
printf(" Section flextural rigidity - EI: %.3en",EI);
printf(" Section axial rigidity - EA: %.3en",EA);
printf(" Section ultimate capacity moment: %.3en",Ultimate_Moment);
}
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 L,double EI,double EA,double Ultimate_Moment){
if ( L < 0 || EI < 0 || EA < 0 || Ultimate_Moment < 0){
MessageErrorReportTEXT();
printf(" Please check this file! -> [ PushoverHingeByHingeMethodFixedSupportBeam-inputDATA.csv ]n");
printf(" *** Negative data input value is not acceptable ***n");
printf(" Length of element: %.3en",L);
printf(" Section flextural rigidity - EI: %.3en",EI);
printf(" Section axial rigidity - EA: %.3en",EA);
printf(" Section ultimate capacity moment: %.3en",Ultimate_Moment);
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_txt(){
}
void OUTPUT_matlab(double A[3][3],double B[3],double C[3][12],int n){
// MATLAB OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen("PushoverHingeByHingeMethodFixedSupportBeam-outputMATLAB.m", "w");
fprintf(OutputFile," %% Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method %%n");
fprintf(OutputFile,"disp_Dof5=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",A[i][1]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"disp_Dof6=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",A[i][2]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"ele_Dof3=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",C[i][2]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"ele_Dof5=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",C[i][4]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"ele_Dof6=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",C[i][5]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"ele_Dof12=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",C[i][11]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"base_shear=[0n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%en",B[i]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"figure(1)n");
fprintf(OutputFile,"plot(disp_Dof6,ele_Dof6,'LineWidth',3);n");
fprintf(OutputFile,"title(['## ELEMENT INTERAL MOMENT - ROTATION DIAGRAM #'],'Color','b');n");
fprintf(OutputFile,"xlabel('ROTATION [DOF(6)]');ylabel('ELEMENT INTERAL MOMENT [DOF(6)]');grid on;n");
fprintf(OutputFile,"figure(2)n");
fprintf(OutputFile,"plot(disp_Dof6,ele_Dof12,'LineWidth',3);n");
fprintf(OutputFile,"title(['## ELEMENT INTERAL MOMENT - ROTATION DIAGRAM #'],'Color','b');n");
fprintf(OutputFile,"xlabel('ROTATION [DOF(6)]');ylabel('ELEMENT INTERAL MOMENT [DOF(12)]');grid on;n");
fprintf(OutputFile,"figure(3)n");
fprintf(OutputFile,"plot(disp_Dof5,ele_Dof5,'LineWidth',3);n");
fprintf(OutputFile,"title(['# ELEMENT INTERAL SHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n");
fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(11)]');ylabel('ELEMENT INTERAL SHEAR [DOF(2)]');grid on;n");
fprintf(OutputFile,"figure(4)n");
fprintf(OutputFile,"plot(disp_Dof5,base_shear,'LineWidth',3);n");
fprintf(OutputFile,"title(['## BASE SHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n");
fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(5)]');ylabel('BASE SHEAR [DOF(2)]+[DOF(8)]');grid on;n");
}
void OUTPUT_excel(double A[3][3],double B[3],double C[3][12],int n){
// EXCEL OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen("PushoverHingeByHingeMethodFixedSupportBeam-outputEXCEL.csv", "w");
fprintf(OutputFile," ### Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method ###n");
fprintf(OutputFile,"Increment,Base Shear[DOF(2)]+[DOF(8)],Displacement [DOF(4)],Displacement [DOF(5)],Rotation [DOF(6)],Ele.1 Axial[DOF(1)],Ele.1 Shear[DOF(2)],Ele.1 Moment[DOF(3)],
Ele.1 Axial[DOF(4)],Ele.1 Shear[DOF(5)],Ele.1 Moment[DOF(6)],Ele.2 Axial[DOF(4)],Ele.2 Shear[DOF(5)],Ele.2 Moment[DOF(6)],Ele.2 Axial[DOF(7)],Ele.2 Shear[DOF(8)],Ele.2 Moment[DOF(9)]n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%d,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%en",i+1,B[i],A[i][0],A[i][1],A[i][2],C[i][0],C[i][1],C[i][2],C[i][3],C[i][4],C[i][5],C[i][6],C[i][7],C[i][8],C[i][9],
C[i][10],C[i][11]);
}
void MatrixDetermination(double A[][NN],int n){
// row operations
int i,j,k;
double Product,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 &Length,double &EA,double &EI,double &Ultimate_Mom){
double Import_Data[4];
int i=0;
FILE *InputFile;
InputFile = fopen("PushoverHingeByHingeMethodFixedSupportBeam-inputDATA.csv", "r");
if (!InputFile){
MessageErrorReportTEXT();
printf(" File is not available! -> [PushoverHingeByHingeMethodFixedSupportBeam-inputDATA.csv] n");
Sleep(6000);
exit(1);
}
char line[100],a[100];
while(i < 4 && fgets(line,sizeof(line),InputFile) != NULL){
sscanf(line,"%s",a);
//printf("a[%d]: %sn",i,a);
Import_Data[i]= atof(a);
i++;
}
Length=Import_Data[0];
EI=Import_Data[1];
EA=Import_Data[2];
Ultimate_Mom=Import_Data[3];
}
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 Length,double EI,double EA,double Ultimate_Moment){
int i;
double K[NN][NN],Kinv[NN][NN],eleF[2][6],ELE_FORCE[3][12],SUM_ELE_FORCE[12];
double L[Ne],lanX[Ne],lanY[Ne],AA[Ne],BB[Ne],CC[Ne],DD[Ne],EE[Ne],f[NN],F[NN],u[3],sum_u[3],Mi[4];
double output_u[3][3],output_base[3];
double MS[6][6],KG[6][6],LANNDA[4],LANNDA_min;
double x[3],y[3];
for (i=0;i<NN;i++){
F[i]=0;f[i] = 0;u[i] = 0;sum_u[i] = 0;
}
for(int j=0;j<3;j++){
for(i=0;i<6*Ne;i++)
ELE_FORCE[j][i] = 0;
}
for(i=0;i<6*Ne;i++)
SUM_ELE_FORCE[i] = 0;
for (i=0;i<4;i++)
Mi[i] = 0;
// SATAGE: 01
F[1]=-1;
x[0] = 0;y[0]=0;
x[1] = Length;y[1]=0+sum_u[1];
x[2] = 3*Length;y[2]=0;
L[0] = SQRT2((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
L[1] = SQRT2((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1]));
lanX[0]=(x[1]-x[0])/L[0];lanY[0]=(y[1]-y[0])/L[0];
lanX[1]=(x[2]-x[1])/L[1];lanY[1]=(y[2]-y[1])/L[1];
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1);
K[0][0]= KG[3][3];//DOF(4)
K[0][1]= KG[3][4];//DOF(4)
K[0][2]= KG[3][5];//DOF(4)
K[1][0]= KG[4][3];//DOF(5)
K[1][1]= KG[4][4];//DOF(5)
K[1][2]= KG[4][5];//DOF(5)
K[2][0]= KG[5][3];//DOF(6)
K[2][1]= KG[5][4];//DOF(6)
K[2][2]= KG[5][5];//DOF(6)
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1);
K[0][0]+= KG[0][0];//DOF(4)
K[0][1]+= KG[0][1];//DOF(4)
K[0][2]+= KG[0][2];//DOF(4)
K[1][0]+= KG[1][0];//DOF(5)
K[1][1]+= KG[1][1];//DOF(5)
K[1][2]+= KG[1][2];//DOF(5)
K[2][0]+= KG[2][0];//DOF(6)
K[2][1]+= KG[2][1];//DOF(6)
K[2][2]+= KG[2][2];//DOF(6)
MatrixDetermination(K,NN);
MatrixInverse(K,Kinv,NN);// Inverse [Kinit]
MatrixMulti01(Kinv,F,u,NN);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1);
ElementInternalForce(MS,u,lanX,lanY,eleF,0);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1);
ElementInternalForce(MS,u,lanX,lanY,eleF,1);
LANNDA[0]=(Ultimate_Moment-ABS(Mi[0]))/ABS(eleF[0][2]);
LANNDA[1]=(Ultimate_Moment-ABS(Mi[1]))/ABS(eleF[0][5]);
LANNDA[2]=(Ultimate_Moment-ABS(Mi[2]))/ABS(eleF[1][2]);
LANNDA[3]=(Ultimate_Moment-ABS(Mi[3]))/ABS(eleF[1][5]);
LANNDA_min = MIN(LANNDA,4);
for (i=0;i<NN;i++)
u[i]=LANNDA_min*u[i];
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1);
ElementInternalForce(MS,u,lanX,lanY,eleF,0);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1);
ElementInternalForce(MS,u,lanX,lanY,eleF,1);
Mi[0]=eleF[0][2];
Mi[1]=eleF[0][5];
Mi[2]=eleF[1][2];
Mi[3]=eleF[1][5];
ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,SUM_ELE_FORCE,u,sum_u,0);
for (i=0;i<NN;i++)
output_u[0][i]=sum_u[i];//output displacement
output_base[0]=-SUM_ELE_FORCE[1]-SUM_ELE_FORCE[10];//output base shear
// So plastic hinge has formed in node 1
// SATAGE: 02
x[0] = 0;y[0]=0;
x[1] = Length;y[1]=0+sum_u[1];
x[2] = 3*Length;y[2]=0;
L[0] = SQRT2((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
L[1] = SQRT2((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1]));
lanX[0]=(x[1]-x[0])/L[0];lanY[0]=(y[1]-y[0])/L[0];
lanX[1]=(x[2]-x[1])/L[1];lanY[1]=(y[2]-y[1])/L[1];
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,2);
K[0][0]= KG[3][3];//DOF(4)
K[0][1]= KG[3][4];//DOF(4)
K[0][2]= KG[3][5];//DOF(4)
K[1][0]= KG[4][3];//DOF(5)
K[1][1]= KG[4][4];//DOF(5)
K[1][2]= KG[4][5];//DOF(5)
K[2][0]= KG[5][3];//DOF(6)
K[2][1]= KG[5][4];//DOF(6)
K[2][2]= KG[5][5];//DOF(6)
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1);
K[0][0]+= KG[0][0];//DOF(4)
K[0][1]+= KG[0][1];//DOF(4)
K[0][2]+= KG[0][2];//DOF(4)
K[1][0]+= KG[1][0];//DOF(5)
K[1][1]+= KG[1][1];//DOF(5)
K[1][2]+= KG[1][2];//DOF(5)
K[2][0]+= KG[2][0];//DOF(6)
K[2][1]+= KG[2][1];//DOF(6)
K[2][2]+= KG[2][2];//DOF(6)
MatrixDetermination(K,3);
MatrixInverse(K,Kinv,NN);// Inverse [Kinit]
MatrixMulti01(Kinv,F,u,NN);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,2);
ElementInternalForce(MS,u,lanX,lanY,eleF,0);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1);
ElementInternalForce(MS,u,lanX,lanY,eleF,1);
LANNDA[0]=(Ultimate_Moment-ABS(Mi[0]))/ABS(eleF[0][2]);
LANNDA[1]=(Ultimate_Moment-ABS(Mi[1]))/ABS(eleF[0][5]);
LANNDA[2]=(Ultimate_Moment-ABS(Mi[2]))/ABS(eleF[1][2]);
LANNDA[3]=(Ultimate_Moment-ABS(Mi[3]))/ABS(eleF[1][5]);
LANNDA_min = MIN(LANNDA,4);
for (i=0;i<NN;i++)
u[i]=LANNDA_min*u[i];
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,2);
ElementInternalForce(MS,u,lanX,lanY,eleF,0);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1);
ElementInternalForce(MS,u,lanX,lanY,eleF,1);
Mi[0]=eleF[0][2];
Mi[1]=eleF[0][5];
Mi[2]=eleF[1][2];
Mi[3]=eleF[1][5];
ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,SUM_ELE_FORCE,u,sum_u,1);
for (i=0;i<NN;i++)
output_u[1][i]=sum_u[i];//output displacement
output_base[1]=-SUM_ELE_FORCE[1]-SUM_ELE_FORCE[10];//output base shear
// So plastic hinge has formed in node 2
// SATAGE: 03
x[0] = 0;y[0]=0;
x[1] = Length;y[1]=0+sum_u[1];
x[2] = 3*Length;y[2]=0;
L[0] = SQRT2((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
L[1] = SQRT2((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1]));
lanX[0]=(x[1]-x[0])/L[0];lanY[0]=(y[1]-y[0])/L[0];
lanX[1]=(x[2]-x[1])/L[1];lanY[1]=(y[2]-y[1])/L[1];
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,4);
K[0][0]= KG[3][3];//DOF(4)
K[0][1]= KG[3][4];//DOF(4)
K[0][2]= KG[3][5];//DOF(4)
K[1][0]= KG[4][3];//DOF(5)
K[1][1]= KG[4][4];//DOF(5)
K[1][2]= KG[4][5];//DOF(5)
K[2][0]= KG[5][3];//DOF(6)
K[2][1]= KG[5][4];//DOF(6)
K[2][2]= KG[5][5];//DOF(6)
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,2);
K[0][0]+= KG[0][0];//DOF(4)
K[0][1]+= KG[0][1];//DOF(4)
K[0][2]+= KG[0][2];//DOF(4)
K[1][0]+= KG[1][0];//DOF(5)
K[1][1]+= KG[1][1];//DOF(5)
K[1][2]+= KG[1][2];//DOF(5)
K[2][0]+= KG[2][0];//DOF(6)
K[2][1]+= KG[2][1];//DOF(6)
K[2][2]+= KG[2][2];//DOF(6)
MatrixInverse(K,Kinv,NN-1);// Inverse [Kinit]
MatrixMulti01(Kinv,F,u,NN-1);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,4);
ElementInternalForce(MS,u,lanX,lanY,eleF,0);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,2);
ElementInternalForce(MS,u,lanX,lanY,eleF,1);
LANNDA[0]=(Ultimate_Moment-ABS(Mi[0]))/ABS(eleF[0][2]);
LANNDA[1]=(Ultimate_Moment-ABS(Mi[1]))/ABS(eleF[0][5]);
LANNDA[2]=(Ultimate_Moment-ABS(Mi[2]))/ABS(eleF[1][2]);
LANNDA[3]=(Ultimate_Moment-ABS(Mi[3]))/ABS(eleF[1][5]);
LANNDA_min = MIN(LANNDA,4);
for (i=0;i<NN;i++)
u[i]=LANNDA_min*u[i];
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,4);
ElementInternalForce(MS,u,lanX,lanY,eleF,0);
Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,2);
ElementInternalForce(MS,u,lanX,lanY,eleF,1);
Mi[0]=eleF[0][2];
Mi[1]=eleF[0][5];
Mi[2]=eleF[1][2];
Mi[3]=eleF[1][5];
ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,SUM_ELE_FORCE,u,sum_u,2);
for (i=0;i<3;i++)
output_u[2][i]=sum_u[i];//output displacement
output_base[2]=-SUM_ELE_FORCE[1]-SUM_ELE_FORCE[10];//output base shear
MessageResult(output_base,output_u,3);
//MatrixDetermination(K,3);
OUTPUT_excel(output_u,output_base,ELE_FORCE,2);
OUTPUT_matlab(output_u,output_base,ELE_FORCE,2);
textcolor(15);
printf("na - Output data is written in Excel and Matlab file -n");
DATE_TIME();
}
void DATE_TIME(){
printf("nt");
system("echo %date%");
printf("t");
system("echo %time%");
}
void Matrix_Stiffness(double EA,double EI,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 lan[6][6],lan_Tr[6][6],ans[6][6];
A[I] = 4*EI/L[I];
B[I] = 6*EI/(L[I]*L[I]);
C[I] = 2*EI/L[I];
D[I] = 12*EI/(L[I]*L[I]*L[I]);
E[I] = EA/L[I];
for (int i=0;i<6;i++)
for (int j=0;j<6;j++)
K[i][j] = 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[2][6],double ELE_FORCE[3][12],double SUM_ELE_FORCE[12],double u[],double sum_u[], int I){
int i;
for (i=0;i<6;i++)
ELE_FORCE[I][i]=eleF[0][i];
for (i=6;i<12;i++)
ELE_FORCE[I][i]=eleF[1][i-6];
for (i=0;i<6*Ne;i++)
SUM_ELE_FORCE[i] += ELE_FORCE[I][i];
for (i=0;i<NN;i++)
sum_u[i] += u[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-8;
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 A[],double B[3][3],int n){
int i;
printf("t ");
for (i=0;i<123;i++)
printf("-");
printf("n");
printf("t Increment Base Shear[DOF(2)]+[DOF(8)] Displacement [DOF(4)] Displacement [DOF(5)] Displacement [DOF(6)] n");
printf("t ");
for (i=0;i<123;i++)
printf("-");
printf("n");
for (i=0;i<n;i++)
printf("tt %dtt %.3ett %.3ett %.3ett %.3en",i+1,A[i],B[i][0],B[i][1],B[i][2]);
}
Plot : 
 
Figure(1) Analysis file  
 
Figure(2) Input csv file 
 
Figure(3) Output csv file 
 
Figure(4) Output matlab file 
 
Figure(5) Stiffness matrix and change of plastic hinges in beam during analysis 

More Related Content

What's hot

COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALVivek Kumar Sinha
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manualAnkit Kumar
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsVishvjeet Yadav
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Aman Deep
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical FileAshwin Francis
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
C tech questions
C tech questionsC tech questions
C tech questionsvijay00791
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILEAnushka Rai
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical fileSai Sathvick Chirakala
 
Computer graphics
Computer graphics Computer graphics
Computer graphics shafiq sangi
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTsKevlin Henney
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribdAmit Kapoor
 

What's hot (20)

COMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUALCOMPUTER GRAPHICS LAB MANUAL
COMPUTER GRAPHICS LAB MANUAL
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output) Practical Class 12th (c++programs+sql queries and output)
Practical Class 12th (c++programs+sql queries and output)
 
12th CBSE Practical File
12th CBSE Practical File12th CBSE Practical File
12th CBSE Practical File
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Arrays
ArraysArrays
Arrays
 
Introduction to graphics programming in c
Introduction to graphics programming in cIntroduction to graphics programming in c
Introduction to graphics programming in c
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
C tech questions
C tech questionsC tech questions
C tech questions
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
Computer graphics
Computer graphics Computer graphics
Computer graphics
 
Cs practical file
Cs practical fileCs practical file
Cs practical file
 
Programming with GUTs
Programming with GUTsProgramming with GUTs
Programming with GUTs
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
 

Similar to Nonlinear analysis of fixed support beam with hinge by hinge method in c programming

Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...
Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...
Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...Salar Delavar Qashqai
 
Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...Salar Delavar Qashqai
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Pushover analysis force analogy method with force control based on euler bern...
Pushover analysis force analogy method with force control based on euler bern...Pushover analysis force analogy method with force control based on euler bern...
Pushover analysis force analogy method with force control based on euler bern...Salar Delavar Qashqai
 
Unit 3 arrays and_string
Unit 3 arrays and_stringUnit 3 arrays and_string
Unit 3 arrays and_stringkirthika jeyenth
 
Array matrix example programs - C language
Array matrix example programs - C languageArray matrix example programs - C language
Array matrix example programs - C languageSk_Group
 
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
 
Slide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdfSlide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdfHimanshuKansal22
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab PracticeMahmud Hasan Tanvir
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignmentJunaid Ahmed
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSKavyaSharma65
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointersvinay arora
 
SaraPIC
SaraPICSaraPIC
SaraPICSara Sahu
 
C Programming lab
C Programming labC Programming lab
C Programming labVikram Nandini
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2Koshy Geoji
 

Similar to Nonlinear analysis of fixed support beam with hinge by hinge method in c programming (20)

Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...
Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...
Nonlinear 2nd order analysis of 2 d fixed support beam with plastic hinge con...
 
Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...Pushover analysis force analogy method with force control based on timoshenko...
Pushover analysis force analogy method with force control based on timoshenko...
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Pushover analysis force analogy method with force control based on euler bern...
Pushover analysis force analogy method with force control based on euler bern...Pushover analysis force analogy method with force control based on euler bern...
Pushover analysis force analogy method with force control based on euler bern...
 
Unit 3 arrays and_string
Unit 3 arrays and_stringUnit 3 arrays and_string
Unit 3 arrays and_string
 
week-5x
week-5xweek-5x
week-5x
 
Array matrix example programs - C language
Array matrix example programs - C languageArray matrix example programs - C language
Array matrix example programs - C language
 
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
 
Slide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdfSlide set 6 Strings and pointers.pdf
Slide set 6 Strings and pointers.pdf
 
Basic C Programming Lab Practice
Basic C Programming Lab PracticeBasic C Programming Lab Practice
Basic C Programming Lab Practice
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
 
LET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERSLET US C (5th EDITION) CHAPTER 2 ANSWERS
LET US C (5th EDITION) CHAPTER 2 ANSWERS
 
C Prog - Pointers
C Prog - PointersC Prog - Pointers
C Prog - Pointers
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
week-3x
week-3xweek-3x
week-3x
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 

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
 
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
 

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...
 
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 ...
 

Recently uploaded

Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiessarkmank1
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsArindam Chakraborty, Ph.D., P.E. (CA, TX)
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
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
 
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
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
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
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
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
 

Recently uploaded (20)

Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
PE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and propertiesPE 459 LECTURE 2- natural gas basic concepts and properties
PE 459 LECTURE 2- natural gas basic concepts and properties
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
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
 
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
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
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
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
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
 

Nonlinear analysis of fixed support beam with hinge by hinge method in c programming

  • 1. >> IN THE NAME OF GOD <<  Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method in C programming    C program is written by Salar Delavar Ghashghaei – Publication Date: 01/July/2018  E‐mail: salar.d.ghashghaei@gmail.com  C Code: #include <stdio.h> #include <windows.h> // text color #include <conio.h> #define NN 3 // Degree of freedom #define Ne 2 // number of element void IMPORT_DATA01(double &Length,double &EA,double &EI,double &Ultimate_Mom); void Matrix_Stiffness(double EA,double EI,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 [][NN],int ); 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);// Calculate internal element force void ELEMNT_FORCE_OUTPUT(double eleF[2][6],double ELE_FORCE[3][12],double SUM_ELE_FORCE[12],double u[],double sum_u[], int I); double ABS(double); double MIN(double A[],int n); double SQRT2(double D); void MessageInitialData(double L,double EI,double EA,double Ultimate_Moment); void MessageAnalysisReport(); void MessageErrorReportTEXT(); void MessageInputDataTEXT(); void MessageCheck_IMPORT_DATA01(double Length,double EA,double EI,double Ultimate_Mom); void MessageResult(double A[],double B[3][3],int n);
  • 2. void OUTPUT_excel(double A[3][3],double B[3],double C[3][12],int n); void OUTPUT_matlab(double A[3][3],double B[3],double C[3][12],int n); void ANALYSIS(double Length,double EI,double EA,double Ultimate_Moment); void Distance(int); void textcolor(int ForgC); void DATE_TIME(); int main(){ double Length,EI,EA,Ultimate_Moment; IMPORT_DATA01(Length,EA,EI,Ultimate_Moment); MessageCheck_IMPORT_DATA01(Length,EI,EA,Ultimate_Moment); textcolor(14); MessageInitialData(Length,EI,EA,Ultimate_Moment); textcolor(11); MessageAnalysisReport(); ANALYSIS(Length,EI,EA,Ultimate_Moment); getch(); return 0; } void MatrixInverse(double A[][NN], double C[][NN],int n){ int i,j,l; double c_A[NN][NN],B[NN][NN],m,Sum; for (i=0;i<NN;i++) for (j=0;j<NN;j++) c_A[i][j]=A[i][j]; // Inverse [Kinit] for (i=0;i<NN;i++) for (j=0;j<NN;j++){ if (i==j) B[i][j]=1; else B[i][j]=0; } for (j=0;j<NN-1;j++) for (i=j+1;i<NN;i++){ m=c_A[i][j]/c_A[j][j]; for (l=0;l<NN;l++){ c_A[i][l] -= m*c_A[j][l]; B[i][l] -= m*B[j][l]; } } // backward substitutions for (i=NN-1;i>=0;i--) for (j=0;j<NN;j++){ Sum=0; for (l=i+1;l<NN;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){ double lan[6][6],UU[6],ff,ll[6][6]; int II; 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;
  • 3. 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 (I == 0){ UU[0]=0;UU[1]=0;UU[2]=0;UU[3]=U[0];UU[4]=U[1];UU[5]=U[2]; } if (I == 1){ UU[0]=U[0];UU[1]=U[1];UU[2]=U[2];UU[3]=0;UU[4]=0;UU[5]=0; } int i,j; // [f] = [K] * [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)
  • 4. 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 L,double EI,double EA,double Ultimate_Moment){ 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<72;i++) printf("%c",Qb); printf("%cn",Qc); printf("tttt%c >> IN THE NAME OF GOD << %cn",Qf,Qf); printf("tttt%c Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method %cn",Qf,Qf); printf("tttt%c UNIT: Free Unit %cn",Qf,Qf); printf("tttt%c",Qg); for (i=1;i<72;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<72;i++) printf("%c",Qb); printf("%cn",Qe); MessageInputDataTEXT(); printf(" Length : %.3en",L); printf(" Section flextural rigidity - EI: %.3en",EI); printf(" Section axial rigidity - EA: %.3en",EA); printf(" Section ultimate capacity moment: %.3en",Ultimate_Moment); } 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 L,double EI,double EA,double Ultimate_Moment){ if ( L < 0 || EI < 0 || EA < 0 || Ultimate_Moment < 0){ MessageErrorReportTEXT(); printf(" Please check this file! -> [ PushoverHingeByHingeMethodFixedSupportBeam-inputDATA.csv ]n");
  • 5. printf(" *** Negative data input value is not acceptable ***n"); printf(" Length of element: %.3en",L); printf(" Section flextural rigidity - EI: %.3en",EI); printf(" Section axial rigidity - EA: %.3en",EA); printf(" Section ultimate capacity moment: %.3en",Ultimate_Moment); 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_txt(){ } void OUTPUT_matlab(double A[3][3],double B[3],double C[3][12],int n){ // MATLAB OUTPUT int i; FILE *OutputFile; OutputFile = fopen("PushoverHingeByHingeMethodFixedSupportBeam-outputMATLAB.m", "w"); fprintf(OutputFile," %% Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method %%n"); fprintf(OutputFile,"disp_Dof5=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",A[i][1]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"disp_Dof6=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",A[i][2]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"ele_Dof3=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",C[i][2]); fprintf(OutputFile,"];nn");
  • 6. fprintf(OutputFile,"ele_Dof5=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",C[i][4]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"ele_Dof6=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",C[i][5]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"ele_Dof12=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",C[i][11]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"base_shear=[0n"); for(i=0;i<n;i++) fprintf(OutputFile,"%en",B[i]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"figure(1)n"); fprintf(OutputFile,"plot(disp_Dof6,ele_Dof6,'LineWidth',3);n"); fprintf(OutputFile,"title(['## ELEMENT INTERAL MOMENT - ROTATION DIAGRAM #'],'Color','b');n"); fprintf(OutputFile,"xlabel('ROTATION [DOF(6)]');ylabel('ELEMENT INTERAL MOMENT [DOF(6)]');grid on;n"); fprintf(OutputFile,"figure(2)n"); fprintf(OutputFile,"plot(disp_Dof6,ele_Dof12,'LineWidth',3);n"); fprintf(OutputFile,"title(['## ELEMENT INTERAL MOMENT - ROTATION DIAGRAM #'],'Color','b');n"); fprintf(OutputFile,"xlabel('ROTATION [DOF(6)]');ylabel('ELEMENT INTERAL MOMENT [DOF(12)]');grid on;n"); fprintf(OutputFile,"figure(3)n"); fprintf(OutputFile,"plot(disp_Dof5,ele_Dof5,'LineWidth',3);n"); fprintf(OutputFile,"title(['# ELEMENT INTERAL SHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n"); fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(11)]');ylabel('ELEMENT INTERAL SHEAR [DOF(2)]');grid on;n"); fprintf(OutputFile,"figure(4)n"); fprintf(OutputFile,"plot(disp_Dof5,base_shear,'LineWidth',3);n"); fprintf(OutputFile,"title(['## BASE SHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n"); fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(5)]');ylabel('BASE SHEAR [DOF(2)]+[DOF(8)]');grid on;n"); } void OUTPUT_excel(double A[3][3],double B[3],double C[3][12],int n){ // EXCEL OUTPUT int i; FILE *OutputFile; OutputFile = fopen("PushoverHingeByHingeMethodFixedSupportBeam-outputEXCEL.csv", "w"); fprintf(OutputFile," ### Nonlinear Analysis of Fixed Support Beam with Hinge by Hinge Method ###n"); fprintf(OutputFile,"Increment,Base Shear[DOF(2)]+[DOF(8)],Displacement [DOF(4)],Displacement [DOF(5)],Rotation [DOF(6)],Ele.1 Axial[DOF(1)],Ele.1 Shear[DOF(2)],Ele.1 Moment[DOF(3)], Ele.1 Axial[DOF(4)],Ele.1 Shear[DOF(5)],Ele.1 Moment[DOF(6)],Ele.2 Axial[DOF(4)],Ele.2 Shear[DOF(5)],Ele.2 Moment[DOF(6)],Ele.2 Axial[DOF(7)],Ele.2 Shear[DOF(8)],Ele.2 Moment[DOF(9)]n"); for(i=0;i<n;i++) fprintf(OutputFile,"%d,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%en",i+1,B[i],A[i][0],A[i][1],A[i][2],C[i][0],C[i][1],C[i][2],C[i][3],C[i][4],C[i][5],C[i][6],C[i][7],C[i][8],C[i][9], C[i][10],C[i][11]); } void MatrixDetermination(double A[][NN],int n){ // row operations int i,j,k; double Product,m,B[n][n];
  • 7. 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 &Length,double &EA,double &EI,double &Ultimate_Mom){ double Import_Data[4]; int i=0; FILE *InputFile; InputFile = fopen("PushoverHingeByHingeMethodFixedSupportBeam-inputDATA.csv", "r"); if (!InputFile){ MessageErrorReportTEXT(); printf(" File is not available! -> [PushoverHingeByHingeMethodFixedSupportBeam-inputDATA.csv] n"); Sleep(6000); exit(1); } char line[100],a[100]; while(i < 4 && fgets(line,sizeof(line),InputFile) != NULL){ sscanf(line,"%s",a); //printf("a[%d]: %sn",i,a); Import_Data[i]= atof(a); i++; } Length=Import_Data[0]; EI=Import_Data[1]; EA=Import_Data[2]; Ultimate_Mom=Import_Data[3]; } 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
  • 8. wColor = (csbi.wAttributes & 0xF0) + (ForgC & 0x0F); SetConsoleTextAttribute(hStdOut, wColor); } return; } void ANALYSIS(double Length,double EI,double EA,double Ultimate_Moment){ int i; double K[NN][NN],Kinv[NN][NN],eleF[2][6],ELE_FORCE[3][12],SUM_ELE_FORCE[12]; double L[Ne],lanX[Ne],lanY[Ne],AA[Ne],BB[Ne],CC[Ne],DD[Ne],EE[Ne],f[NN],F[NN],u[3],sum_u[3],Mi[4]; double output_u[3][3],output_base[3]; double MS[6][6],KG[6][6],LANNDA[4],LANNDA_min; double x[3],y[3]; for (i=0;i<NN;i++){ F[i]=0;f[i] = 0;u[i] = 0;sum_u[i] = 0; } for(int j=0;j<3;j++){ for(i=0;i<6*Ne;i++) ELE_FORCE[j][i] = 0; } for(i=0;i<6*Ne;i++) SUM_ELE_FORCE[i] = 0; for (i=0;i<4;i++) Mi[i] = 0; // SATAGE: 01 F[1]=-1; x[0] = 0;y[0]=0; x[1] = Length;y[1]=0+sum_u[1]; x[2] = 3*Length;y[2]=0; L[0] = SQRT2((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0])); L[1] = SQRT2((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1])); lanX[0]=(x[1]-x[0])/L[0];lanY[0]=(y[1]-y[0])/L[0]; lanX[1]=(x[2]-x[1])/L[1];lanY[1]=(y[2]-y[1])/L[1]; Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); K[0][0]= KG[3][3];//DOF(4) K[0][1]= KG[3][4];//DOF(4) K[0][2]= KG[3][5];//DOF(4) K[1][0]= KG[4][3];//DOF(5) K[1][1]= KG[4][4];//DOF(5) K[1][2]= KG[4][5];//DOF(5) K[2][0]= KG[5][3];//DOF(6) K[2][1]= KG[5][4];//DOF(6) K[2][2]= KG[5][5];//DOF(6) Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1); K[0][0]+= KG[0][0];//DOF(4) K[0][1]+= KG[0][1];//DOF(4) K[0][2]+= KG[0][2];//DOF(4) K[1][0]+= KG[1][0];//DOF(5)
  • 9. K[1][1]+= KG[1][1];//DOF(5) K[1][2]+= KG[1][2];//DOF(5) K[2][0]+= KG[2][0];//DOF(6) K[2][1]+= KG[2][1];//DOF(6) K[2][2]+= KG[2][2];//DOF(6) MatrixDetermination(K,NN); MatrixInverse(K,Kinv,NN);// Inverse [Kinit] MatrixMulti01(Kinv,F,u,NN); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); ElementInternalForce(MS,u,lanX,lanY,eleF,0); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1); ElementInternalForce(MS,u,lanX,lanY,eleF,1); LANNDA[0]=(Ultimate_Moment-ABS(Mi[0]))/ABS(eleF[0][2]); LANNDA[1]=(Ultimate_Moment-ABS(Mi[1]))/ABS(eleF[0][5]); LANNDA[2]=(Ultimate_Moment-ABS(Mi[2]))/ABS(eleF[1][2]); LANNDA[3]=(Ultimate_Moment-ABS(Mi[3]))/ABS(eleF[1][5]); LANNDA_min = MIN(LANNDA,4); for (i=0;i<NN;i++) u[i]=LANNDA_min*u[i]; Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,1); ElementInternalForce(MS,u,lanX,lanY,eleF,0); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1); ElementInternalForce(MS,u,lanX,lanY,eleF,1); Mi[0]=eleF[0][2]; Mi[1]=eleF[0][5]; Mi[2]=eleF[1][2]; Mi[3]=eleF[1][5]; ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,SUM_ELE_FORCE,u,sum_u,0); for (i=0;i<NN;i++) output_u[0][i]=sum_u[i];//output displacement output_base[0]=-SUM_ELE_FORCE[1]-SUM_ELE_FORCE[10];//output base shear // So plastic hinge has formed in node 1 // SATAGE: 02 x[0] = 0;y[0]=0; x[1] = Length;y[1]=0+sum_u[1]; x[2] = 3*Length;y[2]=0; L[0] = SQRT2((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0])); L[1] = SQRT2((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1])); lanX[0]=(x[1]-x[0])/L[0];lanY[0]=(y[1]-y[0])/L[0]; lanX[1]=(x[2]-x[1])/L[1];lanY[1]=(y[2]-y[1])/L[1]; Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,2); K[0][0]= KG[3][3];//DOF(4) K[0][1]= KG[3][4];//DOF(4) K[0][2]= KG[3][5];//DOF(4) K[1][0]= KG[4][3];//DOF(5) K[1][1]= KG[4][4];//DOF(5) K[1][2]= KG[4][5];//DOF(5) K[2][0]= KG[5][3];//DOF(6)
  • 10. K[2][1]= KG[5][4];//DOF(6) K[2][2]= KG[5][5];//DOF(6) Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1); K[0][0]+= KG[0][0];//DOF(4) K[0][1]+= KG[0][1];//DOF(4) K[0][2]+= KG[0][2];//DOF(4) K[1][0]+= KG[1][0];//DOF(5) K[1][1]+= KG[1][1];//DOF(5) K[1][2]+= KG[1][2];//DOF(5) K[2][0]+= KG[2][0];//DOF(6) K[2][1]+= KG[2][1];//DOF(6) K[2][2]+= KG[2][2];//DOF(6) MatrixDetermination(K,3); MatrixInverse(K,Kinv,NN);// Inverse [Kinit] MatrixMulti01(Kinv,F,u,NN); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,2); ElementInternalForce(MS,u,lanX,lanY,eleF,0); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1); ElementInternalForce(MS,u,lanX,lanY,eleF,1); LANNDA[0]=(Ultimate_Moment-ABS(Mi[0]))/ABS(eleF[0][2]); LANNDA[1]=(Ultimate_Moment-ABS(Mi[1]))/ABS(eleF[0][5]); LANNDA[2]=(Ultimate_Moment-ABS(Mi[2]))/ABS(eleF[1][2]); LANNDA[3]=(Ultimate_Moment-ABS(Mi[3]))/ABS(eleF[1][5]); LANNDA_min = MIN(LANNDA,4); for (i=0;i<NN;i++) u[i]=LANNDA_min*u[i]; Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,2); ElementInternalForce(MS,u,lanX,lanY,eleF,0); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,1); ElementInternalForce(MS,u,lanX,lanY,eleF,1); Mi[0]=eleF[0][2]; Mi[1]=eleF[0][5]; Mi[2]=eleF[1][2]; Mi[3]=eleF[1][5]; ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,SUM_ELE_FORCE,u,sum_u,1); for (i=0;i<NN;i++) output_u[1][i]=sum_u[i];//output displacement output_base[1]=-SUM_ELE_FORCE[1]-SUM_ELE_FORCE[10];//output base shear // So plastic hinge has formed in node 2 // SATAGE: 03 x[0] = 0;y[0]=0; x[1] = Length;y[1]=0+sum_u[1]; x[2] = 3*Length;y[2]=0; L[0] = SQRT2((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0])); L[1] = SQRT2((x[2]-x[1])*(x[2]-x[1])+(y[2]-y[1])*(y[2]-y[1])); lanX[0]=(x[1]-x[0])/L[0];lanY[0]=(y[1]-y[0])/L[0]; lanX[1]=(x[2]-x[1])/L[1];lanY[1]=(y[2]-y[1])/L[1]; Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,4); K[0][0]= KG[3][3];//DOF(4)
  • 11. K[0][1]= KG[3][4];//DOF(4) K[0][2]= KG[3][5];//DOF(4) K[1][0]= KG[4][3];//DOF(5) K[1][1]= KG[4][4];//DOF(5) K[1][2]= KG[4][5];//DOF(5) K[2][0]= KG[5][3];//DOF(6) K[2][1]= KG[5][4];//DOF(6) K[2][2]= KG[5][5];//DOF(6) Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,2); K[0][0]+= KG[0][0];//DOF(4) K[0][1]+= KG[0][1];//DOF(4) K[0][2]+= KG[0][2];//DOF(4) K[1][0]+= KG[1][0];//DOF(5) K[1][1]+= KG[1][1];//DOF(5) K[1][2]+= KG[1][2];//DOF(5) K[2][0]+= KG[2][0];//DOF(6) K[2][1]+= KG[2][1];//DOF(6) K[2][2]+= KG[2][2];//DOF(6) MatrixInverse(K,Kinv,NN-1);// Inverse [Kinit] MatrixMulti01(Kinv,F,u,NN-1); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,4); ElementInternalForce(MS,u,lanX,lanY,eleF,0); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,2); ElementInternalForce(MS,u,lanX,lanY,eleF,1); LANNDA[0]=(Ultimate_Moment-ABS(Mi[0]))/ABS(eleF[0][2]); LANNDA[1]=(Ultimate_Moment-ABS(Mi[1]))/ABS(eleF[0][5]); LANNDA[2]=(Ultimate_Moment-ABS(Mi[2]))/ABS(eleF[1][2]); LANNDA[3]=(Ultimate_Moment-ABS(Mi[3]))/ABS(eleF[1][5]); LANNDA_min = MIN(LANNDA,4); for (i=0;i<NN;i++) u[i]=LANNDA_min*u[i]; Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,0,4); ElementInternalForce(MS,u,lanX,lanY,eleF,0); Matrix_Stiffness(EA,EI,L,lanX,lanY,AA,BB,CC,DD,EE,MS,KG,1,2); ElementInternalForce(MS,u,lanX,lanY,eleF,1); Mi[0]=eleF[0][2]; Mi[1]=eleF[0][5]; Mi[2]=eleF[1][2]; Mi[3]=eleF[1][5]; ELEMNT_FORCE_OUTPUT(eleF,ELE_FORCE,SUM_ELE_FORCE,u,sum_u,2); for (i=0;i<3;i++) output_u[2][i]=sum_u[i];//output displacement output_base[2]=-SUM_ELE_FORCE[1]-SUM_ELE_FORCE[10];//output base shear MessageResult(output_base,output_u,3); //MatrixDetermination(K,3); OUTPUT_excel(output_u,output_base,ELE_FORCE,2);
  • 12. OUTPUT_matlab(output_u,output_base,ELE_FORCE,2); textcolor(15); printf("na - Output data is written in Excel and Matlab file -n"); DATE_TIME(); } void DATE_TIME(){ printf("nt"); system("echo %date%"); printf("t"); system("echo %time%"); } void Matrix_Stiffness(double EA,double EI,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 lan[6][6],lan_Tr[6][6],ans[6][6]; A[I] = 4*EI/L[I]; B[I] = 6*EI/(L[I]*L[I]); C[I] = 2*EI/L[I]; D[I] = 12*EI/(L[I]*L[I]*L[I]); E[I] = EA/L[I]; for (int i=0;i<6;i++) for (int j=0;j<6;j++) K[i][j] = 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;
  • 13. 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[2][6],double ELE_FORCE[3][12],double SUM_ELE_FORCE[12],double u[],double sum_u[], int I){ int i; for (i=0;i<6;i++) ELE_FORCE[I][i]=eleF[0][i]; for (i=6;i<12;i++) ELE_FORCE[I][i]=eleF[1][i-6]; for (i=0;i<6*Ne;i++) SUM_ELE_FORCE[i] += ELE_FORCE[I][i]; for (i=0;i<NN;i++) sum_u[i] += u[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-8; 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;
  • 14. 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 A[],double B[3][3],int n){ int i; printf("t "); for (i=0;i<123;i++) printf("-"); printf("n"); printf("t Increment Base Shear[DOF(2)]+[DOF(8)] Displacement [DOF(4)] Displacement [DOF(5)] Displacement [DOF(6)] n"); printf("t "); for (i=0;i<123;i++) printf("-"); printf("n"); for (i=0;i<n;i++) printf("tt %dtt %.3ett %.3ett %.3ett %.3en",i+1,A[i],B[i][0],B[i][1],B[i][2]); }