SlideShare a Scribd company logo
>> IN THE NAME OF GOD <<
Geometric and Material Nonlinearity Analysis of 2D Truss with Force and
Ductility Damage Index Control in C programming
C program is written by Salar Delavar Qashqai – Publication Date: 12/April/2021
E-mail: salar.d.ghashghaei@gmail.com
C Code:
#include <stdio.h>
#include <windows.h> // text color
#include <conio.h>
#define N 10000 // number of increment
#define NN 5 // number of degree of freedom
#define Ne 6 // number of element
#define ShowText01 "PushoverNonlinear2DTrussFCGNDI-inputDATA.csv"
#define ShowText02 "PushoverNonlinear2DTrussFCGNDI-inputELEPROP.csv"
#define ShowText03 "Output data is written in Text, Excel, Matlab and Html file"
#define ShowText04 "PushoverNonlinear2DTrussFCGNDI-outputEXCEL.csv"
#define ShowText05 "PushoverNonlinear2DTrussFCGNDI-outputHTML.html"
#define ShowText06 "PushoverNonlinear2DTrussFCGNDI-outputTEXT.txt"
#define ShowText07 "PushoverNonlinear2DTrussFCGNDI-outputMATLAB.m"
#define ShowText08 "Graph-outputHTML.html"
void IMPORT_FILE01(double &Length,double &Height,double Force[],double &Fini,int &itermax,double &tolerance,double &DI);
void IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int &n);
void SLOPE(double D1[],double F1[],double D2[],double F2[],double D3[],double F3[],double D4[],double F4[],double E1[],double E2[],double E3[],double E4[],int kn);
void MessageInitialData(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double DI,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n);
void MatrixAssembled(double [Ne][4][4],double [][NN]);
void MatrixDetermination(double [][NN],int );
void MatrixInverse(double [][NN], double [][NN],int );
void MatrixMulti01(double [][NN], double [], double [], double [],int );
void MatrixMulti02(double [][NN], double [], double [], double [],int );
double ABS(double );
double MAX_ABS(double [],int );
double SQRT2(double );
void ElementInternalForce(double EA[],double es[],double ele_f[]);
void ElementStiffness(int n,double Length,double Height,double es[],double u[],double D1[],double D2[],double D3[],double D4[],double E1[],double E2[],double E3[],double E4[],double F1[],double F2[],double F3[],double F4[],double A[],double EA[],double k[][4][4],double G[]);
void MessageCheck_IMPORT_FILE01(double ,double ,int ,double,double );
void MessageCheck_IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n);
void MessageErrorReportTEXT();
void MessageAnalysisReportTEXT();
void MessageInputDataTEXT();
void MessageNotConverge(int ,int );
void MessageConverge(int ,int ,double [],double []);
void OUTPUT_text(int zMAX,int I[],int IT[],double reaction[],double DISP[][NN],double eleF[][Ne]);
void OUTPUT_matlab(int zMAX,double reaction[],double DISP[][NN]);
void OUTPUT_excel(int zMAX,int I[],double DISP[][NN],double eleF[][Ne],double reaction[]);
void OUTPUT_html(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int zMAX,int I[],double DISP[][5],double eleF[][6],double reaction[],double DI);
void Distance(int );
double MAX(double A[],int n);
void SHOW_INITAL_REPORT_TEXT();
void ANALYSIS(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int kn,int m,double DI);
void textcolor(int ForgC);
void DATE_TIME();
void BILINEAR_CURVE(double A[],double B[],int M);
void OUTPUT_HTML_GRAPH(double DISP[][5],double reaction[],int n);
int main(){
int itermax,kn,m;
double Length,Height,Force[5],Fini,residual,tolerance,DI;
double F1[Ne],D1[Ne],F2[Ne],D2[Ne],F3[Ne],D3[Ne],F4[Ne],D4[Ne],A[Ne];
IMPORT_FILE01(Length,Height,Force,Fini,itermax,tolerance,DI);
MessageCheck_IMPORT_FILE01(Length,Height,itermax,tolerance,DI);
m = ABS(Fini)/ABS(Force[1]) +1;
IMPORT_FILE02(F1,D1,F2,D2,F3,D3,F4,D4,A,kn);
MessageCheck_IMPORT_FILE02(F1,D1,F2,D2,F3,D3,F4,D4,A,kn);
textcolor(11);
MessageInitialData(Length,Height,Force,Fini,itermax,tolerance,m,DI,F1,D1,F2,D2,F3,D3,F4,D4,A,kn);
textcolor(14);
MessageAnalysisReportTEXT();
ANALYSIS(Length,Height,Force,Fini,itermax,tolerance,F1,D1,F2,D2,F3,D3,F4,D4,A,kn,m,DI);
getch();
return 0;
}
void IMPORT_FILE01(double &Length,double &Height,double Force[],double &Fini,int &itermax,double &tolerance,double &DI){
double Import_Data[11];
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 < N && 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];
Height=Import_Data[1];
Force[0]=Import_Data[2];
Force[1]=Import_Data[3];
Force[2]=Import_Data[4];
Force[3]=Import_Data[5];
Force[4]=Import_Data[6];
Fini=Import_Data[7];
itermax=Import_Data[8];
tolerance=Import_Data[9];
DI=Import_Data[10];
}
void IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],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,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&D1[i],&F1[i],&D2[i],&F2[i],&D3[i],&F3[i],&D4[i],&F4[i],&A[i]);
i++;
}
while(i < N && fgets(line,sizeof(line),InputFile) != NULL);
n = i-1;
//printf("%dn",n);
}
void MessageInitialData(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double DI,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n){
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<80;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf("tttt%c >>IN THE NAME OF GOD << %cn",Qf,Qf);
printf("tttt%c Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control %cn",Qf,Qf);
printf("tttt%c and Ductility Damage Index Control. %cn",Qf,Qf);
printf("tttt%c UNIT: Free Unit %cn",Qf,Qf);
printf("tttt%c",Qg);
for (i=1;i<80;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<80;i++)
printf("%c",Qb);
printf("%cn",Qe);
MessageInputDataTEXT();
printf(" Length of truss structure: %.3en",Length);
printf(" Height of truss structure: %.3en",Height);
printf(" External force [DOF(3)]: %.3en",Force[0]);
printf(" External force [DOF(5)]: %.3en",Force[1]);
printf(" External force [DOF(6)]: %.3en",Force[2]);
printf(" External force [DOF(7)]: %.3en",Force[3]);
printf(" External force [DOF(8)]: %.3en",Force[4]);
printf(" Ultimate external force [DOF(5)]: %.3en",Fini);
printf(" Maximum number of iterations: %.3en",itermax);// maximum number of iterations
printf(" Specified tolerance for convergence: %.3en",tolerance);// specified tolerance for convergence
printf(" Number of increments: %dn",M);
printf(" Ductility Damage Index: %.3enn",DI);
printf(" ");
for(i=0;i<125;i++)
printf("=");
printf("n");
printf(" Strain01 Stress01 Strain02 Stress02 Strain03 Stress03 Strain04 Stress04 Element Arean");
printf(" ");
for(i=0;i<125;i++)
printf("=");
printf("n");
for(i=0;i<n;i++)
printf(" Element[%d]: %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3en",i+1,D1[i],F1[i],D2[i],F2[i],D3[i],F3[i],D4[i],F4[i],A[i]);
printf(" ");
for(i=0;i<125;i++)
printf("=");
printf("n");
}
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 MatrixMulti01(double A[][NN], double B[], double C[], double D[],int n){
int i,j;
double ff;
// [f] =[Ktot] - [u] - [F]
for (i=0; i<n; i++){
ff=0;
for (j=0; j<n; j++)
ff += A[i][j]*B[j];
D[i] = ff-C[i];
}
}
void MatrixMulti02(double A[][NN], double B[], double C[], double D[],int n){
int i,j;
double Dx;
// [du] =[InvKinit] *[f]
for (i=0; i<n; i++){
Dx=0;
for (j=0; j<n; j++)
Dx += A[i][j]* -B[j];
C[i]=Dx;
D[i] += C[i];// u= u+du
}
}
void ElementInternalForce(double EA[],double es[],double ele_f[]){
for (int I=0; I<6;I++)
ele_f[I] = EA[I]*(es[I]+.5*es[I]*es[I]);
}
void ElementStiffness(int n,double Length,double Height,double es[],double u[],double D1[],double D2[],double D3[],double D4[],double E1[],double E2[],double E3[],double E4[],double F1[],double F2[],double F3[],double F4[],double A[],double EA[],double k[][4][4],double G[]){
double x1,y1,x2,y2,x3,y3,x4,y4,L[6],Lpr[Ne],lanX[Ne],lanY[Ne],lanxx[Ne],lanxy[Ne],lanyy[Ne];
int i;
Lpr[0]=Length;Lpr[1]=Height;
Lpr[2]=SQRT2(Length*Length+Height*Height);Lpr[3]=SQRT2(Length*Length+Height*Height);
Lpr[4]=Height;Lpr[5]=Length;
x1=0;y1=0;
x2=Length+u[0];y2=0;
x3=u[1];y3=Height+u[2];
x4=Length+u[3];y4=Height+u[4];
L[0]=SQRT2((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
L[1]=SQRT2((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
L[2]=SQRT2((x4-x1)*(x4-x1)+(y4-y1)*(y4-y1));
L[3]=SQRT2((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
L[4]=SQRT2((x4-x2)*(x4-x2)+(y4-y2)*(y4-y2));
L[5]=SQRT2((x4-x3)*(x4-x3)+(y4-y3)*(y4-y3));
lanX[0]=(x2-x1)/L[0];lanY[0]=(y2-y1)/L[0];
lanX[1]=(x3-x1)/L[1];lanY[1]=(y3-y1)/L[1];
lanX[2]=(x4-x1)/L[2];lanY[2]=(y4-y1)/L[2];
lanX[3]=(x3-x2)/L[3];lanY[3]=(y3-y2)/L[3];
lanX[4]=(x4-x2)/L[4];lanY[4]=(y4-y2)/L[4];
lanX[5]=(x4-x3)/L[5];lanY[5]=(y4-y3)/L[5];
for (i=0;i<n;i++){
es[i]=(L[i]-Lpr[i])/Lpr[i];
if (ABS(es[i])>= 0 && ABS(es[i])<= D1[i])
EA[i] = E1[i]*A[i];
else if (ABS(es[i])> D1[i] && ABS(es[i])<= D2[i])
EA[i] = ((F1[i]+E2[i]*(ABS(es[i])-D1[i]))/ABS(es[i]))*A[i];
else if (ABS(es[i])> D2[i] && ABS(es[i])<= D3[i])
EA[i] = ((F2[i]+E3[i]*(ABS(es[i])-D2[i]))/ABS(es[i]))*A[i];
else if (ABS(es[i])> D3[i] && ABS(es[i])<= D4[i])
EA[i] = ((F3[i]+E4[i]*(ABS(es[i])-D3[i]))/ABS(es[i]))*A[i];
else
EA[i] =0;
// Element
G[i] = EA[i]/L[i];lanxx[i]=lanX[i]*lanX[i];lanxy[i]=lanX[i]*lanY[i];lanyy[i]=lanY[i]*lanY[i];
k[i][0][0]=G[i]*lanxx[i];k[i][0][1]=G[i]*lanxy[i];k[i][0][2]=-G[i]*lanxx[i];k[i][0][3]=-G[i]*lanxy[i];
k[i][1][0]=G[i]*lanxy[i];k[i][1][1]=G[i]*lanyy[i];k[i][1][2]=-G[i]*lanxy[i];k[i][1][3]=-G[i]*lanyy[i];
k[i][2][0]=-G[i]*lanxx[i];k[i][2][1]=-G[i]*lanxy[i];k[i][2][2]=G[i]*lanxx[i];k[i][2][3]=G[i]*lanxy[i];
k[i][3][0]=-G[i]*lanxy[i];k[i][3][1]=-G[i]*lanyy[i];k[i][3][2]=G[i]*lanxy[i];k[i][3][3]=G[i]*lanyy[i];
}
}
void MatrixAssembled(double k[Ne][4][4],double K[][NN]){
K[0][0]= k[0][2][2]+k[3][0][0]+k[4][0][0];
K[0][1]= k[3][0][2];
K[0][2]= k[3][0][3];
K[0][3]= k[4][0][2];
K[0][4]= k[4][0][3];
K[1][0]= k[3][2][0];
K[1][1]= k[1][2][2]+k[3][2][2]+k[5][0][0];
K[1][2]= k[1][2][3]+k[3][2][3]+k[5][0][1];
K[1][3]= k[5][0][2];
K[1][4]= k[5][0][3];
K[2][0]= k[3][3][0];
K[2][1]= k[1][3][2]+k[3][3][2]+k[5][1][0];
K[2][2]= k[1][3][3]+k[3][3][3]+k[5][1][1];
K[2][3]= k[5][1][2];
K[2][4]= k[5][1][3];
K[3][0]= k[4][2][0];
K[3][1]= k[5][2][0];
K[3][2]= k[4][2][1];
K[3][3]= k[2][2][2]+k[4][2][2]+k[5][2][2];
K[3][4]= k[2][2][3]+k[4][2][3]+k[5][2][3];
K[4][0]= k[4][3][0];
K[4][1]= k[5][3][0];
K[4][2]= k[5][3][1];
K[4][3]= k[2][2][2]+k[4][3][2]+k[5][3][2];
K[4][4]= k[2][3][3]+k[4][3][3]+k[5][3][3];
}
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");
}
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;
}
}
double ABS(double B){
if (B < 0)
B = -B;//Absolute number
else
B = B;
return B;
}
void OUTPUT_text(int zMAX,int I[],int IT[],double reaction[],double DISP[][5],double eleF[][6]){
// TEXT OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText06, "w");
fprintf(OutputFile,"ttttt ___________________________________________________________________________________________________________________n");
fprintf(OutputFile,"ttttt | >> IN THE NAME OF GOD << |n");
fprintf(OutputFile,"ttttt | Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control. |n");
fprintf(OutputFile,"ttttt |___________________________________________________________________________________________________________________|n");
fprintf(OutputFile,"ttttt | Unit: Free unit |n");
fprintf(OutputFile,"ttttt | Newton-Raphson Method : Tangent procedure |n");
fprintf(OutputFile,"ttttt |___________________________________________________________________________________________________________________|n");
fprintf(OutputFile,"ttttt | Program is written by Salar Delavar Ghashghaei |n");
fprintf(OutputFile,"ttttt | E-mail: salar.d.ghashghaei@gmail.com |n");
fprintf(OutputFile,"ttttt |___________________________________________________________________________________________________________________|n");
fprintf(OutputFile," ");
for (i=1;i<=145;i++)
fprintf(OutputFile,"-");
fprintf(OutputFile,"n");
fprintf(OutputFile," Increment Iteration Reaction Disp.[DOF(3)] Disp.[DOF(5)] Disp.[DOF(6)] Disp.[DOF(7)] Disp.[DOF(8)] n");
fprintf(OutputFile," ");
for (i=1;i<=145;i++)
fprintf(OutputFile,"-");
fprintf(OutputFile,"n");
for (i=0;i<zMAX;i++)
fprintf(OutputFile,"t%dt %d %e %e %e %e %e %en",I[i]+1,IT[i],reaction[i],DISP[i][0],DISP[i][1],DISP[i][2],DISP[i][3],DISP[i][4]);
fprintf(OutputFile," ");
for (i=1;i<=140;i++)
fprintf(OutputFile,"-");
fprintf(OutputFile,"n");
fprintf(OutputFile," Increment Axial Force-Ele(1) Axial Force-Ele(2) Axial Force-Ele(3) Axial Force-Ele(4) Axial Force-Ele(5) Axial Force-Ele(6) n");
fprintf(OutputFile," ");
for (i=1;i<=140;i++)
fprintf(OutputFile,"-");
fprintf(OutputFile,"n");
for (i=0;i<zMAX;i++)
fprintf(OutputFile,"t%dt %e %e %e %e %e %en",I[i]+1,eleF[i][0],eleF[i][1],eleF[i][2],eleF[i][3],eleF[i][4],eleF[i][5]);
fclose(OutputFile);
}
void OUTPUT_matlab(int zMAX,double reaction[],double DISP[][5]){
// MATLAB OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText07, "w");
fprintf(OutputFile," %% Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control. %%n");
fprintf(OutputFile,"BaseShear=[0n");
for(i=0;i<zMAX;i++)
fprintf(OutputFile,"%en",reaction[i]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"Displacement=[0n");
for(i=0;i<zMAX;i++)
fprintf(OutputFile,"%en",DISP[i][1]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"figure(1)n");
fprintf(OutputFile,"plot(Displacement,BaseShear,'LineWidth',3);n");
fprintf(OutputFile,"title(['#BASESHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n");
fprintf(OutputFile,"legend('C++','Location','NorthEastOutside');n");
fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(5)]');ylabel('BASESHEAR [DOF(1)]');grid on;n");
fclose(OutputFile);
}
void OUTPUT_excel(int zMAX,int I[],double DISP[][5],double eleF[][6],double reaction[]){
// EXCEL OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText04, "w");
fprintf(OutputFile," ### Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control ###n");
fprintf(OutputFile,"Increment,Base Shear [DOF(1)],Displacement [DOF(3)],Displacement [DOF(5)],Displacement [DOF(6)],Displacement [DOF(7)],Displacement [DOF(8)],Axial Force-Ele(1),Axial Force-Ele(2),Axial Force-Ele(3),Axial Force-Ele(4),Axial Force-Ele(5),Axial Force-Ele(6)n");
for(i=0;i<zMAX;i++)
fprintf(OutputFile,"%d,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%en",I[i]+1,reaction[i],DISP[i][0],DISP[i][1],DISP[i][2],DISP[i][3],DISP[i][4],eleF[i][0],eleF[i][1],eleF[i][2],eleF[i][3],eleF[i][4],eleF[i][5]);
fclose(OutputFile);
}
void OUTPUT_html(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int zMAX,int I[],double DISP[][5],double eleF[][6],double reaction[],double DI){
// HTML OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText05, "w");
fprintf(OutputFile,"<html> <body bgcolor="green">n");
// IMPORT IMAGE
fprintf(OutputFile,"<img src="PushoverNonlinear2DTrussFCGNDI-image01.png" style="width:1000px ; height:500px" alt="analysis01"><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,"<th bgcolor="cyan"> Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control. - 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">Length of truss structure: </th><th> %.3e </th> </tr>n",Length);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Height of truss structure: </th><th> %.3e </th> </tr>n",Height);
fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(3)]: </th><th> %.3e </th> </tr>n",Force[0]);
fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(5)]: </th><th> %.3e </th> </tr>n",Force[1]);
fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(6)]: </th><th> %.3e </th> </tr>n",Force[2]);
fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(7)]: </th><th> %.3e </th> </tr>n",Force[3]);
fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(8)]: </th><th> %.3e </th> </tr>n",Force[4]);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Ultimate external force [DOF(5)]: </th><th> %.3e </th> </tr>n",Fini);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Number of increments: </th><th> %d </th> </tr>n",M);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Maximum number of iterations: </th><th> %d </th> </tr>n",itermax);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Specified tolerance for convergence: </th><th> %.3e </th> </tr>n",tolerance);
fprintf(OutputFile,"<tr> <th bgcolor="orange">Ductility Damage Index: </th><th> %.3e </th> </tr>n",DI);
// TABLE 2
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th colspan="10" bgcolor="orange"> Elements Strain-Stress </th> <tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange"> Element Number </th> <th bgcolor="orange">Strain [1]</th> <th bgcolor="orange">Stress [1]</th><th bgcolor="orange">Strain [2]</th><th bgcolor="orange">Stress [2]</th><th bgcolor="orange">Strain [3]</th><th bgcolor="orange">Stress [3]</th><th bgcolor="orange">Strain [4]</th> <th bgcolor="orange">Stress [4]</th><th bgcolor="orange">Section Area </th></tr>n");
for(i=0;i<6;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><td align ="center"> %.3e </td><td align ="center"> %.3e </td><td align ="center"> %.3e </td></td> </tr>n",i+1,D1[i],F1[i],D2[i],F2[i],D3[i],F3[i],D4[i],F4[i],A[i]);
}
// TABLE 3
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">Displacement [DOF(3)]</th> <th bgcolor="orange">Displacement [DOF(5)]</th><th bgcolor="orange">Displacement [DOF(6)]</th><th bgcolor="orange">Displacement [DOF(7)]</th><th bgcolor="orange">Displacement [DOF(8)]</th></tr>n");
for(i=0;i<zMAX;i++){
fprintf(OutputFile,"<tr> <td align ="center"> %d </td> <td align ="center"> %.3e </td> </td> <td align ="center"> %.3e </td></td> <td align ="center"> %.3e </td></td> <td align ="center"> %.3e </td></td> <td align ="center"> %.3e </td></tr>n",i+1,DISP[i][0],DISP[i][1],DISP[i][2],DISP[i][3],DISP[i][4]);
}
// TABLE 4
fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n");
fprintf(OutputFile,"<tr><th colspan="10" bgcolor="orange"> Structral Element Internal Forces </th> </tr>n");
fprintf(OutputFile,"<tr> <th bgcolor="orange"> Increment </th> <th bgcolor="orange">Base Shear [DOF(1)]</th> <th bgcolor="orange">Axial Force-Ele(1)</th> <th bgcolor="orange">Axial Force-Ele(2)</th> <th bgcolor="orange">Axial Force-Ele(3)</th> <th bgcolor="orange">Axial Force-Ele(4)</th> <th bgcolor="orange">Axial Force-Ele(5)</th> <th bgcolor="orange">Axial Force-Ele(6)</th></tr>n");
for(i=0;i<zMAX;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> <td align ="center"> %.3e </td></tr>n",i+1,reaction[i],eleF[i][0],eleF[i][1],eleF[i][2],eleF[i][3],eleF[i][4],eleF[i][5]);
}
fprintf(OutputFile,"</table></body></html>n");
fclose(OutputFile);
}
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 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 MessageCheck_IMPORT_FILE01(double Length,double Height,int itermax,double tolerance,double DI){
if ( Length <0 || Height <0 || itermax < 0 || tolerance<0 ){
MessageErrorReportTEXT();
printf(" Please check this file! ->[%s]n",ShowText01);
printf(" *** Negative data input value is not acceptable ***n");
printf(" Truss length: %fn",Length);
printf(" Truss height: %fn",Height);
printf(" Maximum iteration: %dn",itermax);
printf(" Tolerance: %.3en",tolerance);
printf(" Damage Index: %.3en",DI);
Sleep(40000);
exit(1);
}
}
void MessageCheck_IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n){
int i;
for (i=0;i<n;i++){
if (F1[i] <= 0 || D1[i] <= 0 || F2[i] <= 0 || D2[i] <= 0 || F3[i] <= 0 || D3[i] <=0 || F4[i] <=0 || D4[i] <= 0 || A[i] <= 0){
MessageErrorReportTEXT();
printf(" Please check this file! ->[%s]n",ShowText02);
printf(" *** Negative data input value is not acceptable ***n");
printf(" Row %d has a negative value.n",i+1);
printf(" Strain-1 [%d]: %fn",i,D1[i]);
printf(" Stress-1 [%d]: %fn",i,F1[i]);
printf(" Strain-2 [%d]: %fn",i,D2[i]);
printf(" Stress-2 [%d]: %fn",i,F2[i]);
printf(" Strain-3 [%d]: %fn",i,D3[i]);
printf(" Stress-3 [%d]: %fn",i,F3[i]);
printf(" Strain-4 [%d]: %fn",i,D4[i]);
printf(" Stress-4 [%d]: %fn",i,F4[i]);
printf(" Section area [%d]: %fn",i,A[i]);
Sleep(40000);
exit(1);
}
}
}
void MessageNotConverge(int ii,int iit){
Distance(ii+1);
printf("%dt %d -> ## This step is not converged ##n",ii+1,iit);
}
void MessageConverge(int ii,int iit,double A[],double B[]){
Distance(ii+1);
printf("%dt %d %.3e %.3e %.3e %.3e %.3e %.3en",ii+1,iit,B[ii],A[0],A[1],A[2],A[3],A[4]);
}
void Distance(int i){
if (i < 10)
printf("t");
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");
}
double MAX(double A[],int n){
int i;
double Amax;
Amax = A[0];
for (i=1;i<n;i++){
if (Amax < A[i])
Amax=A[i];
}
return Amax;//Maximum DATA
}
void SLOPE(double D1[],double F1[],double D2[],double F2[],double D3[],double F3[],double D4[],double F4[],double E1[],double E2[],double E3[],double E4[],int kn){
for (int i=0;i<kn;i++){
E1[i]=(F1[i]-0)/(D1[i]-0);
E2[i]=(F2[i]-F1[i])/(D2[i]-D1[i]);
E3[i]=(F3[i]-F2[i])/(D3[i]-D2[i]);
E4[i]=(F4[i]-F3[i])/(D4[i]-D3[i]);
//printf("E4: %fn",E4[i]);
}
}
void SHOW_INITAL_REPORT_TEXT(){
int i;
printf(" ");
for (i=1;i<=145;i++)
printf("-");
printf("n");
printf(" Increment Iteration Reaction Disp.[DOF(3)] Disp.[DOF(5)] Disp.[DOF(6)] Disp.[DOF(7)] Disp.[DOF(8)] n");
printf(" ");
for (i=1;i<=145;i++)
printf("-");
printf("n");
}
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 Height,double Force[],double Fini,int itermax,double tolerance,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int kn,int m,double DI){
int i,it,zz,zMAX,well_done;
double residual;
double EA[Ne],G[Ne],lanX[Ne],lanY[Ne],ele_force[Ne],es[Ne],strain[Ne];
double k[Ne][4][4],u[NN],F[NN],Ktot[NN][NN],Kt[NN][NN],InvKtot[NN][NN],f[NN],du[NN];
double E1[10],E2[10],E3[10],E4[10];
double *reaction= new double [N];
double *DU= new double [N];
int *I= new int [N];
int *IT= new int [N];
double *DISP_DOF_5 = new double [N];
double DISP[N][5],eleF[N][Ne];
SLOPE(D1,F1,D2,F2,D3,F3,D4,F4,E1,E2,E3,E4,kn);
F[0]=Force[0];F[2]=Force[2];F[3]=Force[3];F[4]=Force[4];
SHOW_INITAL_REPORT_TEXT();
for (zz=0;zz <= m || well_done !=1;zz++){
F[1] =Force[1]*(zz+1);// Define the applied load
ElementStiffness(Ne,Length,Height,es,u,D1,D2,D3,D4,E1,E2,E3,E4,F1,F2,F3,F4,A,EA,k,G);
// Total Stiffness
MatrixAssembled(k,Ktot);
// Inverse [Ktot]
MatrixInverse(Ktot,InvKtot,NN);
it = 0; // initialize iteration count
residual = 100; // initialize residual
while (residual > tolerance){
ElementStiffness(Ne,Length,Height,es,u,D1,D2,D3,D4,E1,E2,E3,E4,F1,F2,F3,F4,A,EA,k,G);
MatrixAssembled(k,Kt);
// Finding the determinant of a square matrix
MatrixDetermination(Kt,NN);
// [f] =[Kt] - [u] - [F]
MatrixMulti01(Kt,u,F,f,NN);
// [du] =[InvKtot] * [f]
MatrixMulti02(InvKtot,f,du,u,NN);
// Max residual
residual = MAX_ABS(du,NN);
it += 1; // increment iteration count
if (it == itermax){
MessageNotConverge(zz,it);
break;
}
} // while
// Force and Dispalcement for each increment
reaction[zz] = Force[1]*(zz+1) + Force[0] + Force[3];
DISP_DOF_5[zz] = u[1];
DU[zz]=residual;I[zz]=zz;IT[zz]=it;
// iteration control
if (it < itermax)
MessageConverge(zz,it,u,reaction);
zMAX = zz+1;
// Internal force of each element
ElementInternalForce(EA,es,ele_force);
// Internal force and displacement of each increment
for (i=0;i<Ne;i++){
eleF[zz][i] = ele_force[i];
DISP[zz][i] = u[i];
}
for (i=0;i<Ne;i++){ // Control Strain Damage Index.
strain[i] = DI*(D4[i]-D1[i])+D1[i];
// printf("tt DI strain[%d]: %.3e - ele. strain[%d]: %.3e n",i+1,strain[i],i+1,es[i]);
if (ABS(es[i]) >= ABS(strain[i])){
printf("n ## Strain in element[%d]: %.3e reached to Strain Damage Index: %.3e ##nn",i+1,es[i],strain[i]);
well_done = 1;
}
if (well_done ==1)
break;
}
if (ABS(u[0]) >= Fini){
printf("n ## External force [DOF(5)] reached to ultimate force ##nn");
well_done = 1;
break;
}
if (ABS(reaction[zz]) >= Fini){
printf("n ## External force [DOF(5)] reached to ultimate force ##nn");
well_done = 1;
break;
}
}// for - force increment
if (well_done ==1 ){
if (zMAX >= 25) BILINEAR_CURVE(DISP_DOF_5,reaction,zMAX);
OUTPUT_text(zMAX,I,IT,reaction,DISP,eleF);
OUTPUT_matlab(zMAX,reaction,DISP);
OUTPUT_excel(zMAX,I,DISP,eleF,reaction);
OUTPUT_html(Length,Height,Force,Fini,itermax,tolerance,m,D1,F1,D2,F2,D3,F3,D4,F4,A,zMAX,I,DISP,eleF,reaction,DI);
OUTPUT_HTML_GRAPH(DISP,reaction,zMAX);
textcolor(15);
printf("na - %s -",ShowText03);
system("start /w Graph-outputHTML.html");
DATE_TIME();
}
}
void DATE_TIME(){
printf("nt");
system("echo %date%");
printf("t");
system("echo %time%");
}
void MessageAnalysisReportTEXT(){
int i;
char Ql;
Ql=176;
printf("an ");
for (i=1;i<64;i++)
printf("%c",Ql);
printf(" Analysis Report ");
for (i=1;i<64;i++)
printf("%c",Ql);
printf("n");
}
void BILINEAR_CURVE(double A[],double B[],int M){
double AaSUM=0,B_max=0,k0;
int I,Mmax;
double *AA = (double *) malloc(N);
double *BB = (double *) malloc(N);
double C[6];
for (I=0;I<6;I++);
C[I] =0;
Mmax=0;
for (I=0;I<M;I++){
if (ABS(B_max) < ABS(B[I])){
B_max = ABS(B[I]);
Mmax =I;
}//if
}//for
Mmax =I;
for (I=0;I<Mmax;I++){
AA[I+1]=ABS(A[I]);
BB[I+1]=ABS(B[I]);
}
for (I=0;I<Mmax;I++){ // Mmax-1
AaSUM += ((BB[I]+BB[I+1])*0.5*(AA[I+1]-AA[I]));;
}
C[1]=0;// C[0]=D_y ; C[1]=D_u ; C[2]=F_y ; C[3]=F_u ; C[4]=SC ; C[5]=OF ;
B_max=0;
for (I=0;I<Mmax+1;I++){ // find max
if(C[1] < AA[I])
C[1]=AA[I];
if(B_max < BB[I])
B_max =BB[I];
}
C[3]=BB[I-1];//printf("t %fn",C[3]);
k0 =BB[4]/AA[4];//printf("t %fn",k0);
C[0] = (C[3]*C[1]*0.5-AaSUM)/(C[3]*0.5 - k0*C[1]*0.5);//printf("t %fn",C[0]);
C[2] = k0*C[0];
C[4]=C[1]/C[0];C[5]=C[3]/C[2];
printf("n Structure ductility ratio: %.5en",C[4]);
printf(" Structure over strength factor: %.5enn",C[5]);
printf(" ================================n");
printf(" = Bilinear curve fitted =n");
printf(" = Displacaement Reaction =n");
printf(" = DOF[5] DOF[1] =n");
printf(" ================================n");
printf(" 0 0 n");
printf("t %.3et%.3en",C[0],C[2]);
printf("t %.3et%.3en",C[1],C[3]);
printf(" ================================nn");
}
double MAX_ABS(double A[],int n){
int i;
double B[N];
double Amax;
// abs value
for (i=0;i<n;i++){
B[i] = A[i];
if(B[i] <0)
B[i] = -B[i];
}
// Max of abs
Amax = B[0];
for (i=1;i<n;i++){
if(Amax < B[i])
Amax = B[i];
}
return Amax;
}
void OUTPUT_HTML_GRAPH(double DISP[][5],double reaction[],int n){
// HTML GRAPH OUTPUT
int i;
double x,y,X[N],Y[N],Xnew[N],Ynew[N],NorX[N],NorY[N],Xmax,Ymax;
for (i=0;i<n;i++){
X[i] = ABS(DISP[i][1]);
Y[i] = ABS(reaction[i]);
}
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] = X[i];
Ynew[i+1] = 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(ShowText08, "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="60px serif";s4.fillStyle = "#7fff00";s4.fillText("Base Shear-Disp. Graph",0,0); n");
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("Base Shear [DOF(1)]",0,0);s4.restore(); n");
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("Displacement [DOF(5)]",0,0);s4.restore(); n");
for(i=0;i<10;i++){
x=.1*(i+1)*Xmax;
fprintf(OutputFile,"s5.save();X=-.29*Lx+Lx*(%d+1)*.1;Y=.3*y+Ly+20;s5.rotate(2*Math.PI);s5.font="16px serif"; n",i);
fprintf(OutputFile,"s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText("%.3e",X,Y);s5.restore(); n",x);
}
for(i=0;i<10;i++){
y=.1*(i+1)*Ymax;
fprintf(OutputFile,"s5.save();X=-.28*Lx-50;Y=Ly+.3*y-Ly*(%d+1)*.1;s5.rotate(2*Math.PI);s5.font="16px serif"; n",i);
fprintf(OutputFile,"s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText("%.3e",X,Y);s5.restore(); n",y);
}
fprintf(OutputFile,"s5.save();X=-.25*Lx;Y=.3*y+Ly+20;s5.rotate(2*Math.PI);s5.font="16px serif";s5.fillStyle = "#7fff00";s5.fillText(0,X,Y);s5.restore(); n");
fprintf(OutputFile,"s5.save();X=-.25*Lx-50;Y=Ly+.3*y;s5.rotate(2*Math.PI);s5.font="16px serif";s5.fillStyle = "#7fff00";s5.textAlign = "left";s5.fillText(0,X,Y);s5.restore();}; n");
fprintf(OutputFile,"</script></head><body><canvas id="myCanvas" width="1300" height="1300"style="border:1px solid black;"></canvas></body></html> n");
fclose(OutputFile);
}
Figure(1) C program
Figure(2) C program
Figure(3) Input Data
Figure(4) Input Elemenets Strain-Stress Data
Figure(5) HTML Output
Figure(6) Graph Output

More Related Content

What's hot

DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
Anushka Rai
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
Sushil Mishra
 
Pnno
PnnoPnno
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
Nitesh Dubey
 
C programs
C programsC programs
C programs
Vikram Nandini
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
Srinivas Reddy Amedapu
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
Srinivas Reddy Amedapu
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu
 
C program
C programC program
C program
Komal Singh
 
SaraPIC
SaraPICSaraPIC
SaraPIC
Sara Sahu
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
Rajeev Sharan
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
riturajj
 
Declaring friend function with inline code
Declaring friend function with inline codeDeclaring friend function with inline code
Declaring friend function with inline code
Rajeev Sharan
 
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
vrgokila
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
Kandarp Tiwari
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
C PROGRAMS
C PROGRAMSC PROGRAMS
Arrays
ArraysArrays

What's hot (20)

DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
Pnno
PnnoPnno
Pnno
 
design and analysis of algorithm Lab files
design and analysis of algorithm Lab filesdesign and analysis of algorithm Lab files
design and analysis of algorithm Lab files
 
C programs
C programsC programs
C programs
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
 
C program
C programC program
C program
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
Rajeev oops 2nd march
Rajeev oops 2nd marchRajeev oops 2nd march
Rajeev oops 2nd march
 
Cn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshanCn os-lp lab manual k.roshan
Cn os-lp lab manual k.roshan
 
Declaring friend function with inline code
Declaring friend function with inline codeDeclaring friend function with inline code
Declaring friend function with inline code
 
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
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
C programms
C programmsC programms
C programms
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
Arrays
ArraysArrays
Arrays
 

Similar to Geometric and material nonlinearity analysis of 2 d truss with force and ductility damage index control in c programming

C Programming Example
C Programming Example C Programming Example
C Programming Example
University of Potsdam
 
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
 
Function basics
Function basicsFunction basics
Function basics
mohamed sikander
 
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
Salar Delavar Qashqai
 
week-3x
week-3xweek-3x
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translation
Shobhit Saxena
 
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
 
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
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
Abdullah Al Shiam
 
Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789
Ghh
 
labb123456789123456789123456789123456789
labb123456789123456789123456789123456789labb123456789123456789123456789123456789
labb123456789123456789123456789123456789
Ghh
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
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
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
tristans3
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
VTU Network lab programs
VTU Network lab   programsVTU Network lab   programs
VTU Network lab programs
Ananda Kumar HN
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
Koshy Geoji
 

Similar to Geometric and material nonlinearity analysis of 2 d truss with force and ductility damage index control in c programming (20)

C Programming Example
C Programming Example C Programming Example
C Programming Example
 
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...
 
Function basics
Function basicsFunction basics
Function basics
 
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
 
week-3x
week-3xweek-3x
week-3x
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Write a program to perform translation
Write a program to perform translationWrite a program to perform translation
Write a program to perform translation
 
Write a program to perform translation.
 Write a program to perform translation. Write a program to perform translation.
Write a program to perform translation.
 
Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]Cse 121 presentation on matrix [autosaved]
Cse 121 presentation on matrix [autosaved]
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789Zoro123456789123456789123456789123456789
Zoro123456789123456789123456789123456789
 
labb123456789123456789123456789123456789
labb123456789123456789123456789123456789labb123456789123456789123456789123456789
labb123456789123456789123456789123456789
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
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...
 
C Programming
C ProgrammingC Programming
C Programming
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
VTU Network lab programs
VTU Network lab   programsVTU Network lab   programs
VTU Network lab programs
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
 
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 solver
Salar Delavar Qashqai
 
Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...
Salar Delavar Qashqai
 
Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...
Salar Delavar Qashqai
 
Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...
Salar Delavar Qashqai
 
Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000
Salar Delavar Qashqai
 
Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...
Salar Delavar Qashqai
 
Moment curvature analysis unconfined concrete section with different tension...
Moment curvature analysis unconfined concrete section  with different tension...Moment curvature analysis unconfined concrete section  with different tension...
Moment curvature analysis unconfined concrete section with different tension...
Salar Delavar Qashqai
 
Optimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductilityOptimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductility
Salar Delavar Qashqai
 
Import data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programming
Salar Delavar Qashqai
 
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
Salar Delavar Qashqai
 
Structural eigen value analysis in c programming
Structural eigen value analysis in c programmingStructural eigen value analysis in c programming
Structural eigen value analysis in c programming
Salar Delavar Qashqai
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Salar Delavar Qashqai
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Salar Delavar Qashqai
 
Moment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlabMoment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlab
Salar Delavar Qashqai
 
Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...
Salar Delavar Qashqai
 
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
 
Pushover analysis of simply support concrete section beam subjected to increm...
Pushover analysis of simply support concrete section beam subjected to increm...Pushover analysis of simply support concrete section beam subjected to increm...
Pushover analysis of simply support concrete section beam subjected to increm...
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
 
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 ...
 
Pushover analysis of simply support concrete section beam subjected to increm...
Pushover analysis of simply support concrete section beam subjected to increm...Pushover analysis of simply support concrete section beam subjected to increm...
Pushover analysis of simply support concrete section beam subjected to increm...
 

Recently uploaded

原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
MiscAnnoy1
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
171ticu
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
shahdabdulbaset
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
Madan Karki
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
GauravCar
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
TaghreedAltamimi
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 

Recently uploaded (20)

原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Introduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptxIntroduction to AI Safety (public presentation).pptx
Introduction to AI Safety (public presentation).pptx
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样官方认证美国密歇根州立大学毕业证学位证书原版一模一样
官方认证美国密歇根州立大学毕业证学位证书原版一模一样
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Hematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood CountHematology Analyzer Machine - Complete Blood Count
Hematology Analyzer Machine - Complete Blood Count
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Seminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptxSeminar on Distillation study-mafia.pptx
Seminar on Distillation study-mafia.pptx
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
artificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptxartificial intelligence and data science contents.pptx
artificial intelligence and data science contents.pptx
 
Software Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.pptSoftware Quality Assurance-se412-v11.ppt
Software Quality Assurance-se412-v11.ppt
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 

Geometric and material nonlinearity analysis of 2 d truss with force and ductility damage index control in c programming

  • 1. >> IN THE NAME OF GOD << Geometric and Material Nonlinearity Analysis of 2D Truss with Force and Ductility Damage Index Control in C programming C program is written by Salar Delavar Qashqai – Publication Date: 12/April/2021 E-mail: salar.d.ghashghaei@gmail.com
  • 2. C Code: #include <stdio.h> #include <windows.h> // text color #include <conio.h> #define N 10000 // number of increment #define NN 5 // number of degree of freedom #define Ne 6 // number of element #define ShowText01 "PushoverNonlinear2DTrussFCGNDI-inputDATA.csv" #define ShowText02 "PushoverNonlinear2DTrussFCGNDI-inputELEPROP.csv" #define ShowText03 "Output data is written in Text, Excel, Matlab and Html file" #define ShowText04 "PushoverNonlinear2DTrussFCGNDI-outputEXCEL.csv" #define ShowText05 "PushoverNonlinear2DTrussFCGNDI-outputHTML.html" #define ShowText06 "PushoverNonlinear2DTrussFCGNDI-outputTEXT.txt" #define ShowText07 "PushoverNonlinear2DTrussFCGNDI-outputMATLAB.m" #define ShowText08 "Graph-outputHTML.html" void IMPORT_FILE01(double &Length,double &Height,double Force[],double &Fini,int &itermax,double &tolerance,double &DI); void IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int &n); void SLOPE(double D1[],double F1[],double D2[],double F2[],double D3[],double F3[],double D4[],double F4[],double E1[],double E2[],double E3[],double E4[],int kn); void MessageInitialData(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double DI,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n); void MatrixAssembled(double [Ne][4][4],double [][NN]); void MatrixDetermination(double [][NN],int ); void MatrixInverse(double [][NN], double [][NN],int ); void MatrixMulti01(double [][NN], double [], double [], double [],int ); void MatrixMulti02(double [][NN], double [], double [], double [],int ); double ABS(double ); double MAX_ABS(double [],int ); double SQRT2(double ); void ElementInternalForce(double EA[],double es[],double ele_f[]); void ElementStiffness(int n,double Length,double Height,double es[],double u[],double D1[],double D2[],double D3[],double D4[],double E1[],double E2[],double E3[],double E4[],double F1[],double F2[],double F3[],double F4[],double A[],double EA[],double k[][4][4],double G[]); void MessageCheck_IMPORT_FILE01(double ,double ,int ,double,double ); void MessageCheck_IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n); void MessageErrorReportTEXT(); void MessageAnalysisReportTEXT(); void MessageInputDataTEXT(); void MessageNotConverge(int ,int ); void MessageConverge(int ,int ,double [],double []); void OUTPUT_text(int zMAX,int I[],int IT[],double reaction[],double DISP[][NN],double eleF[][Ne]); void OUTPUT_matlab(int zMAX,double reaction[],double DISP[][NN]); void OUTPUT_excel(int zMAX,int I[],double DISP[][NN],double eleF[][Ne],double reaction[]); void OUTPUT_html(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int zMAX,int I[],double DISP[][5],double eleF[][6],double reaction[],double DI); void Distance(int ); double MAX(double A[],int n); void SHOW_INITAL_REPORT_TEXT(); void ANALYSIS(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int kn,int m,double DI); void textcolor(int ForgC); void DATE_TIME(); void BILINEAR_CURVE(double A[],double B[],int M); void OUTPUT_HTML_GRAPH(double DISP[][5],double reaction[],int n); int main(){ int itermax,kn,m; double Length,Height,Force[5],Fini,residual,tolerance,DI; double F1[Ne],D1[Ne],F2[Ne],D2[Ne],F3[Ne],D3[Ne],F4[Ne],D4[Ne],A[Ne]; IMPORT_FILE01(Length,Height,Force,Fini,itermax,tolerance,DI); MessageCheck_IMPORT_FILE01(Length,Height,itermax,tolerance,DI); m = ABS(Fini)/ABS(Force[1]) +1; IMPORT_FILE02(F1,D1,F2,D2,F3,D3,F4,D4,A,kn); MessageCheck_IMPORT_FILE02(F1,D1,F2,D2,F3,D3,F4,D4,A,kn); textcolor(11); MessageInitialData(Length,Height,Force,Fini,itermax,tolerance,m,DI,F1,D1,F2,D2,F3,D3,F4,D4,A,kn); textcolor(14); MessageAnalysisReportTEXT(); ANALYSIS(Length,Height,Force,Fini,itermax,tolerance,F1,D1,F2,D2,F3,D3,F4,D4,A,kn,m,DI); getch(); return 0; } void IMPORT_FILE01(double &Length,double &Height,double Force[],double &Fini,int &itermax,double &tolerance,double &DI){ double Import_Data[11]; 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 < N && 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]; Height=Import_Data[1]; Force[0]=Import_Data[2]; Force[1]=Import_Data[3]; Force[2]=Import_Data[4]; Force[3]=Import_Data[5]; Force[4]=Import_Data[6]; Fini=Import_Data[7]; itermax=Import_Data[8]; tolerance=Import_Data[9]; DI=Import_Data[10]; } void IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],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,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&D1[i],&F1[i],&D2[i],&F2[i],&D3[i],&F3[i],&D4[i],&F4[i],&A[i]); i++; } while(i < N && fgets(line,sizeof(line),InputFile) != NULL); n = i-1; //printf("%dn",n); } void MessageInitialData(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double DI,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n){ 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<80;i++) printf("%c",Qb); printf("%cn",Qc); printf("tttt%c >>IN THE NAME OF GOD << %cn",Qf,Qf); printf("tttt%c Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control %cn",Qf,Qf); printf("tttt%c and Ductility Damage Index Control. %cn",Qf,Qf); printf("tttt%c UNIT: Free Unit %cn",Qf,Qf); printf("tttt%c",Qg); for (i=1;i<80;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<80;i++) printf("%c",Qb); printf("%cn",Qe); MessageInputDataTEXT(); printf(" Length of truss structure: %.3en",Length); printf(" Height of truss structure: %.3en",Height); printf(" External force [DOF(3)]: %.3en",Force[0]); printf(" External force [DOF(5)]: %.3en",Force[1]); printf(" External force [DOF(6)]: %.3en",Force[2]); printf(" External force [DOF(7)]: %.3en",Force[3]); printf(" External force [DOF(8)]: %.3en",Force[4]); printf(" Ultimate external force [DOF(5)]: %.3en",Fini); printf(" Maximum number of iterations: %.3en",itermax);// maximum number of iterations printf(" Specified tolerance for convergence: %.3en",tolerance);// specified tolerance for convergence printf(" Number of increments: %dn",M); printf(" Ductility Damage Index: %.3enn",DI); printf(" "); for(i=0;i<125;i++) printf("="); printf("n"); printf(" Strain01 Stress01 Strain02 Stress02 Strain03 Stress03 Strain04 Stress04 Element Arean"); printf(" "); for(i=0;i<125;i++) printf("="); printf("n"); for(i=0;i<n;i++) printf(" Element[%d]: %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3e %.3en",i+1,D1[i],F1[i],D2[i],F2[i],D3[i],F3[i],D4[i],F4[i],A[i]); printf(" "); for(i=0;i<125;i++) printf("="); printf("n"); } 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++){
  • 3. 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 MatrixMulti01(double A[][NN], double B[], double C[], double D[],int n){ int i,j; double ff; // [f] =[Ktot] - [u] - [F] for (i=0; i<n; i++){ ff=0; for (j=0; j<n; j++) ff += A[i][j]*B[j]; D[i] = ff-C[i]; } } void MatrixMulti02(double A[][NN], double B[], double C[], double D[],int n){ int i,j; double Dx; // [du] =[InvKinit] *[f] for (i=0; i<n; i++){ Dx=0; for (j=0; j<n; j++) Dx += A[i][j]* -B[j]; C[i]=Dx; D[i] += C[i];// u= u+du } } void ElementInternalForce(double EA[],double es[],double ele_f[]){ for (int I=0; I<6;I++) ele_f[I] = EA[I]*(es[I]+.5*es[I]*es[I]); } void ElementStiffness(int n,double Length,double Height,double es[],double u[],double D1[],double D2[],double D3[],double D4[],double E1[],double E2[],double E3[],double E4[],double F1[],double F2[],double F3[],double F4[],double A[],double EA[],double k[][4][4],double G[]){ double x1,y1,x2,y2,x3,y3,x4,y4,L[6],Lpr[Ne],lanX[Ne],lanY[Ne],lanxx[Ne],lanxy[Ne],lanyy[Ne]; int i; Lpr[0]=Length;Lpr[1]=Height; Lpr[2]=SQRT2(Length*Length+Height*Height);Lpr[3]=SQRT2(Length*Length+Height*Height); Lpr[4]=Height;Lpr[5]=Length; x1=0;y1=0; x2=Length+u[0];y2=0; x3=u[1];y3=Height+u[2]; x4=Length+u[3];y4=Height+u[4]; L[0]=SQRT2((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); L[1]=SQRT2((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)); L[2]=SQRT2((x4-x1)*(x4-x1)+(y4-y1)*(y4-y1)); L[3]=SQRT2((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2)); L[4]=SQRT2((x4-x2)*(x4-x2)+(y4-y2)*(y4-y2)); L[5]=SQRT2((x4-x3)*(x4-x3)+(y4-y3)*(y4-y3)); lanX[0]=(x2-x1)/L[0];lanY[0]=(y2-y1)/L[0]; lanX[1]=(x3-x1)/L[1];lanY[1]=(y3-y1)/L[1]; lanX[2]=(x4-x1)/L[2];lanY[2]=(y4-y1)/L[2]; lanX[3]=(x3-x2)/L[3];lanY[3]=(y3-y2)/L[3]; lanX[4]=(x4-x2)/L[4];lanY[4]=(y4-y2)/L[4]; lanX[5]=(x4-x3)/L[5];lanY[5]=(y4-y3)/L[5]; for (i=0;i<n;i++){ es[i]=(L[i]-Lpr[i])/Lpr[i]; if (ABS(es[i])>= 0 && ABS(es[i])<= D1[i]) EA[i] = E1[i]*A[i]; else if (ABS(es[i])> D1[i] && ABS(es[i])<= D2[i]) EA[i] = ((F1[i]+E2[i]*(ABS(es[i])-D1[i]))/ABS(es[i]))*A[i]; else if (ABS(es[i])> D2[i] && ABS(es[i])<= D3[i]) EA[i] = ((F2[i]+E3[i]*(ABS(es[i])-D2[i]))/ABS(es[i]))*A[i]; else if (ABS(es[i])> D3[i] && ABS(es[i])<= D4[i]) EA[i] = ((F3[i]+E4[i]*(ABS(es[i])-D3[i]))/ABS(es[i]))*A[i]; else EA[i] =0; // Element G[i] = EA[i]/L[i];lanxx[i]=lanX[i]*lanX[i];lanxy[i]=lanX[i]*lanY[i];lanyy[i]=lanY[i]*lanY[i]; k[i][0][0]=G[i]*lanxx[i];k[i][0][1]=G[i]*lanxy[i];k[i][0][2]=-G[i]*lanxx[i];k[i][0][3]=-G[i]*lanxy[i]; k[i][1][0]=G[i]*lanxy[i];k[i][1][1]=G[i]*lanyy[i];k[i][1][2]=-G[i]*lanxy[i];k[i][1][3]=-G[i]*lanyy[i]; k[i][2][0]=-G[i]*lanxx[i];k[i][2][1]=-G[i]*lanxy[i];k[i][2][2]=G[i]*lanxx[i];k[i][2][3]=G[i]*lanxy[i]; k[i][3][0]=-G[i]*lanxy[i];k[i][3][1]=-G[i]*lanyy[i];k[i][3][2]=G[i]*lanxy[i];k[i][3][3]=G[i]*lanyy[i]; } } void MatrixAssembled(double k[Ne][4][4],double K[][NN]){ K[0][0]= k[0][2][2]+k[3][0][0]+k[4][0][0]; K[0][1]= k[3][0][2]; K[0][2]= k[3][0][3]; K[0][3]= k[4][0][2]; K[0][4]= k[4][0][3]; K[1][0]= k[3][2][0]; K[1][1]= k[1][2][2]+k[3][2][2]+k[5][0][0]; K[1][2]= k[1][2][3]+k[3][2][3]+k[5][0][1]; K[1][3]= k[5][0][2]; K[1][4]= k[5][0][3]; K[2][0]= k[3][3][0]; K[2][1]= k[1][3][2]+k[3][3][2]+k[5][1][0]; K[2][2]= k[1][3][3]+k[3][3][3]+k[5][1][1]; K[2][3]= k[5][1][2]; K[2][4]= k[5][1][3]; K[3][0]= k[4][2][0]; K[3][1]= k[5][2][0]; K[3][2]= k[4][2][1]; K[3][3]= k[2][2][2]+k[4][2][2]+k[5][2][2]; K[3][4]= k[2][2][3]+k[4][2][3]+k[5][2][3]; K[4][0]= k[4][3][0]; K[4][1]= k[5][3][0]; K[4][2]= k[5][3][1]; K[4][3]= k[2][2][2]+k[4][3][2]+k[5][3][2]; K[4][4]= k[2][3][3]+k[4][3][3]+k[5][3][3]; } 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"); } 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; } } double ABS(double B){ if (B < 0) B = -B;//Absolute number else B = B; return B; } void OUTPUT_text(int zMAX,int I[],int IT[],double reaction[],double DISP[][5],double eleF[][6]){ // TEXT OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText06, "w"); fprintf(OutputFile,"ttttt ___________________________________________________________________________________________________________________n"); fprintf(OutputFile,"ttttt | >> IN THE NAME OF GOD << |n"); fprintf(OutputFile,"ttttt | Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control. |n"); fprintf(OutputFile,"ttttt |___________________________________________________________________________________________________________________|n"); fprintf(OutputFile,"ttttt | Unit: Free unit |n"); fprintf(OutputFile,"ttttt | Newton-Raphson Method : Tangent procedure |n"); fprintf(OutputFile,"ttttt |___________________________________________________________________________________________________________________|n"); fprintf(OutputFile,"ttttt | Program is written by Salar Delavar Ghashghaei |n"); fprintf(OutputFile,"ttttt | E-mail: salar.d.ghashghaei@gmail.com |n"); fprintf(OutputFile,"ttttt |___________________________________________________________________________________________________________________|n"); fprintf(OutputFile," "); for (i=1;i<=145;i++) fprintf(OutputFile,"-"); fprintf(OutputFile,"n"); fprintf(OutputFile," Increment Iteration Reaction Disp.[DOF(3)] Disp.[DOF(5)] Disp.[DOF(6)] Disp.[DOF(7)] Disp.[DOF(8)] n"); fprintf(OutputFile," "); for (i=1;i<=145;i++) fprintf(OutputFile,"-"); fprintf(OutputFile,"n"); for (i=0;i<zMAX;i++) fprintf(OutputFile,"t%dt %d %e %e %e %e %e %en",I[i]+1,IT[i],reaction[i],DISP[i][0],DISP[i][1],DISP[i][2],DISP[i][3],DISP[i][4]); fprintf(OutputFile," "); for (i=1;i<=140;i++) fprintf(OutputFile,"-"); fprintf(OutputFile,"n"); fprintf(OutputFile," Increment Axial Force-Ele(1) Axial Force-Ele(2) Axial Force-Ele(3) Axial Force-Ele(4) Axial Force-Ele(5) Axial Force-Ele(6) n"); fprintf(OutputFile," "); for (i=1;i<=140;i++)
  • 4. fprintf(OutputFile,"-"); fprintf(OutputFile,"n"); for (i=0;i<zMAX;i++) fprintf(OutputFile,"t%dt %e %e %e %e %e %en",I[i]+1,eleF[i][0],eleF[i][1],eleF[i][2],eleF[i][3],eleF[i][4],eleF[i][5]); fclose(OutputFile); } void OUTPUT_matlab(int zMAX,double reaction[],double DISP[][5]){ // MATLAB OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText07, "w"); fprintf(OutputFile," %% Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control. %%n"); fprintf(OutputFile,"BaseShear=[0n"); for(i=0;i<zMAX;i++) fprintf(OutputFile,"%en",reaction[i]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"Displacement=[0n"); for(i=0;i<zMAX;i++) fprintf(OutputFile,"%en",DISP[i][1]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"figure(1)n"); fprintf(OutputFile,"plot(Displacement,BaseShear,'LineWidth',3);n"); fprintf(OutputFile,"title(['#BASESHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n"); fprintf(OutputFile,"legend('C++','Location','NorthEastOutside');n"); fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(5)]');ylabel('BASESHEAR [DOF(1)]');grid on;n"); fclose(OutputFile); } void OUTPUT_excel(int zMAX,int I[],double DISP[][5],double eleF[][6],double reaction[]){ // EXCEL OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText04, "w"); fprintf(OutputFile," ### Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control ###n"); fprintf(OutputFile,"Increment,Base Shear [DOF(1)],Displacement [DOF(3)],Displacement [DOF(5)],Displacement [DOF(6)],Displacement [DOF(7)],Displacement [DOF(8)],Axial Force-Ele(1),Axial Force-Ele(2),Axial Force-Ele(3),Axial Force-Ele(4),Axial Force-Ele(5),Axial Force-Ele(6)n"); for(i=0;i<zMAX;i++) fprintf(OutputFile,"%d,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%e,%en",I[i]+1,reaction[i],DISP[i][0],DISP[i][1],DISP[i][2],DISP[i][3],DISP[i][4],eleF[i][0],eleF[i][1],eleF[i][2],eleF[i][3],eleF[i][4],eleF[i][5]); fclose(OutputFile); } void OUTPUT_html(double Length,double Height,double Force[],double Fini,int itermax,double tolerance,int M,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int zMAX,int I[],double DISP[][5],double eleF[][6],double reaction[],double DI){ // HTML OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText05, "w"); fprintf(OutputFile,"<html> <body bgcolor="green">n"); // IMPORT IMAGE fprintf(OutputFile,"<img src="PushoverNonlinear2DTrussFCGNDI-image01.png" style="width:1000px ; height:500px" alt="analysis01"><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,"<th bgcolor="cyan"> Geometric and Material Nonlinearity Analysis of 2D Truss with Force Control and Ductility Damage Index Control. - 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">Length of truss structure: </th><th> %.3e </th> </tr>n",Length); fprintf(OutputFile,"<tr> <th bgcolor="orange">Height of truss structure: </th><th> %.3e </th> </tr>n",Height); fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(3)]: </th><th> %.3e </th> </tr>n",Force[0]); fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(5)]: </th><th> %.3e </th> </tr>n",Force[1]); fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(6)]: </th><th> %.3e </th> </tr>n",Force[2]); fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(7)]: </th><th> %.3e </th> </tr>n",Force[3]); fprintf(OutputFile,"<tr> <th bgcolor="orange">External force [DOF(8)]: </th><th> %.3e </th> </tr>n",Force[4]); fprintf(OutputFile,"<tr> <th bgcolor="orange">Ultimate external force [DOF(5)]: </th><th> %.3e </th> </tr>n",Fini); fprintf(OutputFile,"<tr> <th bgcolor="orange">Number of increments: </th><th> %d </th> </tr>n",M); fprintf(OutputFile,"<tr> <th bgcolor="orange">Maximum number of iterations: </th><th> %d </th> </tr>n",itermax); fprintf(OutputFile,"<tr> <th bgcolor="orange">Specified tolerance for convergence: </th><th> %.3e </th> </tr>n",tolerance); fprintf(OutputFile,"<tr> <th bgcolor="orange">Ductility Damage Index: </th><th> %.3e </th> </tr>n",DI); // TABLE 2 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th colspan="10" bgcolor="orange"> Elements Strain-Stress </th> <tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange"> Element Number </th> <th bgcolor="orange">Strain [1]</th> <th bgcolor="orange">Stress [1]</th><th bgcolor="orange">Strain [2]</th><th bgcolor="orange">Stress [2]</th><th bgcolor="orange">Strain [3]</th><th bgcolor="orange">Stress [3]</th><th bgcolor="orange">Strain [4]</th> <th bgcolor="orange">Stress [4]</th><th bgcolor="orange">Section Area </th></tr>n"); for(i=0;i<6;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><td align ="center"> %.3e </td><td align ="center"> %.3e </td><td align ="center"> %.3e </td></td> </tr>n",i+1,D1[i],F1[i],D2[i],F2[i],D3[i],F3[i],D4[i],F4[i],A[i]); } // TABLE 3 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">Displacement [DOF(3)]</th> <th bgcolor="orange">Displacement [DOF(5)]</th><th bgcolor="orange">Displacement [DOF(6)]</th><th bgcolor="orange">Displacement [DOF(7)]</th><th bgcolor="orange">Displacement [DOF(8)]</th></tr>n"); for(i=0;i<zMAX;i++){ fprintf(OutputFile,"<tr> <td align ="center"> %d </td> <td align ="center"> %.3e </td> </td> <td align ="center"> %.3e </td></td> <td align ="center"> %.3e </td></td> <td align ="center"> %.3e </td></td> <td align ="center"> %.3e </td></tr>n",i+1,DISP[i][0],DISP[i][1],DISP[i][2],DISP[i][3],DISP[i][4]); } // TABLE 4 fprintf(OutputFile,"<table style=”width:100%” border="1px" width="1000px" height="120px" bgcolor="yellow">n"); fprintf(OutputFile,"<tr><th colspan="10" bgcolor="orange"> Structral Element Internal Forces </th> </tr>n"); fprintf(OutputFile,"<tr> <th bgcolor="orange"> Increment </th> <th bgcolor="orange">Base Shear [DOF(1)]</th> <th bgcolor="orange">Axial Force-Ele(1)</th> <th bgcolor="orange">Axial Force-Ele(2)</th> <th bgcolor="orange">Axial Force-Ele(3)</th> <th bgcolor="orange">Axial Force-Ele(4)</th> <th bgcolor="orange">Axial Force-Ele(5)</th> <th bgcolor="orange">Axial Force-Ele(6)</th></tr>n"); for(i=0;i<zMAX;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> <td align ="center"> %.3e </td></tr>n",i+1,reaction[i],eleF[i][0],eleF[i][1],eleF[i][2],eleF[i][3],eleF[i][4],eleF[i][5]); } fprintf(OutputFile,"</table></body></html>n"); fclose(OutputFile); } 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 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 MessageCheck_IMPORT_FILE01(double Length,double Height,int itermax,double tolerance,double DI){ if ( Length <0 || Height <0 || itermax < 0 || tolerance<0 ){ MessageErrorReportTEXT(); printf(" Please check this file! ->[%s]n",ShowText01); printf(" *** Negative data input value is not acceptable ***n"); printf(" Truss length: %fn",Length); printf(" Truss height: %fn",Height); printf(" Maximum iteration: %dn",itermax); printf(" Tolerance: %.3en",tolerance); printf(" Damage Index: %.3en",DI); Sleep(40000); exit(1); } } void MessageCheck_IMPORT_FILE02(double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int n){ int i; for (i=0;i<n;i++){ if (F1[i] <= 0 || D1[i] <= 0 || F2[i] <= 0 || D2[i] <= 0 || F3[i] <= 0 || D3[i] <=0 || F4[i] <=0 || D4[i] <= 0 || A[i] <= 0){ MessageErrorReportTEXT(); printf(" Please check this file! ->[%s]n",ShowText02); printf(" *** Negative data input value is not acceptable ***n"); printf(" Row %d has a negative value.n",i+1); printf(" Strain-1 [%d]: %fn",i,D1[i]); printf(" Stress-1 [%d]: %fn",i,F1[i]); printf(" Strain-2 [%d]: %fn",i,D2[i]); printf(" Stress-2 [%d]: %fn",i,F2[i]); printf(" Strain-3 [%d]: %fn",i,D3[i]); printf(" Stress-3 [%d]: %fn",i,F3[i]); printf(" Strain-4 [%d]: %fn",i,D4[i]); printf(" Stress-4 [%d]: %fn",i,F4[i]); printf(" Section area [%d]: %fn",i,A[i]); Sleep(40000); exit(1); } } } void MessageNotConverge(int ii,int iit){ Distance(ii+1); printf("%dt %d -> ## This step is not converged ##n",ii+1,iit); } void MessageConverge(int ii,int iit,double A[],double B[]){ Distance(ii+1); printf("%dt %d %.3e %.3e %.3e %.3e %.3e %.3en",ii+1,iit,B[ii],A[0],A[1],A[2],A[3],A[4]); } void Distance(int i){ if (i < 10) printf("t"); 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"); } double MAX(double A[],int n){ int i; double Amax; Amax = A[0];
  • 5. for (i=1;i<n;i++){ if (Amax < A[i]) Amax=A[i]; } return Amax;//Maximum DATA } void SLOPE(double D1[],double F1[],double D2[],double F2[],double D3[],double F3[],double D4[],double F4[],double E1[],double E2[],double E3[],double E4[],int kn){ for (int i=0;i<kn;i++){ E1[i]=(F1[i]-0)/(D1[i]-0); E2[i]=(F2[i]-F1[i])/(D2[i]-D1[i]); E3[i]=(F3[i]-F2[i])/(D3[i]-D2[i]); E4[i]=(F4[i]-F3[i])/(D4[i]-D3[i]); //printf("E4: %fn",E4[i]); } } void SHOW_INITAL_REPORT_TEXT(){ int i; printf(" "); for (i=1;i<=145;i++) printf("-"); printf("n"); printf(" Increment Iteration Reaction Disp.[DOF(3)] Disp.[DOF(5)] Disp.[DOF(6)] Disp.[DOF(7)] Disp.[DOF(8)] n"); printf(" "); for (i=1;i<=145;i++) printf("-"); printf("n"); } 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 Height,double Force[],double Fini,int itermax,double tolerance,double F1[],double D1[],double F2[],double D2[],double F3[],double D3[],double F4[],double D4[],double A[],int kn,int m,double DI){ int i,it,zz,zMAX,well_done; double residual; double EA[Ne],G[Ne],lanX[Ne],lanY[Ne],ele_force[Ne],es[Ne],strain[Ne]; double k[Ne][4][4],u[NN],F[NN],Ktot[NN][NN],Kt[NN][NN],InvKtot[NN][NN],f[NN],du[NN]; double E1[10],E2[10],E3[10],E4[10]; double *reaction= new double [N]; double *DU= new double [N]; int *I= new int [N]; int *IT= new int [N]; double *DISP_DOF_5 = new double [N]; double DISP[N][5],eleF[N][Ne]; SLOPE(D1,F1,D2,F2,D3,F3,D4,F4,E1,E2,E3,E4,kn); F[0]=Force[0];F[2]=Force[2];F[3]=Force[3];F[4]=Force[4]; SHOW_INITAL_REPORT_TEXT(); for (zz=0;zz <= m || well_done !=1;zz++){ F[1] =Force[1]*(zz+1);// Define the applied load ElementStiffness(Ne,Length,Height,es,u,D1,D2,D3,D4,E1,E2,E3,E4,F1,F2,F3,F4,A,EA,k,G); // Total Stiffness MatrixAssembled(k,Ktot); // Inverse [Ktot] MatrixInverse(Ktot,InvKtot,NN); it = 0; // initialize iteration count residual = 100; // initialize residual while (residual > tolerance){ ElementStiffness(Ne,Length,Height,es,u,D1,D2,D3,D4,E1,E2,E3,E4,F1,F2,F3,F4,A,EA,k,G); MatrixAssembled(k,Kt); // Finding the determinant of a square matrix MatrixDetermination(Kt,NN); // [f] =[Kt] - [u] - [F] MatrixMulti01(Kt,u,F,f,NN); // [du] =[InvKtot] * [f] MatrixMulti02(InvKtot,f,du,u,NN); // Max residual residual = MAX_ABS(du,NN); it += 1; // increment iteration count if (it == itermax){ MessageNotConverge(zz,it); break; } } // while // Force and Dispalcement for each increment reaction[zz] = Force[1]*(zz+1) + Force[0] + Force[3]; DISP_DOF_5[zz] = u[1]; DU[zz]=residual;I[zz]=zz;IT[zz]=it; // iteration control if (it < itermax) MessageConverge(zz,it,u,reaction); zMAX = zz+1; // Internal force of each element ElementInternalForce(EA,es,ele_force); // Internal force and displacement of each increment for (i=0;i<Ne;i++){ eleF[zz][i] = ele_force[i]; DISP[zz][i] = u[i]; } for (i=0;i<Ne;i++){ // Control Strain Damage Index. strain[i] = DI*(D4[i]-D1[i])+D1[i]; // printf("tt DI strain[%d]: %.3e - ele. strain[%d]: %.3e n",i+1,strain[i],i+1,es[i]); if (ABS(es[i]) >= ABS(strain[i])){ printf("n ## Strain in element[%d]: %.3e reached to Strain Damage Index: %.3e ##nn",i+1,es[i],strain[i]); well_done = 1; } if (well_done ==1) break; } if (ABS(u[0]) >= Fini){ printf("n ## External force [DOF(5)] reached to ultimate force ##nn"); well_done = 1; break; } if (ABS(reaction[zz]) >= Fini){ printf("n ## External force [DOF(5)] reached to ultimate force ##nn"); well_done = 1; break; } }// for - force increment if (well_done ==1 ){ if (zMAX >= 25) BILINEAR_CURVE(DISP_DOF_5,reaction,zMAX); OUTPUT_text(zMAX,I,IT,reaction,DISP,eleF); OUTPUT_matlab(zMAX,reaction,DISP); OUTPUT_excel(zMAX,I,DISP,eleF,reaction); OUTPUT_html(Length,Height,Force,Fini,itermax,tolerance,m,D1,F1,D2,F2,D3,F3,D4,F4,A,zMAX,I,DISP,eleF,reaction,DI); OUTPUT_HTML_GRAPH(DISP,reaction,zMAX); textcolor(15); printf("na - %s -",ShowText03); system("start /w Graph-outputHTML.html"); DATE_TIME(); } } void DATE_TIME(){ printf("nt"); system("echo %date%"); printf("t"); system("echo %time%"); } void MessageAnalysisReportTEXT(){ int i; char Ql; Ql=176; printf("an "); for (i=1;i<64;i++) printf("%c",Ql); printf(" Analysis Report "); for (i=1;i<64;i++) printf("%c",Ql); printf("n"); } void BILINEAR_CURVE(double A[],double B[],int M){ double AaSUM=0,B_max=0,k0; int I,Mmax; double *AA = (double *) malloc(N); double *BB = (double *) malloc(N); double C[6]; for (I=0;I<6;I++); C[I] =0; Mmax=0; for (I=0;I<M;I++){ if (ABS(B_max) < ABS(B[I])){ B_max = ABS(B[I]); Mmax =I; }//if }//for Mmax =I; for (I=0;I<Mmax;I++){ AA[I+1]=ABS(A[I]); BB[I+1]=ABS(B[I]); } for (I=0;I<Mmax;I++){ // Mmax-1 AaSUM += ((BB[I]+BB[I+1])*0.5*(AA[I+1]-AA[I]));; } C[1]=0;// C[0]=D_y ; C[1]=D_u ; C[2]=F_y ; C[3]=F_u ; C[4]=SC ; C[5]=OF ; B_max=0; for (I=0;I<Mmax+1;I++){ // find max if(C[1] < AA[I]) C[1]=AA[I]; if(B_max < BB[I]) B_max =BB[I]; } C[3]=BB[I-1];//printf("t %fn",C[3]); k0 =BB[4]/AA[4];//printf("t %fn",k0); C[0] = (C[3]*C[1]*0.5-AaSUM)/(C[3]*0.5 - k0*C[1]*0.5);//printf("t %fn",C[0]);
  • 6. C[2] = k0*C[0]; C[4]=C[1]/C[0];C[5]=C[3]/C[2]; printf("n Structure ductility ratio: %.5en",C[4]); printf(" Structure over strength factor: %.5enn",C[5]); printf(" ================================n"); printf(" = Bilinear curve fitted =n"); printf(" = Displacaement Reaction =n"); printf(" = DOF[5] DOF[1] =n"); printf(" ================================n"); printf(" 0 0 n"); printf("t %.3et%.3en",C[0],C[2]); printf("t %.3et%.3en",C[1],C[3]); printf(" ================================nn"); } double MAX_ABS(double A[],int n){ int i; double B[N]; double Amax; // abs value for (i=0;i<n;i++){ B[i] = A[i]; if(B[i] <0) B[i] = -B[i]; } // Max of abs Amax = B[0]; for (i=1;i<n;i++){ if(Amax < B[i]) Amax = B[i]; } return Amax; } void OUTPUT_HTML_GRAPH(double DISP[][5],double reaction[],int n){ // HTML GRAPH OUTPUT int i; double x,y,X[N],Y[N],Xnew[N],Ynew[N],NorX[N],NorY[N],Xmax,Ymax; for (i=0;i<n;i++){ X[i] = ABS(DISP[i][1]); Y[i] = ABS(reaction[i]); } 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] = X[i]; Ynew[i+1] = 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(ShowText08, "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="60px serif";s4.fillStyle = "#7fff00";s4.fillText("Base Shear-Disp. Graph",0,0); n"); 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("Base Shear [DOF(1)]",0,0);s4.restore(); n"); 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("Displacement [DOF(5)]",0,0);s4.restore(); n"); 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); }
  • 10. Figure(4) Input Elemenets Strain-Stress Data