SlideShare a Scribd company logo
>> IN THE NAME OF GOD <
Geometric Nonlinearity Analysis of Springs with Rigid Element Displacement Control
Large Deformation Formulated in C programming
C program is written by Salar Delavar Ghashghaei – Publication Date: 18/November/2019
E-mail: salar.d.ghashghaei@gmail.com
-4.00E+03
-3.00E+03
-2.00E+03
-1.00E+03
0.00E+00
1.00E+03
2.00E+03
3.00E+03
4.00E+03
0.00E+00 2.00E+01 4.00E+01 6.00E+01 8.00E+01 1.00E+02 1.20E+02
BaseShear
Displacement
Geometric and Material Nonlinearity Analysis of Springs
C Code:#include <stdio.h>
#include <windows.h> // text color
#include <conio.h>
#define N 10000
#define S01 " >> IN THE NAME OF GOD << "
#define S02 " Geometric and Material Nonlinearity Analysis of Springs with Displacement Control "
#define S03 " UNIT: Free Unit "
#define S04 " This program is written by Salar Delavar Ghashghaei "
#define S05 " E-mail: salar.d.ghashghaei@gmail.com "
#define ShowText01 "ConnectionProblemDCStrain-inputDATA.csv"
#define ShowText02 "ConnectionProblemDCStrain-inputSPRING.csv"
#define ShowText03 "ConnectionProblemDCStrain-outputEXCEL.csv"
#define ShowText04 "ConnectionProblemDCStrain-outputMATLAB.m"
void IMPORT_DATA01(double Import_Data[]);
void IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int &k);
void MessageNegative_IMPORT_DATA01(double Import_Data[]);
void MessageNegative_IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n);
void MessageInputDataTEXT();
void MessageAnalysisReportTEXT();
void MessageErrorReportTEXT();
void MessageInitialData(double Import_Data[],int n);
void MessageStrainStressTEXT(double STARIN01[],double STRESS01[],double STARIN02[],double STRESS02[],int n);
void textcolor(int ForgC);
void Distance(int i);
void Element_Slope(double A[],double B[],double C[],int n);
void Element_Stiffness(double A[],double B[],double C[],double D[],double E[],double F[],double K[],int n,int m);
void ANALYSIS(double Import_Data[],double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n,int m);
void OUTPUT_excel(double A[],double B[],int n);
void OUTPUT_matlab(double A[],double B[],int n);
double ABS(double B);
double Horizental_Disp(double L,double &x,double y);
double SQRT2(double D);
int main(){
int k;
double Import_Data[10];
double STRAIN01[10];
double STRESS01[10];
double STRAIN02[10];
double STRESS02[10];
IMPORT_DATA01(Import_Data);
MessageNegative_IMPORT_DATA01(Import_Data);
IMPORT_DATA02(STRAIN01,STRESS01,STRAIN02,STRESS02,k);
MessageNegative_IMPORT_DATA02(STRAIN01,STRESS01,STRAIN02,STRESS02,k);
int m = 1 + ABS(Import_Data[9]/Import_Data[7]);
textcolor(10);
MessageInitialData(Import_Data,m);
MessageStrainStressTEXT(STRAIN01,STRESS01,STRAIN02,STRESS02,k);
textcolor(14);
ANALYSIS(Import_Data,STRAIN01,STRESS01,STRAIN02,STRESS02,k,m);
getch();
return 0;
}
void IMPORT_DATA01(double Import_Data[]){
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++;
}
}
void IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int &k){
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",&STRAIN01[i],&STRESS01[i],&STRAIN02[i],&STRESS02[i]);
//printf("%d - STRAIN01[%d]: %lf - STRESS01[%d]: %lf- STRAIN02[%d]: %lf - STRESS02[%d]: %lfn",i,i,STRAIN01[i],i,STRESS01[i],i,STRAIN02[i],i,STRESS02[i]);
i++;
}
while(i < N && fgets(line,sizeof(line),InputFile) != NULL);
k = i-1;
//printf("%dn",k);
}
void MessageNegative_IMPORT_DATA01(double Import_Data[]){
if ( Import_Data[0] < 0 || Import_Data[1] < 0 || Import_Data[2] < 0 || Import_Data[3] < 0 || Import_Data[4] < 0 || Import_Data[9] < 0){
MessageErrorReportTEXT();
printf(" Please check this file! -> [%s]n",ShowText01);
printf(" *** Negative data input value is not acceptable ***n");
printf(" Length of rigid element: %fn",Import_Data[0]);
printf(" Spring length 1: %fn",Import_Data[1]);
printf(" Spring length 2: %fn",Import_Data[2]);
printf(" Spring area 1: %fn",Import_Data[3]);
printf(" Spring area 2: %fn",Import_Data[4]);
printf(" External applied load in spring 1: %fn",Import_Data[5]);
printf(" External applied load in spring 2: %fn",Import_Data[6]);
printf(" Initial applied displacement: %fn",Import_Data[7]);
printf(" Distance of spring 1 from rigid element: %fn",Import_Data[8]);
printf(" Ultimate absolute displacement: %fn",Import_Data[9]);
Sleep(40000);
exit(1);
}
}
void MessageNegative_IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n){
int i;
for (i=0;i<n+1;i++){
if ( STRAIN01[i] < 0 || STRESS01[i] < 0 || STRAIN02[i] < 0 || STRESS02[i] < 0 ){
MessageErrorReportTEXT();
printf(" Please check this file! -> [%s]n",ShowText02);
printf(" Row %d has a negative value.n",i);
printf(" *** Negative data input value is not acceptable ***n");
printf(" Strain of spring 1: %fn",STRAIN01[i]);
printf(" Stress of spring 1: %fn",STRESS01[i]);
printf(" Strian of spring 2: %fn",STRAIN02[i]);
printf(" Stress of spring 2: %fn",STRESS02[i]);
Sleep(40000);
exit(1);
}
}
}
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 MessageErrorReportTEXT(){
int i;
char Ql;
Ql=176;
textcolor(12);
printf("an ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf(" Error Report ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf("n");
}
void MessageInputDataTEXT(){
int i;
char Ql=176;
printf("n ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf(" Input Data ");
for (i=1;i<50;i++)
printf("%c",Ql);
printf("n");
}
void MessageAnalysisReportTEXT(){
int i;
char Ql=176;
printf("n ");
for (i=1;i<47;i++)
printf("%c",Ql);
printf(" Analysis Report ");
for (i=1;i<47;i++)
printf("%c",Ql);
printf("n");
printf("nt ");
for (i=1;i<72;i++)
printf("-");
printf("n");
printf("t Increment Base Shear Incremental Displacement[DOF(1)] n");
printf("t ");
for (i=1;i<72;i++)
printf("-");
printf("n");
}
void Distance(int i){
if (i < 10)
printf("b");
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 ABS(double B){
if (B < 0)
B = -B;//Absolute number
else
B = B;
return B;
}
void Element_Slope(double A[],double B[],double C[],int n){
int i;
C[0]=B[0]/A[0];
//printf("%d - Rk[%d]: %fn",0,0,C[0]);
for (i=1;i<n;i++){
//cout<<i<<" - TET["<<i<<"]:"<<A[i]<<" - MOM["<<i<<"]:"<<B[i]<<endl;
C[i]=(B[i]-B[i-1])/(A[i]-A[i-1]);
//printf("%d - Strain[%d]: %f - Stress[%d]: %f - Rk[%d]: %fn",i,i,A[i],i,B[i],i,C[i]);
}
}
void Element_Stiffness(double A[],double B[],double C[],double D[],double E[],double F[],double K[],int n,int m){
int i;
if (ABS(D[n])>= 0 && ABS(D[n])<= A[0])
K[n] = (C[n]*E[n])/F[n];
for (i=0;i<m;i++){
if (ABS(D[n])> A[i] && ABS(D[n])<= A[i+1])
K[n] = ((B[i]+C[i+1]*(ABS(D[n])-A[i]))/ABS(D[n]))*E[n]/F[n];
}
if (ABS(D[n]) > A[m-1])
K[n] = 0;
}
void ANALYSIS(double Import_Data[],double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n,int m){
double L,Dx,a=0,Le[2],Area[2],Force[2],es[2],K[2],SLOPE01[10],SLOPE02[10],Dini,Dmax,Du,up;
int z,zMAX,well_done=0;
double output_u[N],output_base[N];
L = Import_Data[0];
Le[0] = Import_Data[1];
Le[1] = Import_Data[2];
Area[0] = Import_Data[3];
Area[1] = Import_Data[4];
Force[0] = Import_Data[5];
Force[1] = Import_Data[6];
Dini = Import_Data[7];
Du = Import_Data[8];
Dmax = Import_Data[9];
double F[2],Ay;
Element_Slope(STRAIN01,STRESS01,SLOPE01,n);
Element_Slope(STRAIN02,STRESS02,SLOPE02,n);
MessageAnalysisReportTEXT();
for (z=0;z<m;z++){
up = Dini*(z+1);// Define the applied Displacement
Horizental_Disp(L,Dx,up);
a = SQRT2(.5*up*.5*up + .5*Dx*.5*Dx);// spring strain 1 during analysis
es[0] = a/Le[0];
Element_Stiffness(STRAIN01,STRESS02,SLOPE01,es,Area,Le,K,0,n);
F[0] = (((L-Dx)/L)*((L-Dx)/L))*K[0]*0.5*up + Import_Data[5];
Ay = F[0];
//printf("t+ %f - %fn",es[0],F[0]);
if (ABS(up) >= Du){
es[1] = (Du-up)/Le[1];
Element_Stiffness(STRAIN02,STRESS02,SLOPE02,es,Area,Le,K,1,n);
F[1] = (((L-Dx)/L)*((L-Dx)/L))*K[1]*(Du-up) + Import_Data[6];
Ay = F[0] + F[1];
//printf("t= %f - %fn",es[1],F[1]);
}
//printf("t %f - %fn",up,Dx);
zMAX=z+1;
output_u[z]=up;
output_base[z]=Ay;
Distance(z);
printf("tt%dtt%ett%en",z+1,output_base[z],output_u[z]);
if (ABS(up) >= Dmax){
well_done = 1;
textcolor(13);
printf("ntt ## Increment displacement reach to ultimate displacement ##nn");
break;
}
}// for
if (well_done == 1){
OUTPUT_excel(output_u,output_base,zMAX);
OUTPUT_matlab(output_u,output_base,zMAX);
textcolor(15);
printf("na - Output data is written in Excel and Matlab file -");
}
}
void OUTPUT_matlab(double A[],double B[],int n){
// MATLAB OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText04, "w");
fprintf(OutputFile," %% Geometric and Material Nonlinearity Analysis of Springs with Displacement Control %%n");
fprintf(OutputFile,"disp_Dof1=[0n");
for(i=0;i<=n;i++)
fprintf(OutputFile,"%en",A[i]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"base_shear=[0n");
for(i=0;i<=n;i++)
fprintf(OutputFile,"%en",B[i]);
fprintf(OutputFile,"];nn");
fprintf(OutputFile,"figure(1)n");
fprintf(OutputFile,"plot(disp_Dof1,base_shear,'LineWidth',3);n");
fprintf(OutputFile,"title(['# BASE SHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n");
fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(1)]');ylabel('BASE SHEAR');grid on;n");
fclose(OutputFile);
}
void OUTPUT_excel(double A[],double B[],int n){
// EXCEL OUTPUT
int i;
FILE *OutputFile;
OutputFile = fopen(ShowText03, "w");
fprintf(OutputFile," ### Geometric and Material Nonlinearity Analysis of Springs with Displacement Control ###n");
fprintf(OutputFile,"Increment,Displacement [DOF(1)],Base Shear[DOF(1)]n");
for(i=0;i<n;i++)
fprintf(OutputFile,"%d,%e,%en",i+1,A[i],B[i]);
fclose(OutputFile);
}
void MessageInitialData(double Import_Data[],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<84;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf("tttt%c%s%cn",Qf,S01,Qf);
printf("tttt%c%s%cn",Qf,S02,Qf);
printf("tttt%c%s%cn",Qf,S03,Qf);
printf("tttt%c",Qg);
for (i=1;i<84;i++)
printf("%c",Qb);
printf("%cn",Qk);
printf("tttt%c%s%cn",Qf,S04,Qf);
printf("tttt%c%s%cn",Qf,S05,Qf);
printf("tttt%c",Qd);
for (i=1;i<84;i++)
printf("%c",Qb);
printf("%cn",Qe);
MessageInputDataTEXT();
printf("t Length of rigid element: %fn",Import_Data[0]);
printf("t Spring length 1: %fn",Import_Data[1]);
printf("t Spring length 2: %fn",Import_Data[2]);
printf("t Spring area 1: %fn",Import_Data[3]);
printf("t Spring area 2: %fn",Import_Data[4]);
printf("t External applied load in spring 1: %fn",Import_Data[5]);
printf("t External applied load in spring 2: %fn",Import_Data[6]);
printf("t Initial applied displacement: %fn",Import_Data[7]);
printf("t Distance of spring 1 from rigid element: %fn",Import_Data[8]);
printf("t Ultimate absolute displacement: %fn",Import_Data[9]);
printf("t Number of increments: %dn",n);
}
void MessageStrainStressTEXT(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n){
int i;
char Qa,Qb,Qc,Qd,Qe,Qf;
int BB=201,CC=205,DD=187,EE=200,FF=188,GG=186;
Qa=BB;Qb=CC;Qc=DD;Qd=EE;Qe=FF;Qf=GG;
printf(" %c",Qa);
for (i=1;i<77;i++)
printf("%c",Qb);
printf("%cn",Qc);
printf(" %c Spring 1 | Spring 2 %cn",Qf,Qf);
printf(" %c Strain Stress | Strain Stress %cn",Qf,Qf);
printf(" %c",Qd);
for (i=1;i<77;i++)
printf("%c",Qb);
printf("%cn",Qe);
for(i=0;i<n;i++)
printf(" %e %e %e %en",STRAIN01[i],STRESS01[i],STRAIN02[i],STRESS02[i]);
}
double Horizental_Disp(double L,double &x,double y){
int it,itermax;
double residual,tolerance,dx,dx_ABS,f,df;
it = 0; // initialize iteration count
itermax = 100000;
residual = 100; // initialize residual
tolerance = 1e-12;
x = 1;// initialize answer
while (residual > tolerance){
f = x*x + y*y - 2*L*x;
df = 2*x - 2*L;
dx = f/df;
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",y,it);
break;
}
}
if (it < itermax){
//printf("tSQRT(number,power) - SQRT(%f,%f) : %f n",D,n, x);
return x;
}
}
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 -= dx;
residual = ABS(dx); // abs residual
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;
}
}
Plot :
Figure(1) Analysis file
Figure(2) Input csv file
Figure(3) Input Strain-Stress properties csv file
Figure(4) Output csv file
Ad

More Related Content

What's hot (20)

DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
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
 
Pnno
PnnoPnno
Pnno
shristichaudhary4
 
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
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
Kandarp Tiwari
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
Sushil Mishra
 
Nonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programmingNonlinear analysis of frame with hinge by hinge method in c programming
Nonlinear analysis of frame with hinge by hinge method in c programming
Salar Delavar Qashqai
 
C programs
C programsC programs
C programs
Vikram Nandini
 
C program
C programC program
C program
Komal Singh
 
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
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
Syed Tanveer
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 
C programms
C programmsC programms
C programms
Mukund Gandrakota
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
Srinivas Reddy Amedapu
 
Cpds lab
Cpds labCpds lab
Cpds lab
praveennallavelly08
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
Malikireddy Bramhananda Reddy
 
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
 
programs
programsprograms
programs
Vishnu V
 
SaraPIC
SaraPICSaraPIC
SaraPIC
Sara Sahu
 
Arrays
ArraysArrays
Arrays
mohamed sikander
 

Similar to Geometric nonlinearity analysis of springs with rigid element displacement control large deformation formulated in c programming (20)

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
Arkadeep Dey
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
Array matrix example programs - C language
Array matrix example programs - C languageArray matrix example programs - C language
Array matrix example programs - C language
Sk_Group
 
array.ppt
array.pptarray.ppt
array.ppt
DeveshDewangan5
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
Ashishchinu
 
C programs
C programsC programs
C programs
Azaj Khan
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 
Mcs 011 solved assignment 2015-16
Mcs 011 solved assignment 2015-16Mcs 011 solved assignment 2015-16
Mcs 011 solved assignment 2015-16
Indira Gnadhi National Open University (IGNOU)
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
Srinivas Reddy Amedapu
 
C and Data Structures Lab Solutions
C and Data Structures Lab SolutionsC and Data Structures Lab Solutions
C and Data Structures Lab Solutions
Srinivas Reddy Amedapu
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
Saket Pathak
 
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
 
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
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
Abdullah Al Naser
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
C basics
C basicsC basics
C basics
MSc CST
 
Assignment on Numerical Method C Code
Assignment on Numerical Method C CodeAssignment on Numerical Method C Code
Assignment on Numerical Method C Code
Syed Ahmed Zaki
 
Ad

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...
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
 
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Salar Delavar Qashqai
 
Import data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programming
Salar Delavar Qashqai
 
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 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
 
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Salar Delavar Qashqai
 
Import data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programming
Salar Delavar Qashqai
 
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
 
Ad

Recently uploaded (20)

[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
Jimmy Lai
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Physical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A ReviewPhysical and Physic-Chemical Based Optimization Methods: A Review
Physical and Physic-Chemical Based Optimization Methods: A Review
Journal of Soft Computing in Civil Engineering
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...
🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...
🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...
SanjeetMishra29
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
22PCOAM16_MACHINE_LEARNING_UNIT_IV_NOTES_with_QB
Guru Nanak Technical Institutions
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
vtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdfvtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdf
RaghavaGD1
 
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
[PyCon US 2025] Scaling the Mountain_ A Framework for Tackling Large-Scale Te...
Jimmy Lai
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...
🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...
🚀 TDX Bengaluru 2025 Unwrapped: Key Highlights, Innovations & Trailblazer Tak...
SanjeetMishra29
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
Automatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and BeyondAutomatic Quality Assessment for Speech and Beyond
Automatic Quality Assessment for Speech and Beyond
NU_I_TODALAB
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
vtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdfvtc2018fall_otfs_tutorial_presentation_1.pdf
vtc2018fall_otfs_tutorial_presentation_1.pdf
RaghavaGD1
 

Geometric nonlinearity analysis of springs with rigid element displacement control large deformation formulated in c programming

  • 1. >> IN THE NAME OF GOD < Geometric Nonlinearity Analysis of Springs with Rigid Element Displacement Control Large Deformation Formulated in C programming C program is written by Salar Delavar Ghashghaei – Publication Date: 18/November/2019 E-mail: salar.d.ghashghaei@gmail.com -4.00E+03 -3.00E+03 -2.00E+03 -1.00E+03 0.00E+00 1.00E+03 2.00E+03 3.00E+03 4.00E+03 0.00E+00 2.00E+01 4.00E+01 6.00E+01 8.00E+01 1.00E+02 1.20E+02 BaseShear Displacement Geometric and Material Nonlinearity Analysis of Springs
  • 2. C Code:#include <stdio.h> #include <windows.h> // text color #include <conio.h> #define N 10000 #define S01 " >> IN THE NAME OF GOD << " #define S02 " Geometric and Material Nonlinearity Analysis of Springs with Displacement Control " #define S03 " UNIT: Free Unit " #define S04 " This program is written by Salar Delavar Ghashghaei " #define S05 " E-mail: salar.d.ghashghaei@gmail.com " #define ShowText01 "ConnectionProblemDCStrain-inputDATA.csv" #define ShowText02 "ConnectionProblemDCStrain-inputSPRING.csv" #define ShowText03 "ConnectionProblemDCStrain-outputEXCEL.csv" #define ShowText04 "ConnectionProblemDCStrain-outputMATLAB.m" void IMPORT_DATA01(double Import_Data[]); void IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int &k); void MessageNegative_IMPORT_DATA01(double Import_Data[]); void MessageNegative_IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n); void MessageInputDataTEXT(); void MessageAnalysisReportTEXT(); void MessageErrorReportTEXT(); void MessageInitialData(double Import_Data[],int n); void MessageStrainStressTEXT(double STARIN01[],double STRESS01[],double STARIN02[],double STRESS02[],int n); void textcolor(int ForgC); void Distance(int i); void Element_Slope(double A[],double B[],double C[],int n); void Element_Stiffness(double A[],double B[],double C[],double D[],double E[],double F[],double K[],int n,int m); void ANALYSIS(double Import_Data[],double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n,int m); void OUTPUT_excel(double A[],double B[],int n); void OUTPUT_matlab(double A[],double B[],int n); double ABS(double B); double Horizental_Disp(double L,double &x,double y); double SQRT2(double D); int main(){ int k; double Import_Data[10]; double STRAIN01[10]; double STRESS01[10]; double STRAIN02[10]; double STRESS02[10]; IMPORT_DATA01(Import_Data); MessageNegative_IMPORT_DATA01(Import_Data); IMPORT_DATA02(STRAIN01,STRESS01,STRAIN02,STRESS02,k); MessageNegative_IMPORT_DATA02(STRAIN01,STRESS01,STRAIN02,STRESS02,k); int m = 1 + ABS(Import_Data[9]/Import_Data[7]); textcolor(10); MessageInitialData(Import_Data,m); MessageStrainStressTEXT(STRAIN01,STRESS01,STRAIN02,STRESS02,k); textcolor(14); ANALYSIS(Import_Data,STRAIN01,STRESS01,STRAIN02,STRESS02,k,m); getch(); return 0; } void IMPORT_DATA01(double Import_Data[]){ 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++; } } void IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int &k){ 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",&STRAIN01[i],&STRESS01[i],&STRAIN02[i],&STRESS02[i]); //printf("%d - STRAIN01[%d]: %lf - STRESS01[%d]: %lf- STRAIN02[%d]: %lf - STRESS02[%d]: %lfn",i,i,STRAIN01[i],i,STRESS01[i],i,STRAIN02[i],i,STRESS02[i]); i++; } while(i < N && fgets(line,sizeof(line),InputFile) != NULL); k = i-1; //printf("%dn",k); } void MessageNegative_IMPORT_DATA01(double Import_Data[]){ if ( Import_Data[0] < 0 || Import_Data[1] < 0 || Import_Data[2] < 0 || Import_Data[3] < 0 || Import_Data[4] < 0 || Import_Data[9] < 0){ MessageErrorReportTEXT(); printf(" Please check this file! -> [%s]n",ShowText01); printf(" *** Negative data input value is not acceptable ***n"); printf(" Length of rigid element: %fn",Import_Data[0]); printf(" Spring length 1: %fn",Import_Data[1]); printf(" Spring length 2: %fn",Import_Data[2]); printf(" Spring area 1: %fn",Import_Data[3]); printf(" Spring area 2: %fn",Import_Data[4]); printf(" External applied load in spring 1: %fn",Import_Data[5]); printf(" External applied load in spring 2: %fn",Import_Data[6]); printf(" Initial applied displacement: %fn",Import_Data[7]); printf(" Distance of spring 1 from rigid element: %fn",Import_Data[8]); printf(" Ultimate absolute displacement: %fn",Import_Data[9]); Sleep(40000); exit(1); } } void MessageNegative_IMPORT_DATA02(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n){ int i; for (i=0;i<n+1;i++){ if ( STRAIN01[i] < 0 || STRESS01[i] < 0 || STRAIN02[i] < 0 || STRESS02[i] < 0 ){ MessageErrorReportTEXT(); printf(" Please check this file! -> [%s]n",ShowText02); printf(" Row %d has a negative value.n",i); printf(" *** Negative data input value is not acceptable ***n"); printf(" Strain of spring 1: %fn",STRAIN01[i]); printf(" Stress of spring 1: %fn",STRESS01[i]); printf(" Strian of spring 2: %fn",STRAIN02[i]); printf(" Stress of spring 2: %fn",STRESS02[i]); Sleep(40000); exit(1); } } } 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 MessageErrorReportTEXT(){ int i; char Ql; Ql=176; textcolor(12); printf("an "); for (i=1;i<50;i++) printf("%c",Ql); printf(" Error Report "); for (i=1;i<50;i++) printf("%c",Ql); printf("n"); } void MessageInputDataTEXT(){ int i; char Ql=176; printf("n "); for (i=1;i<50;i++) printf("%c",Ql); printf(" Input Data "); for (i=1;i<50;i++) printf("%c",Ql); printf("n"); } void MessageAnalysisReportTEXT(){ int i; char Ql=176; printf("n "); for (i=1;i<47;i++) printf("%c",Ql); printf(" Analysis Report "); for (i=1;i<47;i++) printf("%c",Ql); printf("n"); printf("nt "); for (i=1;i<72;i++) printf("-"); printf("n"); printf("t Increment Base Shear Incremental Displacement[DOF(1)] n"); printf("t "); for (i=1;i<72;i++) printf("-"); printf("n"); } void Distance(int i){ if (i < 10) printf("b"); 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 ABS(double B){ if (B < 0) B = -B;//Absolute number else B = B; return B; } void Element_Slope(double A[],double B[],double C[],int n){ int i; C[0]=B[0]/A[0]; //printf("%d - Rk[%d]: %fn",0,0,C[0]); for (i=1;i<n;i++){ //cout<<i<<" - TET["<<i<<"]:"<<A[i]<<" - MOM["<<i<<"]:"<<B[i]<<endl; C[i]=(B[i]-B[i-1])/(A[i]-A[i-1]); //printf("%d - Strain[%d]: %f - Stress[%d]: %f - Rk[%d]: %fn",i,i,A[i],i,B[i],i,C[i]); } } void Element_Stiffness(double A[],double B[],double C[],double D[],double E[],double F[],double K[],int n,int m){ int i; if (ABS(D[n])>= 0 && ABS(D[n])<= A[0]) K[n] = (C[n]*E[n])/F[n]; for (i=0;i<m;i++){ if (ABS(D[n])> A[i] && ABS(D[n])<= A[i+1]) K[n] = ((B[i]+C[i+1]*(ABS(D[n])-A[i]))/ABS(D[n]))*E[n]/F[n]; } if (ABS(D[n]) > A[m-1]) K[n] = 0; } void ANALYSIS(double Import_Data[],double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n,int m){ double L,Dx,a=0,Le[2],Area[2],Force[2],es[2],K[2],SLOPE01[10],SLOPE02[10],Dini,Dmax,Du,up; int z,zMAX,well_done=0; double output_u[N],output_base[N]; L = Import_Data[0]; Le[0] = Import_Data[1]; Le[1] = Import_Data[2]; Area[0] = Import_Data[3]; Area[1] = Import_Data[4]; Force[0] = Import_Data[5]; Force[1] = Import_Data[6]; Dini = Import_Data[7]; Du = Import_Data[8]; Dmax = Import_Data[9]; double F[2],Ay; Element_Slope(STRAIN01,STRESS01,SLOPE01,n); Element_Slope(STRAIN02,STRESS02,SLOPE02,n); MessageAnalysisReportTEXT(); for (z=0;z<m;z++){ up = Dini*(z+1);// Define the applied Displacement Horizental_Disp(L,Dx,up); a = SQRT2(.5*up*.5*up + .5*Dx*.5*Dx);// spring strain 1 during analysis es[0] = a/Le[0]; Element_Stiffness(STRAIN01,STRESS02,SLOPE01,es,Area,Le,K,0,n); F[0] = (((L-Dx)/L)*((L-Dx)/L))*K[0]*0.5*up + Import_Data[5]; Ay = F[0]; //printf("t+ %f - %fn",es[0],F[0]); if (ABS(up) >= Du){ es[1] = (Du-up)/Le[1]; Element_Stiffness(STRAIN02,STRESS02,SLOPE02,es,Area,Le,K,1,n); F[1] = (((L-Dx)/L)*((L-Dx)/L))*K[1]*(Du-up) + Import_Data[6]; Ay = F[0] + F[1]; //printf("t= %f - %fn",es[1],F[1]); } //printf("t %f - %fn",up,Dx); zMAX=z+1; output_u[z]=up; output_base[z]=Ay; Distance(z); printf("tt%dtt%ett%en",z+1,output_base[z],output_u[z]); if (ABS(up) >= Dmax){ well_done = 1; textcolor(13); printf("ntt ## Increment displacement reach to ultimate displacement ##nn"); break; } }// for if (well_done == 1){ OUTPUT_excel(output_u,output_base,zMAX); OUTPUT_matlab(output_u,output_base,zMAX); textcolor(15); printf("na - Output data is written in Excel and Matlab file -"); } } void OUTPUT_matlab(double A[],double B[],int n){ // MATLAB OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText04, "w"); fprintf(OutputFile," %% Geometric and Material Nonlinearity Analysis of Springs with Displacement Control %%n"); fprintf(OutputFile,"disp_Dof1=[0n"); for(i=0;i<=n;i++) fprintf(OutputFile,"%en",A[i]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"base_shear=[0n"); for(i=0;i<=n;i++) fprintf(OutputFile,"%en",B[i]); fprintf(OutputFile,"];nn"); fprintf(OutputFile,"figure(1)n"); fprintf(OutputFile,"plot(disp_Dof1,base_shear,'LineWidth',3);n"); fprintf(OutputFile,"title(['# BASE SHEAR - DISPLACEMENT DIAGRAM #'],'Color','b');n"); fprintf(OutputFile,"xlabel('DISPLACEMENT [DOF(1)]');ylabel('BASE SHEAR');grid on;n"); fclose(OutputFile); } void OUTPUT_excel(double A[],double B[],int n){ // EXCEL OUTPUT int i; FILE *OutputFile; OutputFile = fopen(ShowText03, "w"); fprintf(OutputFile," ### Geometric and Material Nonlinearity Analysis of Springs with Displacement Control ###n"); fprintf(OutputFile,"Increment,Displacement [DOF(1)],Base Shear[DOF(1)]n"); for(i=0;i<n;i++) fprintf(OutputFile,"%d,%e,%en",i+1,A[i],B[i]); fclose(OutputFile); } void MessageInitialData(double Import_Data[],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<84;i++) printf("%c",Qb); printf("%cn",Qc); printf("tttt%c%s%cn",Qf,S01,Qf); printf("tttt%c%s%cn",Qf,S02,Qf); printf("tttt%c%s%cn",Qf,S03,Qf); printf("tttt%c",Qg); for (i=1;i<84;i++) printf("%c",Qb); printf("%cn",Qk); printf("tttt%c%s%cn",Qf,S04,Qf); printf("tttt%c%s%cn",Qf,S05,Qf); printf("tttt%c",Qd); for (i=1;i<84;i++) printf("%c",Qb); printf("%cn",Qe); MessageInputDataTEXT(); printf("t Length of rigid element: %fn",Import_Data[0]); printf("t Spring length 1: %fn",Import_Data[1]); printf("t Spring length 2: %fn",Import_Data[2]); printf("t Spring area 1: %fn",Import_Data[3]); printf("t Spring area 2: %fn",Import_Data[4]); printf("t External applied load in spring 1: %fn",Import_Data[5]); printf("t External applied load in spring 2: %fn",Import_Data[6]); printf("t Initial applied displacement: %fn",Import_Data[7]); printf("t Distance of spring 1 from rigid element: %fn",Import_Data[8]); printf("t Ultimate absolute displacement: %fn",Import_Data[9]); printf("t Number of increments: %dn",n); } void MessageStrainStressTEXT(double STRAIN01[],double STRESS01[],double STRAIN02[],double STRESS02[],int n){ int i; char Qa,Qb,Qc,Qd,Qe,Qf; int BB=201,CC=205,DD=187,EE=200,FF=188,GG=186; Qa=BB;Qb=CC;Qc=DD;Qd=EE;Qe=FF;Qf=GG; printf(" %c",Qa); for (i=1;i<77;i++) printf("%c",Qb); printf("%cn",Qc); printf(" %c Spring 1 | Spring 2 %cn",Qf,Qf); printf(" %c Strain Stress | Strain Stress %cn",Qf,Qf); printf(" %c",Qd); for (i=1;i<77;i++) printf("%c",Qb); printf("%cn",Qe); for(i=0;i<n;i++) printf(" %e %e %e %en",STRAIN01[i],STRESS01[i],STRAIN02[i],STRESS02[i]); } double Horizental_Disp(double L,double &x,double y){ int it,itermax; double residual,tolerance,dx,dx_ABS,f,df; it = 0; // initialize iteration count itermax = 100000; residual = 100; // initialize residual tolerance = 1e-12; x = 1;// initialize answer while (residual > tolerance){ f = x*x + y*y - 2*L*x; df = 2*x - 2*L; dx = f/df; x -= dx; residual = ABS(dx); // abs residual it = it + 1; // increment iteration count //printf("f: %f -tdx: %f -tresidual: %fn",f,dx,residual);
  • 3. if (it == itermax){ printf("tSQRT2(number,power) : SQRT2(%f) - iteration: %d -> ## The solution is not converged ##n",y,it); break; } } if (it < itermax){ //printf("tSQRT(number,power) - SQRT(%f,%f) : %f n",D,n, x); return x; } } 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 -= dx; residual = ABS(dx); // abs residual 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; } } Plot : Figure(1) Analysis file
  • 5. Figure(3) Input Strain-Stress properties csv file
  翻译: