Professional Documents
Culture Documents
In C++ Code
Devyn Kirban
Abstract
can have various components within them such as multiple springs attached to one mass and
multiple spring-mass systems attached to each other. In this paper, we will observe the forces
applied to a combination of spring-mass systems, form a stiffness matrix, find the inverse matrix,
and solve for displacements if under certain parameters using C++ coding.
Introduction
(a) The system before release. (b) The system after release.
Fig.1 shows an arrangement of three masses and four springs where after being released is purely
pulled downward by the force of gravity. In order to solve this problem for the unknown
decomposition with Gauss elimination using dynamic memory in C++ to solve them. We found
that with m1= 10 Kg, m2= 20 Kg, m3= 30 Kg, g= 10 m/s2 and k= 10 Kg/s2, the displacements
were 60m, 85m, and 115m. We then found the same values for the displacements by multiplying
Physical Analysis
The springs are made of the same elastic solid material, thus making the spring constants the
same. The system of ordinary differential equations satisfied by this system follows from
We know that at equilibrium, the mass finally reaches its steady state, the equations (1)-(3)
And:
are the column vectors of the unknown displacements and the known weights, respectively [1]. If
we were to find the inverse of the stiffness matrix, we could multiply it by the stiffness matrix to
get the identity matrix. The inverse means that it can reverse the stiffness matrix and it could be
beneficial to predict the displacements of the same mass-spring system with a different set of
Numerical Analysis
The numerical method we used was the LU decomposition with Gauss elimination using dynamic
memory to find the stiffness matrix. To solve a system where Ax=b, the LU decomposition
method involves decomposing A into a product between a lower triangular matrix L and an upper
triangular matrix U. Then, it involves a forward substitution solving Ly=b and a backward
substitution solving Ux=y. We calculated the inverse of the stiffness matrix by changing the b
array values to columns of the identity matric and running the code 3 separate
times so it would print out each column at a time for the inverse matrix.
[1]
Results
We used the LU decomposition code previously mentioned with the values: m1=
30 -20 0
-20 30 -10
0 -10 10
The code produced the solution of 60, 85, and 115. After running the code three times with the
Conclusion
When encountering vertical spring-mass systems, we understand that we must analyze the forces
applied, combine physics equations, and create a matrix to solve. No matter the amount of
systems inside one larger system, the various components can be solved in this way. By using
C++ coding with LU decomposition, it made it relatively easy to solve for any displacement with
varying weights and a different spring constant. Overall, using these methods allow you to
predict the behavior of mass-spring systems before observing them in reality and could provide
References
[1] Dr. Corina S. Drapaca, ESC 261M: Computational Methods for Engineers, Lecture 10 & 11.
IntArrayPtr; void
int main() { int n; cout << "Enter the row and column
int i,
j,k;
= new double[n];
cout << "Enter " << n << " rows of " << n << " integers each:\n";
{
for (i=k+1; i<n; i++)
m[i][k]=factor;
m[i][j]=m[i][j]-factor*m[k][j];
print(m,n);
double sum=0;
double b[3]={100,200,300};
{
sum = b[i];
} b[i] = sum; }
double x[3];
sum + m[i][j] *
x[j];
m[i][i];
delete[] m;
return 0; }
To find inverse: