0% found this document useful (0 votes)
25 views33 pages

CL-02 - Uchit Balsari - Octave

Uploaded by

UCHIT BALSARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views33 pages

CL-02 - Uchit Balsari - Octave

Uploaded by

UCHIT BALSARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: Balsari Uchit M.

Roll No: CL-02


ID No: 17CLUOG036
Subject: OCTAVE Applications in Civil Engineering

1
Sr.No Content Page No
1. Introduction to OCTAVE Software 3
2. Obtaining roots of equation using Bisection 5
method, False position method, Newton
Raphson method, Secant method.
3. Shear force and Bending moment diagram of 13
simply supported beam
4. Basic Matrix operations using OCTAVE Software 16
5. Analysis of continuous Beam using direct 19
stiffness matrix method
6. Design of Rectangular reinforced concrete beam 25
7. Design of two-way simply supported slab 28
8. Central difference method of earthquake 31
analysis using OCTAVE Software

2
1) Introduction of Octave Software:

• OCTAVE is an open-source interactive Software system for


numerical computations and graphics.
• It is particularly designed for matrix computations: solving
simultaneous equations, computing eigen values, eigen vectors
and so on.
• It Provides a convenient command line interface for solving
linear and non-linear problems numerically, and performing
other numerical experiments using a language that is mostly
compatible with OCTAVE.
• OCTAVE has extensive tools for solving common numerical
linear algebra problems, finding roots of non-linear equations,
integrating ordinary functions, Manipulating polynomials, and
integrating ordinary differential and differential-algebraic
equations.
• OCTAVE has it’s own programming language and works like a
very powerful, programmable and graphical calculator.
• It’s syntax is compatible with MATLAB Software (a proprietary
Software with similar functionalities.
 Advantages of using OCTAVE Software:
• It has C, C++ and FORTRAN as it’s base languages, Which makes
it a lot faster.
• It’s syntax is very close to mathematical expressions. There are
some prebuilt mathematical functions which can be directly
use in calculations.
• It has high level plot commands for 2D and 3D for data
visualization.
• It also supports contour plots.
• Size of file generated is very small.

3
 Comparision of MATLAB and OCTAVE Software:

MATLAB OCTAVE
Not open source Open source
Consumes more memory Consumes less memory compare
compare to OCTAVE. to MATLAB.
Very good interface and easy to Interface is not good compare to
operate. MATLAB.
Execution speed is faster. Execution speed is slow.
It does not support C-style auto- It does support C-style auto-
increment and assignment increment and assignment
operators like x++, ++x, x--. operators like x++, ++x, x--, --x.

 Method to use OCTAVE Software:


• In Editor Window, Create Script file using various function
available in Software.
• After creating script file run file and show output in command
window.

4
2) Obtain Roots of Equations using different Methods:

1) 6x3-4x2-7x-2=0, Limits are xi=0, xu=2.


(i) Bisection Method:
clc
clear
a=input('Enter Value of Lower Limit:');
b=input('Enter Value of Upper Limit:');
n=input('Enter Number Of itterations:');
for i=1:n
c=(a+b)/2;
fa=6*a^3-4*a^2-7*a-2;
fc=6*c^3-4*c^2-7*c-2;
if fa*fc<0;
b=c;
else
a=c;
end
end
disp(c)
-----------------------------------------------------------
Enter Value of Lower Limit:0
Enter Value of Upper Limit:2
Enter Number Of itterations:10
1.5566

5
(ii) False-Position Method:
clc
clear
a=input('Enter Value of Lower Limit:');
b=input('Enter Value of Upper Limit:');
n=input('Enter Number Of itterations:');
for i=1:n
fa=6*a^3-4*a^2-7*a-2;
fb=6*b^3-4*b^2-7*b-2;
c=(a*fb-b*fa)/(fb-fa);
fc=6*c^3-4*c^2-7*c-2;
if fa*fc<0;
b=c;
else
a=c;
end
end
disp(c)
----------------------------------------------------------------------------------
Enter Value of Lower Limit:0
Enter Value of Upper Limit:2
Enter Number Of itterations:10
1.5544

6
(iii) Newton Raphson Method:
clear
clc
x0=input('Enter The Initial guess Solution=');
n=input('Numbers Of Itterations=');

for i=1:n
fx=6*x0^3-4*x0^2-7*x0-2;
dfx=18*x0^2-8*x0-7;
x1=x0-(fx/dfx);
x0=x1;
end
fprintf("Final Solution:")
disp(x1)
----------------------------------------------
Enter The Initial guess Solution=1
Numbers Of Itterations=10
Final Solution:1.5549

7
(iv) Secant Method:
clear
clc
xi_1=input('Enter The Initial guess Solution i-1=');
xi=input('Enter The Next Initial guess Solution i:');
n=input('Numbers Of Itterations=');

for i=1:n
fxi_1=6*xi_1^3-4*xi_1^2-7*xi_1-2;
fxi=6*xi^3-4*xi^2-7*xi-2;
x1=(xi_1*fxi-xi*fxi_1)/(fxi-fxi_1);
xi_1=xi;
xi=x1;
if and (fxi<0.001,fxi>-0.001)
break
endif
end
fprintf("Final Solution:")
disp(x1)
--------------------------------------------------
Enter The Initial guess Solution i-1=1.5
Enter The Next Initial guess Solution i:1.6
Numbers Of Itterations=10
Final Solution:1.5549

8
2) (5-x) e0.25x-2.5=0, Limits are xi=0.5, xu=1.

(i) Bisection Method:


clc

clear

a=input('Enter Value of Lower Limit:');

b=input('Enter Value of Upper Limit:');

n=input('Enter Number Of itterations:');

for i=1:n

c=(a+b)/2

fa=(5-a)*exp(0.5*a)-2.5

fc=(5-c)*exp(0.5*c)-2.5

if fa*fc<0;

b=c;

else

a=c;

end

end

disp(c)

--------------------------------------------------------

Enter Value of Lower Limit:0.5

Enter Value of Upper Limit:1

Enter Number Of itterations:10

0.9995

9
(ii) False-Position Method:
clc

clear

a=input('Enter Value of Lower Limit:');

b=input('Enter Value of Upper Limit:');

n=input('Enter Number Of itterations:');

for i=1:n

fa=(5-a)*exp(0.5*a)-2.5;

fb=(5-b)*exp(0.5*b)-2.5;

c=(a*fb-b*fa)/(fb-fa);

fc=(5-c)*exp(0.5*c)-2.5;

if fa*fc<0;

b=c;

else

a=c;

end

end

disp(c)

------------------------------------------------

Enter Value of Lower Limit:0.5

Enter Value of Upper Limit:1

Enter Number Of itterations:10

-2.0827

10
(iii) Secant Method:
clear

clc

xi_1=input('Enter The Initial guess Solution i-1=');

xi=input('Enter The Next Initial guess Solution i:');

n=input('Numbers Of Itterations=');

for i=1:n

fxi_1=(5-xi_1)*exp(0.5*xi_1)-2.5;

fxi=(5-xi)*exp(0.5*xi)-2.5;

x1=(xi_1*fxi-xi*fxi_1)/(fxi-fxi_1);

xi_1=xi;

xi=x1;

if and (fxi<0.001,fxi>-0.001)

break

endif

end

fprintf("Final Solution:")

disp(x1)

------------------------------------------------

Enter The Initial guess Solution i-1=0.5

Enter The Next Initial guess Solution i:1

Numbers Of Itterations=10

Final Solution:-2.0827

11
(iv) Newton’s Raphson Method:
clear

clc

x0=input('Enter The Initial guess Solution=');

n=input('Numbers Of Itterations=');

for i=1:n

fx=(5-x0)*exp(0.5*x0)-2.5;

dfx=(5-x0)*0.5*exp(0.5*x0)-exp(0.5*x0);

x1=x0-(fx/dfx);

x0=x1;

end

fprintf("Final Solution:")

disp(x1)

--------------------------------------------------

Enter The Initial guess Solution=-2

Numbers Of Itterations=10

Final Solution:-2.0827

12
3)Shear force and Bending Moment Diagram:

Script File:
clc
clear
L=input('Length of simply supported Beam (m):');
w=input('Enter UDL (kN/m):');
Ra=w*3
Rb=w*3
x=0:3
SF=Ra-w*x
a=x/2;
BM=Ra*x-w*x.*a
y=x*0;
x=4:7
SF=Ra-(w*3)
a=(x-1.5);
BM=Ra*x-30*a
x=8:10
SF=Rb-30-w*(x-7)
13
a=x-1.5;

BM=Ra*x-30*a-(0.5*w*(x-7).^2)
y=(x-7)*0;
subplot(2,1,1)
plot(x,SF,x,y)
subplot(2,1,2)
plot(x,BM,x,y)
Output of Script file:
Length of simply supported Beam (m):10
Enter UDL (kN/m):10
Ra = 30
Rb = 30
x=
0 1 2 3
SF =
30 20 10 0
BM =
0 25 40 45
x=
4 5 6 7
SF = 0
BM =
45 45 45 45
x=
8 9 10

14
SF =
-10 -20 -30
BM =
40 25 0

SFD and BMD

15
4)Basic Operations of Matrix using OCTAVE:

Script file:
clc
clear
A=[1 2 3 4;5 6 8 7;3 7 9 1;7 -1 -7 2]
B=[4 6 5 1;7 8 3 2;3 2 -4 -5;-3 8 9 4]
detA=det(A)
detB=det(B)
invA=inv(A)
invB=inv(B)
TranA=[A]'
TranB=[B]'
subA=magic(3)
A(4,:)=[]
B(:,1)=[]
B(5,:)=B(2,:)

16
Output:
A=
1 2 3 4
5 6 8 7
3 7 9 1
7 -1 -7 2
B=
4 6 5 1
7 8 3 2
3 2 -4 -5
-3 8 9 4
detA = 259.00
detB = 1080
invA =
-0.965251 0.598456 -0.243243 -0.042471
1.756757 -1.189189 0.702703 0.297297
-1.092664 0.737452 -0.351351 -0.220077
0.432432 -0.108108 -0.027027 0.027027
invB =
0.174074 0.014815 -0.062963 -0.129630
-0.224074 0.135185 0.112963 0.129630
0.388889 -0.222222 -0.055556 -0.055556
-0.296296 0.240741 -0.148148 0.018519

17
TranA =
1 5 3 7
2 6 7 -1
3 8 9 -7
4 7 1 2
TranB =
4 7 3 -3
6 8 2 8
5 3 -4 9
1 2 -5 4
subA =
8 1 6
3 5 7
4 9 2
A=
1 2 3 4
5 6 8 7
3 7 9 1
B=
6 5 1
8 3 2
2 -4 -5
8 9 4

18
B=
6 5 1
8 3 2
2 -4 -5
8 9 4
8 3 2

5)Analysis of Beam using Stiffness Matrix method:

Script file:
clc
clear
M=input('Enter The Numbers Of Member:=');
E=input('Enter Value Of E(kN/m2)=');
J=M+1;
R=2*J;
Nr=input('Enter the total no. of Support Restrains=');
DOF=R-Nr
for i=1:M
fprintf('Data For Member:%d\n',i)
fprintf('Enter the Value Of B%d(m)=',i)

19
B=input('');
fprintf('Enter the Value Of D%d(m)=',i)
D=input('');
A=B*D
fprintf('Enter the Value Of I%d(m^4)=',i)
I=(B*D^3)/12; disp(I)
fprintf('Enter the Value Of L%d(m)=',i)
L=input('');
K=fprintf('SJ%d=\n',i);

K=[12*E*I/L^3 6*E*I/L^2 -12*E*I/L^3 6*E*I/L^2;6*E*I/L^2 4*E*I/L -6*E*I/L^2


2*E*I/L;-12*E*I/L^3 -6*E*I/L^2 12*E*I/L^3 -6*E*I/L^2;6*E*I/L^2 2*E*I/L -
6*E*I/L^2 4*E*I/L];
disp(K);

Sjc(:,:,i)=K;
end
for i=1:M
fprintf('Input the Value Of Vector Fixed End Action AML%d=',i);
AML=input('')';
AMLi(:,i)=AML;
end
SJ=zeros(2*M+2);
AML=zeros(2*M+2,1);
for i=1:M
k=2*i-1;
SJ(k:k+3,k:k+3)=SJ(k:k+3,k:k+3)+Sjc(:,:,i);

20
AML(k:k+3,1)=AML(k:k+3,1)+AMLi(:,i);
end

SJ;
AML;
AE=-AML;
AJ=input('Enter Value Of Vector AJ=')';
AC=AE+AJ;
FRDOF(:,:)=input('Input The Row Vector Of Free DOF:');
FIDOF(:,:)=input('Input Row Vector For Fixed DOF:');
ASC=SJ([FRDOF(:,:) FIDOF(:,:)],:);
AssembledSJ=ASC(:,[FRDOF(:,:) FIDOF(:,:)]);
SFF=AssembledSJ(1:DOF,1:DOF);
SFR=AssembledSJ(1:DOF,DOF+1:R);
SRF=AssembledSJ(DOF+1:R,1:DOF);
SRR=AssembledSJ(DOF+1:R,DOF+1:R);
AFC=AC(FRDOF(:,:),:);
ARC=AC(FIDOF(:,:),:);
DFF=inv(SFF)*AFC
AR=-ARC+SRF*DFF
DFT=zeros(2*J,1);
for i=1:DOF
DFT(FRDOF(i),1)=DFF(i,1);
end
for i=1:M
k=2*i-1;

21
DM(:,i)=DFT(k:k+3,1);
AM=AMLi(:,i)+Sjc(:,:,i)*DM(:,1)
end
------------------------------------------------------------
Enter The Numbers Of Member:=3
Enter Value Of E(kN/m2)=2.5e6
Enter the total no. of Support Restrains=5
DOF = 3
Data For Member:1
Enter the Value Of B1(m)=0.23
Enter the Value Of D1(m)=0.5
A = 0.1150
Enter the Value Of I1(m^4)=2.3958e-03
Enter the Value Of L1(m)=4
SJ1=
1123.0 2246.1 -1123.0 2246.1
2246.1 5989.6 -2246.1 2994.8
-1123.0 -2246.1 1123.0 -2246.1
2246.1 2994.8 -2246.1 5989.6
Data For Member:2
Enter the Value Of B2(m)=0.23
Enter the Value Of D2(m)=0.5
A = 0.1150
Enter the Value Of I2(m^4)=2.3958e-03
Enter the Value Of L2(m)=3
SJ2=

22
2662.0 3993.1 -2662.0 3993.1
3993.1 7986.1 -3993.1 3993.1
-2662.0 -3993.1 2662.0 -3993.1
3993.1 3993.1 -3993.1 7986.1
Data For Member:3
Enter the Value Of B3(m)=0.23
Enter the Value Of D3(m)=0.5
A = 0.1150
Enter the Value Of I3(m^4)=2.3958e-03
Enter the Value Of L3(m)=4
SJ3=
1123.0 2246.1 -1123.0 2246.1
2246.1 5989.6 -2246.1 2994.8
-1123.0 -2246.1 1123.0 -2246.1
2246.1 2994.8 -2246.1 5989.6
Input the Value Of Vector Fixed End Action AML1=[-7.5 -5 7.5 -5]
Input the Value Of Vector Fixed End Action AML2=[15 7.5 15 -7.5]
Input the Value Of Vector Fixed End Action AML3=[10 8.33 10 -8.33]
Enter Value Of Vector AJ=[0 0 0 0 0 0 0 0]
Input The Row Vector Of Free DOF:[4 6 8]
Input Row Vector For Fixed DOF:[1 2 3 5 7]
DFF =
-7.1004e-05
-3.7757e-04
1.5795e-03

23
AR =
-7.6595
-5.2126
20.8683
29.4909
7.3003
AM =
-7.6595
-5.2126
7.6595
-5.4253
AM =
14.7165
7.2165
15.2835
-8.0670
AM =
9.8405
8.1174
10.1595
-8.7553

24
6)Design Of Rectandular RC Beam:

Script file:
clear
clc
b=input('Enter Width Of Beam(mm):');
D=input('Overall depth of Beam(mm):');
dt=input('Effective Cover For Tension Reinforcement(mm):');
dc=input('Effective Cover For Compression Reinforcement(mm):');
fck=input('Grade Of Concrete(N/mm2):');
fy=input('Grade Of Steel(N/mm2):');
E=input('Young Modulus Of Steel(N/mm2):');
Mu=input('Factored Moment(kNm):');
deff=D-dt;
if fy==250
Mulim=(0.148*fck*b*deff^2)/10^6;
elseif fy==415
Mulim=(0.138*fck*b*deff^2)/10^6;
elseif fy==500
Mulim=(0.133*fck*b*deff^2)/10^6;
else
disp('Grade Of Steel Is Incorrect');
end

25
if fy==250
xumax=0.53*deff;
elseif fy==415
xumax=0.48*deff;
elseif fy==500
xumax=0.46*deff;
else
disp('Grade Of Steel Is Incorrect')
end
if Mu<Mulim
disp('Singly Beam Design')
pt=50*(fck/fy)*(1-(1-4.6/fck*Mu*10^6/(b*deff^2))^(1/2))
disp('Area Of Reinforcement(mm2):')
Ast=pt*b*deff/100
else Mu>Mulim
disp('Doubly Beam Design')
Astlim=(0.36*fck*b*xumax)/(0.87*fy);
Mu2=Mu-Mulim;
Ast2=(Mu2*10^6)/(0.87*fy*(deff-dc));
Ast=Ast2+Astlim;
Ast=round(Ast)
str=0.0035*(1-(dc/xumax));
if str<(0.8*fy/1.15/E)
fsc=str*E;
elseif (0.8*fy/1.15/E)<=str<=((fy/1.15/E)+0.002)

26
s=[0.8*fy/1.15/E;0.85*fy/1.15/E;0.9*fy/1.15/E;0.95*fy/1.15/E;0.975*fy/1.15/E
;1*fy/1.15/E]
S=[(s(1)/E)+0;(s(2)/E)+0.0001;(s(3)/E)+0.0003;(s(4)/E)+0.0007;(s(5)/E)+0.001;(s(
6)/E)+0.002]
fsc=interp1(S,s,str);
else
fsc=fy/1.15;
end
Asc=0.87*fy*Ast2/fsc;
Asc=round(Asc)
end
------------------------------------------------
Enter Width Of Beam(mm):300
Overall depth of Beam(mm):550
Effective Cover For Tension Reinforcement(mm):25
Effective Cover For Compression Reinforcement(mm):30
Grade Of Concrete(N/mm2):25
Grade Of Steel(N/mm2):415
Young Modulus Of Steel(N/mm2):2e5
Factored Moment(kNm):370
ans = 1
Doubly Beam Design
Ast = 2359
Asc = 474

27
7)Design of Two-way simply supported slab:

Script file:
clc
clear
lx=input('Enter clear dimention in x-direction (m):');
ly=input('Enter clear dimention in y-direction (m):');
fck=input('Enter Grade of concrete:');
fy=input('Enter Grade of steel:');
b=input('Enter wall thickness (m):');
LL=input('Enter LL (kN/m2):');
FF=input('Enter FF (kN/m2):');
D=input('Enter total depth D (m):');
dx=D-0.020;
dy=dx-0.01;
lex=min(lx+dx,lx+b);
ley=min(lx+dy,ly+b);
load=1.5*((25*D)+LL+FF);
str=ly/lx;
r=[1 1.1 1.2 1.3 1.4 1.5 1.75 2 2.5 3];
alx=[0.062 0.074 0.084 0.093 0.099 0.104 0.113 0.118 0.122 0.124];
aly=[0.062 0.061 0.059 0.055 0.051 0.046 0.037 0.029 0.02 0.014];

28
fprintf('Results for direction x \n')
alphax=interp1(r,alx,str);
Mu=alphax*load*lex*lex;
k=(Mu*10^6)/(fck*1000*(dx*1000)^2);
ptx=50*fck/fy*(1-(1-(4.6*k))^0.5);
ast1=(ptx*1000*dx*1000)/100;
astmin=(0.12/100)*1000*D*1000;
astx=max(ast1,astmin)
diabarx=input('Assume diameter of bar:');
M=[(((3.14/4)*diabarx*diabarx)/astx)*1000,300,3000*dx];
spacingx=min(M);
spacingx=round(spacingx)
astprox=(((3.14/4)*diabarx*diabarx)/spacingx)*1000;
ptprox=(astprox/(1000*dx*1000))*100;
MFx=1/(1+0.625*log10(ptprox));
dxpro=lex/(20*MFx);
if dxpro>dx
fprintf('Deflection check satisfies \n')
else
fprintf('Deflection check does not satisfy \n')
end
fprintf('Results for direction y \n')
alphay=interp1(r,aly,str);
Mu=alphax*load*ley*ley;
k=(Mu*10^6)/(fck*1000*(dy*1000)^2);
pty=50*fck/fy*(1-(1-(4.6*k))^0.5);

29
ast2=(pty*1000*dx*1000)/100;
asty=max(ast2,astmin)
diabary=input('Assume diameter of bar:');
N=[(((3.14/4)*diabary*diabary)/asty)*1000,3*dy*1000,300];
spacingy=min(N);
spacingy=round(spacingy)
astproy=(((3.14/4)*diabary*diabary)/spacingy)*1000;
ptproy=(astproy/(1000*dy*1000))*100;
MFy=1/(1+0.625*log10(ptproy));
dypro=ley/(20*MFy);
if dypro>dy
fprintf('Deflection check satisfies')
else
fprintf('Deflection check does not satisfy')
end
---------------------------------------------------------------------------
Enter clear dimention in x-direction (m):3.5
Enter clear dimention in y-direction (m):4.5
Enter Grade of concrete:20
Enter Grade of steel:415
Enter wall thickness (m):0.23
Enter LL (kN/m2):4
Enter FF (kN/m2):1
Enter total depth D (m):0.14
Results for direction x
astx = 378.65

30
Assume diameter of bar:10
spacingx = 207
Deflection check satisfies
Results for direction y
asty = 454.52
Assume diameter of bar:12
spacingy = 249
Deflection check satisfies>>

8)Central difference method:

Script file:
clc
clear
format short
fprintf('CENTRAL DIFFRENCE METHOD \n \n')
m=input('Enter value of mass m(kg):');
k=input('Enter value of stiffness k(N/m):');
zi=input('Enter value of damping ratio:');
t=input('Enter value of time period (sec):');
deltaT=input('Enter value of deltaT (sec):');
xi(2)=input('Enter value of initial displacement x0(m):');
xdoti(1)=input('Enter value of initial velocity xdot0(m/s):');
wn=sqrt(k/m);

31
c=2*m*wn*zi;
F(2)=0;
xddoti(2)=(F(2)-c*xdoti-k*xi(2))/m;
xi(1)=xi(2)-deltaT*xdoti(1)+(deltaT^2*xddoti(2))/2';
kcap=m/deltaT^2+c/(2*deltaT);
a=m/deltaT^2-c/(2*deltaT);
b=k-2*m/(deltaT^2);
for i=0:(t/deltaT)
ti(i+1)=i/(t/deltaT);
F(:,i+2)=round(40*sin(pi*ti(i+1)/0.6));
if F(i+2)<0
F(i+2)=0;
end
a1(i+1,:)=[i;ti(i+1);F(:,i+2)];
end
for i=2:t/deltaT+2
Fcap(i)=F(i)-a*xi(i-1)-b*xi(i);
xi(i+1)=Fcap(i)/kcap;
xdoti(i-1)=(xi(i+1)-xi(i-1))/(2*deltaT);
xddoti(i)=(xi(i+1)-2*xi(i)+xi(i-1))/(deltaT)^2;
a2(i-1,:)=[xi(i-1);a*xi(i-1);xi(i);b*xi(i);Fcap(i);xi(i+1);xdoti(i-1)];
end
a=[a1(:,:) a2(:,:)];
fprintf(' i ti Fi xi-1 a*xi-1 xi b*xi Fcap xi+1
xdoti \n')
disp(a)
------------------------------------------------------------------------------------------
32
CENTRAL DIFFRENCE METHOD

Enter value of mass m(kg):45000


Enter value of stiffness k(N/m):1800000
Enter value of damping ratio:0.05
Enter value of time period (sec):1
Enter value of deltaT (sec):0.1
Enter value of initial displacement x0(m):0
Enter value of initial velocity xdot0(m/s):0

33

You might also like