You are on page 1of 6

LIVE SCRIPT

Problem
Write a program in MATLAB (or any preferred Programming Language)
to find the displacements in the following system.

F 3 = 3 units

I F 6 = 6units

Clearing Workspace
Use of "Clear" command, usually slows down the performance of code. However, for evaluation purpose, the command is of great
significance.

clc
clear all;

Geometric Parameters
Total Length of system = 5 units
Area of cross-section for each Spring = 1 units

Total_length_of_system = 5; %%%%%%%%Change%%%%%%%% Geometric Parameters


Area_of_element = 1; %%%%%%%%Change%%%%%%%% Geometric Parameters

Material Properties
Element Stiffness for each Spring = 100 units
Young's Modulus of Elasticity for each Spring = 1 units

Es = 100; %%%%%%%%Change%%%%%%%% Material Properties


E_of_element = 1; %%%%%%%%Change%%%%%%%% Material Properties

Discretization Details
Number of nodes per element = 2
Degree of Freedom at each node = 1

No_of_elements = 5; %%%%%%%%Change%%%%%%%% Discretization Parameters


No_of_global_nodes = No_of_elements + 1;
No_of_nodes_per_element = 2;
No_DOF_per_node = 1;
Length_of_element = (Total_length_of_system / No_of_elements);

Construction of Location Matrix


The location matrix relates initial global node number and element local node numbers. IEN matrix has the following structure:

Initial global node number= IEN (local node number, element number )
IEN = [1:No_of_elements;2:No_of_elements+l]

IEN =
1 2 3 4 5
2 3 4 5 6

Essential Boundary Conditions


Displacement at Node No 1 = O units

No_of_constraint_nodes = 1; %%%%%%%%Change%%%%%%%% Essential BoundaryConditions


Constraint_nodes = [1]; %%%%%%%%Change%%%%%%%% Essential BoundaryConditions

Construction of Destination array


The destination array relates number of equations of the system by excluding known parts of the problem definition which are
provided in the form of Geometric Boundary Conditions.

Reordered global node number= ID (Initial global node number)


ID = ones(l,No_of_elements + 1);
ID (1,
Constraint_nodes) = 0;
ElementValue = 0;
for i=l:No_of_elements + 1
if ID (1,i) == 0
ID (1,i) = 0;
else
ID (1,i) = ElementValue+l;
ElementValue = ElementValue+l;
end
end
ID

ID =
0 1 2 3 4 5

Natural Boundary Conditions


External Force at Node No 3 = 3 units (+ve in the direction of- X)
External Force at Node No 6 = 6 units (+ve in the direction of- X)

No_of_loding_nodes = 2; %%%%%%%%Change%%%%%%%% Natural BoundaryConditions


Loading_nodes = [3 6]; %%%%%%%%Change, Also change values for loading inConstruction of Displacement Vector%%%%%%%%

Construction of Location matrix


Location matrix relates local node numbers & element numbers with the global node numbers. This is the location matrix that would
help us in assembling global stiffness matrix from local node numbers, local element stiffness matrix.

Reordered global node number= LM (Local node number, element number)

LM(I ,e)= ID(IEN (I ,e))


LM = zeros(2,No_of_elements);
for i=l:2
for j=l:No_of_elements
X = IEN(i,j);
LM(i,j) = ID(l,x);
end
end
LM

LM =
0 1 2 3 4
1 2 3 4 5
for j= 1:No_of_global_nodes
if Overall_displacement_vector(j,i) 0
else
for ii= No_DOF_per_node
for jj= 1:No_of_global_nodes - No_of_constraint_nodes
Displacement_vector(jj,ii)= 0;
end
end
end
end
end
Displacement_vector

Displacement_vector=
0
0
0
0
0

Finally, displacement vector is ready for further utlization after truncation of the known displacements.
Construction of Displacement Vector
Similarly, the overall force vector also needs to be truncated for the known reaction at known displacement nodes. Elements of overall
force vector with "O" are showing locations of known reaction/s and elements with "1" are showing absence of any known external loads.

F= Overall_displacement_vector;
F(3,1)= 3; %%%%%%%% Change, This change is associated with change in Natural Boundary Conditions Column%%%%%%%%
F(6,l)= 6; %%%%%%%% Change, This change is associated with change in Natural Boundary Conditions Column%%%%%%%%
Overall_force_vector= F

Overall_force_vector=
0
1
3
1
1
6

After necessary truncation, the force vector is ready for solving system of equations.

Force_vector= ones(No_of_global_nodes - No_of_constraint_nodes,1);


ii= lj
jj = 0;
for i= No_DOF_per_node
for j= 1:No_of_global_nodes
if Overall_force_vector(j,i) 0
else
jj= jj + 1;
if Overall_force_vector(j,i) 1
Force_vector(jj,ii)= 0;
else
Force_vector(jj,ii)= Overall_force_vector(j,i);
end
end
end
end
Force_vector

Force_vector=
0
3
0
0
6

D_Matrix_Solved= K A -l*Force_vector;
Displacement_vector_solved= ones(No_of_global_nodes,1);

You might also like