MCL 311 Lab 4 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

Aditya

2020ME10902
MCL-311 (LAB – 04)
Matlab code for Ques-1:
clc
clear all

%Enter no. of elements


prompt = "Enter the no. of elements"
numberElements = input(prompt);
numberNodes = numberElements + 1;

%Enter the values of young modulus, Area and length


E = 200e3;
%A = 100
A = zeros(1,numberElements);
A = linspace(100,200,numberElements);
L = 600;

%Here we make the matrix of numberelements , 1


nodeCoordinates = zeros(1,numberElements + 1);
nodeCoordinates = linspace(0, L,numberElements + 1);

ii = 1:numberElements;
elementNodes(ii,1) = ii;
elementNodes(ii,2) = ii + 1;

%Here we make a make matrix of numbernodes, 1;


displacements = zeros(numberNodes,1);

%here we make force vector matrix numbernodes,1


force = zeros(numberNodes,1);
stiffness = zeros(numberNodes);

%Here we make a loop for no. of elements


for i = 1:numberElements
L(i) = nodeCoordinates(i + 1) - nodeCoordinates(i);
k(i) = (A(i)*E)/L(i);
end

%here we enter the value of force


prompt = "Enter the force node"
ForceNode = input(prompt);
force(ForceNode,1) = 1e4;

for e = 1:numberElements
elementDof = elementNodes(e,:);
stiffness(elementDof, elementDof) = stiffness(elementDof, elementDof) +
k(e).*[1 -1;-1 1];
end
restrictedDof = [1];
activeDof = setdiff([1:numberNodes]',[restrictedDof]);

displacements = stiffness(activeDof , activeDof)\force(activeDof);

displacements1 = zeros(numberNodes,1);
displacements1(activeDof) = displacements;

F = stiffness*displacements1;
reactions = F(restrictedDof);

disp('reactions')
[restrictedDof reactions]

nodenumber = (1:numberNodes)';
disp('displacements')
[nodenumber nodeCoordinates' displacements1]

plot(nodeCoordinates' ,displacements1)

Matlab for Q-2:


clc
clear all

prompt = "Enter the number of elements"


numberElements = input(prompt);
numberNodes = numberElements +1;

% input the values of young's Modulus


%Area and total Length

E = 200e3;
A1 = 200; A2=100
Ltotal = 600;

% didvides the total length into egual spacing

nodeCoordinates = zeros(1,numberElements+1);
nodeCoordinates = linspace(0,Ltotal,numberElements+1);

% creates the element node connectivity matrix

i1 = 1:numberElements
elementNodes(i1,1)=i1;
elementNodes(i1,2)=i1+1;

% initialize the displacement, force and stiffness matrix


displacements = zeros(numberNodes,1);
force = zeros(numberNodes,1);
stiffness = zeros(numberNodes);

% calculate the stiffnes for individual elements


for i=1:numberElements
L(i)=nodeCoordinates(i+1)-nodeCoordinates(i);
x1 = nodeCoordinates(i);
x2 = nodeCoordinates(i+1);
Xmean = (x1+x2)/2;
A(i) = A1 - (A1-A2)*Xmean/Ltotal;
K(i)=A(i)*E/L(i);
end

% Applied force at the free node


prompt = "Enter the force node"
ForceNode = input(prompt);
force(ForceNode,1) = 10000.0;

for e=1:numberElements
elementDof=elementNodes(e,:);
stiffness(elementDof,elementDof) = stiffness(elementDof,elementDof)+ K (e).*[1 -1;-1 1];
end

restrictedDof = [1];

activeDof=setdiff([1:numberNodes]',[restrictedDof]);

displacements = stiffness (activeDof,activeDof)\force(activeDof);

dsplacements1 = zeros(numberNodes,1);
displacements1(activeDof)=displacements;

F=stiffness.*displacements1;
reaction=F(restrictedDof);

disp('reactions')
[restrictedDof reaction]

nodenumber = (1:numberNodes);
disp('displacements')
[nodenumber nodeCoordinates displacements1]

% plot the displacements


plot(nodeCoordinates,displacements1)
xlabel('nodeCoordinates (mm)')
ylabel('Displacements (mm)')
title('uniform area bar Under Tensile Loading')
Q-3:
1. First, we run ‘’ANSYS Mechanical Enterprise’’ software in PC and then go to
“Preferences’’ in the main menu and select “Structural’’ option. ‘’Structural’’
option in the “Preferences” menu allows the user to set various options related
to the structural analysis capabilities. It can include settings for element types,
load steps, solution methods, and more.

2. Then doing this command


Main Menu → Preprocessor → Add/ Edit/ Delete
Then, create a new element with the structural mass of Link and the analysis type
"3D finit stn 180." Three-dimensional structures are simulated under various loading
circumstances by the 3D Finite Element (FE) Structural 180 analysis type. The
structure is discretized into numerous tiny elements using the finite element
method, and the unknown displacement, velocity, and acceleration fields are then
solved for inside those elements.
3. Then doing this command
Main Menu → Preprocessor → Material Properties → Material Models
and define Material Model Number 1 and select Linear Isotopic Elastic Structural
Model and enter EX (Young’s Modulus) = 200 e3(similarly here we take young
modulus in kpa because area take in mm2 and length in mm) and PRXY (Poisson’s
Ratio) = 0.3
4. Then doing this command
Main Menu → Preprocessor → Section → Link → Add
Then add link with section ID = 1 defining the section name = s1 and section area
=190 mm^2 and applying the changes.
Then add link with section ID = 2 defining the section name = s2 and section area
=170 mm^2 and applying the changes.
Then add link with section ID = 3 defining the section name = s3 and section area
=150 mm^2 and applying the changes.

Then add link with section ID = 4 defining the section name = s4 and section area
=130 mm^2 and applying the changes.
Then add link with section ID = 5 defining the section name = s5 and section area
=110 mm^2 and applying the changes.

5. Then doing this command


Main Menu → Preprocessor → Modeling → Create → Keypoints → In Active CS
Add a keypoint with Keypoint Number 1 as origin and Keypoint Number 2 with X
location = 600 as the length of bar is 600mm. Thus defining the two ends of the bar.
The above operation results to this:
6. Then Go to List → Properties → Section Properties to check the executed
operations i.e. the section numbers and the respective section areas .
7. Then doing this command
Main Menu → Preprocessor → Meshing → Mesh Tool and set the element attribute
“Global” and setting global size controls with Element Edge Length =0 and No. of
element divisions =5 .
Now this operation will lead to selecting Mesh Line and then we select the mesh line
shown in green colour below to divide this line.
After selecting line, it will look like this:
8. Then going to “Plot” menu and in the Numbering Controls turn on the “Node
Numbers”.

After applying this operation, the node numbers will look start to appear on the line.
9. Then Doing this command
Main Menu → Preprocessor → Modeling → Move/Modify → Elements → Modify
Attrib
Then select the elements while assigning them new attribute numbers.
First, enter New Attribute number = 1 and select 1 st element.

Then , enter New Attribute number = 2 and select 2nd element.


Similarly repeating this process till selecting 5th element as each element have
different section area.
10. Then Doing this command
Main Menu → Preprocessor → Loads → Define Loads → Apply → Structural →
Displacement → On Nodes and select the Node 2 and restrict its all Degrees of
freedom (DOF) as it is fixed end.
11. Then Doing this command
Main Menu → Preprocessor → Loads → Define Loads → Apply → Structural →
Force/Moment → On Nodes and set the load value = “1e4” on Node 2 along X
direction.
After the above operation, the element will look like this:
12. Then Doing this command
Main Menu → Solution → Current LS and it will solve the given problem.
13. Then Doing this command
Main Menu → General Postproc → Plot Results → Contour Plot→ Nodal Solu
Then Doing this command Contour Nodal Solution Data → Nodal Solution → DOF
Solution → X-component of displacement → OK

It results to:
14. Then Doing this command PlotCtrls → Style → Size and Shape and turn “Display
of Element” option “ON”. This process lets us change the size and shape of
graphics window elements. When "Display of Element" is "ON," the plot shows
the model's element distribution and mesh quality.
Resulting this solution:

15. Then doing a right click and selecting the Oblique View to getter a better view of
the element.
Oblique View:

16. Then Doing this command


PlotCtrls → Redirect Plots → To JPEG File and turn “ON” force white BG and black FG
and increase “Pixel Resolution” to 1600 to save the plot of element to a JPEG File
with a better quality.
FINAL SOLUTION OF QUES 4:

You might also like