Anda di halaman 1dari 12

General Information:

Finite elements methods, which enable us to solve complicated engineering problems


using controllable pieces by simplifying the data, is a common and a practical solution method
that is used in many engineering practices. The main idea is to take a complicated problem to a
solution through simplifying. In this method, the solution area consists of sub-categories called
many, simple, little, connected, finite element. As we all know, an object contains infinitely
many points. And this method starts with decreasing the number of infinite points to a finite
number. It is called "meshing". For example, you can represent the infinite numbers of points in
the heart muscle by meshing finite number without breaking its shape. These degraded points
are called "nodes". By combining these nodes, 1-2-3 dimensional objects are formed and called
elements. In this way, the finite elements model of the design is formed. Into the model,
necessary parameters could be entered and desired tests could be run by using computers. All
in all, the problem of the pieces bonded together with multiple nodes can be solved easily.

Our Project:

In this project, we have made a new spring model for 1 Dimensional Time-Stepping
problem that we have done in the lecture, implementing Mass Matrix to 3 Dimensional Truss.

Here you can find the summary of what we have done so far: We have chosen 12 points
and we have determined the locations of the points on the plane. We have fixed them from the
corners. We have used force to the point in for loop (it can be also gravity) and we have
observed the motions of the other points. In the future work part, we have made spring model,
using 3D Truss. Assuming there is spring between all points and giving a fixed k" we have
observed motions of them. In these processes, we have taken the start speed of the points or
balls as zero.

APPLICATIONS
- Mechanical/Aero/Civil/Automotive Engineering Applications
- Structural Analysis (Static, Dynamic, Linear, Non-linear)
- Heat and Fluid Calculations
- Electromagnetic Calculations
- Biomechanics Calculations
- Medical Applications

Here are some mass-spring simulation examples, which are related to our project.

1. Cloth Simulation
[1]

2. Gluteus Maximus and medius muscle modeling with FEM.

[2]

PROGRAM SOURCE CODE AND LINE BY LINE EXPLANATION


clear all, close all, clc

U and V array determines the number of nodes in x and y directions,


respectively, by changing the increments.

U = 0:(1/4):1;
V = 0:0.2:1;
u = U';
v = V';

c1, c2, c3, and c4 functions determine the x, y and z components of the points. C1, C2,
C3 and C4 arrays are the arrays of the points on the bottom, right, up and left edges of
rectangular, respectively. We set these right left upper and bottom boundary in the c1, c2, c3
and c4 functions.

C1 = c1(u);
C2 = c2(v);
C3 = c3(u);
C4 = c4(v);

We set the right, left, upper and bottom boundaries in the c1, c2, c3 and c4 functions.
For example the function for the bottom edge is as following:
function curve1 = c1(u)
x1 = 1 + (10-1)*u;
y1 = 1 + (1-1)*u;
z1 = 5 + (5-5)*u;

curve1 = [x1 y1 z1];


%end of the function c1

S1= s(0,0);
S2 = s(1,0);
S3 = s(0,1);
S4 = s(1,1);

We created a points array where we can keep all the points with their x, y and z
positions. The quantity of the points can be found by multiplying length of u with length of v.
Therefore the number of points can be changed simply by changing the length of u and v. Since
there are 3 components (x, y, z) of each point, creating points array with the initial values of
zero is as following:

points = zeros(length(u)*length(v),3);

In the following line we calculated the number of beams (elements) by adding all
horizontal beams to all vertical beams. We used rectangular shaped finite elements but not
triangle.

nel=length(U)*(length(V)-1)+(length(U)-1)*length(V); % number of elements


The following line means that every beam in the beam network are connected to 2
nodes.
nnel=2; % number of nodes per element

The following lines calculate number of degree of freedoms, total number of nodes in
the system, total degree of freedoms in system and set the constant values of elastic modulus,
height of the beam, cross sectional area of the beam. Option flag for the mass matrix
determines whether we are going to use actual mass matrix or lumped mass matrix method.
ndof=3; % number of dofs per node
nnode=length(U)*length(V); % total number of nodes in system
sdof=nnode*ndof; % total system dofs
el=100*10^9; % elastic modulus
xi=0.02^4/12; % height (or thickness) of the beam
area=0.004; % cross-sectional area of the beam
rho=1000; % mass density of the beam
ipt=2; % option flag for mass matrix

We initially set the values of point matrix as zeros. Following code set these zeros to
their actual values by using the transfinite interpolation.
for i = 1:length(u)
for j = 1:length(v)
points((j-1)*length(u)+i,:)= s(u(i),v(j));
end
end

The following for loop calculates the lengths of horizontal beams by creating an L array
and setting the values with the help of SpaceTrussElementLength function. This function
basically measures the distance between two points from their coordination.

%lengths of horizontal elements


tempvar = 1;
for i = 1:length(V)
for j = 1+length(U)*(i-1):length(U)*i-1
L(tempvar) = SpaceTrussElementLength(points((j),:),points((j+1),:));
tempvar = tempvar+1;
end
end

In the same manner, this for loop calculates the lengths of vertical beams and put them
after all lengths of horizontal beams are placed into the array.

%lengths of vertical elements


for i = 1:length(U)*(length(V)-1)
L(tempvar) = SpaceTrussElementLength(points((i),:),points((i+4),:));
tempvar = tempvar+1;
end

Following lines are for creating the angle arrays for each element. They are initially
zeros, however it is going to be set to their actual values with the loops.
thetax = zeros(nel,1);
thetay = zeros(nel,1);
thetaz = zeros(nel,1);

%angles of horizontal elements


tempvar = 1;
for i = 1: length(V)
for j = 1+length(U)*(i-1):length(U)*i-1
thetax(tempvar) = acos((points((j+1),1)-
points((j),1))/L(tempvar))*180/pi;
thetay(tempvar) = acos((points((j+1),2)-
points((j),2))/L(tempvar))*180/pi;
thetaz(tempvar) = acos((points((j+1),3)-
points((j),3))/L(tempvar))*180/pi;
tempvar = tempvar + 1;
end
end

%angles of vertical elements


for i = 1:length(U)*(length(V)-1)
thetax(tempvar) = acos((points((i+4),1)-
points((i),1))/L(tempvar))*180/pi;
thetay(tempvar) = acos((points((i+4),2)-
points((i),2))/L(tempvar))*180/pi;
thetaz(tempvar) = acos((points((i+4),3)-
points((i),3))/L(tempvar))*180/pi;
tempvar = tempvar + 1;
end

Following lines determines the time step size, initial time, final time and calculates
number of time steps.

dt=0.0001; % time step size


ti=0; % initial time
tf=5; % final time
nt=fix((tf-ti)/dt); % number of time steps

In the following lines, we created global stiffness and global mass matrices. The sizes of
these matrices depend on number of degree of freedoms of the system and therefore they
depend on the number of beams.
kk=zeros(sdof,sdof); % initialization of system stiffness matrix
mm=zeros(sdof,sdof); % initialization of system mass matrix
force=zeros(sdof,1); % initialization of force vector
index=zeros(nel*ndof,1); % initialization of index vector
acc=zeros(sdof,nt); % initialization of acceleration matrix
vel=zeros(sdof,nt); % initialization of velocity matrix
disp=zeros(sdof,nt); % initialization of displacement matrix

From now on, we are able to change our code for different trials and we are able to see
how the displacement of a node changes when boundary conditions are set and a force is
applied to any node with any angle.
We are first going to set the initial velocities and displacements of each node as zero.

vel(:,1)=zeros(sdof,1); % initial zero velocity


disp(:,1)=zeros(sdof,1); % initial zero displacement

We are applying force on the 17th (51/3) node in x, y and z directions. By changing the
indices of force vector as force(54), force(53), force(52) we can easily change the node that
force is exerted to in x, y and z directions. We can also change the amount of force by setting
different values.
force(51)= 100000; % tip load of 100 kN in z direction
force(50) = 100000; % tip load of 100 kN in y direction
force(49)= 100000; % tip load of 100 kN in x direction

Local stiffness and local mass matrices are 6 by 6 for 3 dimensional problems. By
multiplying the column size with the number of elements (nel), we aimed to add each local
stiffness and local mass matrices one after another and create bigger local stiffness and local
mass matrices arrays that contain each 6 by 6 local matrices.

k = zeros(6,6*nel);
m = zeros(6,6*nel);

The following for loop sets the values of local stiffness and local mass matrices.

for iel=1:nel

index=feeldof1(iel,nnel,ndof); % extract system dofs associated with


element

[k(1:6,6*(iel-1)+1:(iel*6)),m(1:6,6*(iel-
1)+1:(iel*6))]=febeam1(el,xi,L(iel),area,rho,ipt,thetax(iel),thetay(iel),thet
az(iel)); % compute element stiffness matrix

end

The following for loops add local stiffness and local mass matrices to global stiffness and
global mass matrices, respectively. Firstly, local matrices horizontal beams are added, then the
vertical beams are added.

tempvar = 1;
for i = 1:length(V) %% adding horizontal stiffness and mass elements
for j = length(U)*i-3:length(U)*i-1
kk = SpaceTrussAssemble(kk,k(:,1+6*(tempvar-1):6*tempvar),j,j+1);
mm = SpaceTrussAssemble(mm,m(:,1+6*(tempvar-1):6*tempvar),j,j+1);
tempvar=tempvar+1;
end
end
%%adding vertical stiffness and mass elements
for i = 1:length(U)*(length(V)-1)
kk = SpaceTrussAssemble(kk,k(:,1+6*(tempvar-1):6*tempvar),i,i+4);
mm = SpaceTrussAssemble(mm,m(:,1+6*(tempvar-1):6*tempvar),i,i+4);
tempvar=tempvar+1;
end

Inverting the mass matrix is essential because we need to multiply both sides of the
equation [M]*[d] t + dt = dt*([F]-[K]*[d] t) + [M]*[d] t with inverse of mass matrix. We used
pseudo inverse built-in Matlab function instead of inverse function since there was a row of
zeros in mass matrix that causes an error.
mminv=pinv(mm); % invert the mass matrix

Outer for loop calculates the acceleration of each nodes whereas inner for loops are
setting the boundary conditions of the problem. After calculating the acceleration, the outer for
loop also calculates the velocity and displacements.

for it=1:nt
acc(:,it)=mminv*(force-kk*disp(:,it));

for ibc= 1:length(U); %% stabilized bottom edge


acc(1+3*(ibc-1),it)=0;
acc(2+3*(ibc-1),it)=0;
acc(3+3*(ibc-1),it)=0;
end

for ibc= 1+length(U)*(length(V)-1):length(U)*length(V) %%stabilized upper


edge
acc(1+3*(ibc-1),it)=0;
acc(2+3*(ibc-1),it)=0;
acc(3+3*(ibc-1),it)=0;
end

for ibc= 1 : length(U) : 1+length(U)*(length(V)-1) %% stabilized left


edge
acc(1+3*(ibc-1),it)=0;
acc(2+3*(ibc-1),it)=0;
acc(3+3*(ibc-1),it)=0;
end

for ibc= length(U) : length(U) : length(U)*length(V) %%stabilized right


edge
acc(1+3*(ibc-1),it)=0;
acc(2+3*(ibc-1),it)=0;
acc(3+3*(ibc-1),it)=0;
end
vel(:,it+1)=vel(:,it)+acc(:,it)*dt;
disp(:,it+1)=disp(:,it)+vel(:,it+1)*dt;
end

acc(:,nt+1)=mminv*(force-kk*disp(:,nt+1));

The following lines plot a 2d displacement-time plot for a specific node in the specific
direction.
time=0:dt:nt*dt;
figure(1)
plot(time,disp(51,:))
xlabel('Time(seconds)')
ylabel('Tip displ. (m)')

The following lines plot all the points in 3 dimensional coordinate system.
figure(2)
plot3(points(:,1),points(:,2),points(:,3),'bo')
grid on
By the following lines, we can easily observe the displacements any point. An example
of how a point (18. node) moves is shown in the figure.
for i=1:5000
figure(3)
plot3(disp(52,i),disp(53,i),disp(54,i),'ro')
pause(0.00001);
grid on
hold on
end
FUTURE WORKS

In order to improve our model we defined our future works that can be very useful for
so many different applications and fields. Our first improvement will be the animation of the
entire system. For that, we will have to work with only the displaying part of the code. By
writing a for loop which includes the plot command and can count the all nodes of the system,
we can observe the motion of entire system.

After we obtain an animation for the motion of the system, we can implement our code
in to different applications. Actually, we can implement it every harmonic system which
contains spring and damper. We want to improve our code first for the animation of shortening
& elongation of heart muscles. To animate the contraction motion of heart, we will need a
different surface than our existing rectangular surface. We have to define a curved surface that
can represent a specific part of heart. To do that, we just need to modify our transfinite
interpolation code with the desired curve equations. For this animation we also have to add
contractile elements to the system. Contractile elements represent the contraction percentage
of muscles. Similar to stiffness and mass assembles; we will construct contractile matrices for
each element of the system. At the end of these additions, we can create and animation of the
contraction motion of heart muscles.

Additionally, we can also use our model for other system animations like expected
vibration of a bridge or expected reaction of any system to the wind. For example, to animate
the bridge vibration, first we need to define a more complex geometry than our existing
surface. Our entire system for bridge animation will be an assembly of lots of bar elements and
rectangular frames. After we define forces like weight and wind, we can solve and animate
problem by using our improved code.
CONCLUSION

With this project we first tried to come up with a code that divides the given geometry
to defined number of nodes whose coordinates are known. We used Linear Transpolation to be
able to create that nodal system. Then we built a model that simulates the motion of only one
node of a system. Our system was first stable then we applied force in desired dimensions.
Force can be applied either one node or more than one nodes. Then we observed the motion of
-preferably- the node that the force applied. However, by just selecting the displacements of
desired nodes, we can obtain the motion of the system with its nodes.

Our project also demonstrates the expected reactions of a specific system under some
force. Without performing experiments, we can solve problems and animate the system
reactions. By analyzing the results of our code, we can modify the experiment conditions,
determine the optimal system and perform the experiment according to our theoretical results.
However, considering and determining all conditions (environmental and other effects) for a
system cannot be always applicable and, most of the time, theoretical results cannot exactly
match with experimental results. But, this kind of models provides us better understanding into
critical design parameters, computerized (virtual) prototyping and less hardware waste for
prototyping. So, it improves design cycles and productivity.

In summary, by using our code, we can predict and compute theoretical reactions of
systems under defined force. So, we can virtually make prototype of the system that can
provide us very critical data, before making experiment or hardware prototype. This is the
reason that our model can improve productivity and quality of the experiment or design.
REFERENCES

[1] Baraff, David, and Andrew Witkin. "Large steps in cloth simulation." Proceedings of the 25th
annual conference on Computer graphics and interactive techniques. ACM, 1998.

[2] Glueck, Michael, et al. Modeling and simulation of skeletal muscle for computer graphics: A
survey. Now, 2012.

Anda mungkin juga menyukai