SlideShare una empresa de Scribd logo
1 de 6
Descargar para leer sin conexión
>> 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

Más contenido relacionado

La actualidad más candente

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
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
Swarup Kumar Boro
 

La actualidad más candente (20)

DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
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
 
Pnno
PnnoPnno
Pnno
 
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
 
Os lab file c programs
Os lab file c programsOs lab file c programs
Os lab file c programs
 
c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
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
 
C programs
C programsC programs
C programs
 
C program
C programC program
C program
 
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILECOMPUTER SCIENCE CLASS 12 PRACTICAL FILE
COMPUTER SCIENCE CLASS 12 PRACTICAL FILE
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
c++ program for Railway reservation
c++ program for Railway reservationc++ program for Railway reservation
c++ program for Railway reservation
 
C programms
C programmsC programms
C programms
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
C PROGRAMS
C PROGRAMSC PROGRAMS
C PROGRAMS
 
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
 
programs
programsprograms
programs
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
Arrays
ArraysArrays
Arrays
 

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

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
C basics
C basicsC basics
C basics
MSc CST
 

Similar a 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
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Array matrix example programs - C language
Array matrix example programs - C languageArray matrix example programs - C language
Array matrix example programs - C language
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
array.ppt
array.pptarray.ppt
array.ppt
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
C programs
C programsC programs
C programs
 
C Programming
C ProgrammingC Programming
C Programming
 
Mcs 011 solved assignment 2015-16
Mcs 011 solved assignment 2015-16Mcs 011 solved assignment 2015-16
Mcs 011 solved assignment 2015-16
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
C and Data Structures Lab Solutions
C and Data Structures Lab SolutionsC and Data Structures Lab Solutions
C and Data Structures Lab Solutions
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
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 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
 
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
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
C basics
C basicsC basics
C basics
 

Más de 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
 

Más de Salar Delavar Qashqai (20)

Pushover 2order (p delta effect) analysis force analogy method with force con...
Pushover 2order (p delta effect) analysis force analogy method with force con...Pushover 2order (p delta effect) analysis force analogy method with force con...
Pushover 2order (p delta effect) analysis force analogy method with force con...
 
Pushover analysis of frame by force analogy method with force control based o...
Pushover analysis of frame by force analogy method with force control based o...Pushover analysis of frame by force analogy method with force control based o...
Pushover analysis of frame by force analogy method with force control based o...
 
Truss optimization with excel solver
Truss optimization with excel solverTruss optimization with excel solver
Truss optimization with excel solver
 
Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...Pushover analysis of triangular steel membrane element subjected to lateral d...
Pushover analysis of triangular steel membrane element subjected to lateral d...
 
Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...Pushover analysis of simply support steel section beam based on plastic hinge...
Pushover analysis of simply support steel section beam based on plastic hinge...
 
Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...Pushover analysis of steel section beam subjected to incremental vertical loa...
Pushover analysis of steel section beam subjected to incremental vertical loa...
 
Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000Moment curvature analysis of unconfined concrete section with matlab and sap2000
Moment curvature analysis of unconfined concrete section with matlab and sap2000
 
Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...Large deformation analysis of cantilever beam subjected to concentrated const...
Large deformation analysis of cantilever beam subjected to concentrated const...
 
Moment curvature analysis unconfined concrete section with different tension...
Moment curvature analysis unconfined concrete section  with different tension...Moment curvature analysis unconfined concrete section  with different tension...
Moment curvature analysis unconfined concrete section with different tension...
 
Optimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductilityOptimization of steel section based on moment and section ductility
Optimization of steel section based on moment and section ductility
 
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
Nonlinear analysis of 2 d cantilever nonprismatic beam with plastic hinge con...
 
Import data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programmingImport data from csv excel file and export to xml excel file in c programming
Import data from csv excel file and export to xml excel file in c programming
 
Elastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programmingElastic response pseudo spectrum in c programming
Elastic response pseudo spectrum in c programming
 
Structural eigen value analysis in c programming
Structural eigen value analysis in c programmingStructural eigen value analysis in c programming
Structural eigen value analysis in c programming
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
Analysis of 1st order and 2nd order nonlinear semi rigid connection braced fr...
 
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
Analysis of 1st order and 2nd order nonlinear semi rigid connection frame sub...
 
Moment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlabMoment curvature analysis confined concrete section in matlab
Moment curvature analysis confined concrete section in matlab
 
Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...Moment curvature analysis of unconfined circular concrete pipe section with m...
Moment curvature analysis of unconfined circular concrete pipe section with m...
 
1st order pushover analysis of column subjected to compression and tension ax...
1st order pushover analysis of column subjected to compression and tension ax...1st order pushover analysis of column subjected to compression and tension ax...
1st order pushover analysis of column subjected to compression and tension ax...
 
Pushover analysis of steel section beam with semi rigid connection in matlab ...
Pushover analysis of steel section beam with semi rigid connection in matlab ...Pushover analysis of steel section beam with semi rigid connection in matlab ...
Pushover analysis of steel section beam with semi rigid connection in matlab ...
 

Último

Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Último (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 

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