 # Analyzing N Order Spring-Mass Oscillator System using Gauss Seidel

by admin in on May 5, 2019

This is a MATLAB program to analyze the spring-mass oscillator system shown in the following figure. Spring-mass systems play an important role in mechanical and mechatronic engineering systems. Here, we consider a system consisting of n masses, suspended vertically by a series of spring (ki, i=1,2,…,n) as shown in figure at the right. Initially, at the moment these masses are attached to the springs, each spring elongates by a certain amount due to gravitational force, which therefore brings the overall mechanical structure to a static equilibrium position (rest position). The application of an external force (i=1,2,,n) on the i’m mass causes the whole spring-mass system moving along the vertical direction (up or down depending on the direction of the force). In other words, any external force applied to one mass results in a new equilibrium for all masses. The variable xi (i=1,2,…,n) next to the it” mass indicates the amount of displacement of the mass from its initial equilibrium position (when the force =0) due to one or more external forces applied. At the rest position (when no force is applied), the displacement of each mass is assumed to be 0.
This code determines the amount of static displacement (displacement at the steady-state) of each mass in the system from its initial equilibrium state (xi=0, for i=1,2,…,n) when three external (constant) forces are applied on three specific masses: the first mass (mass 1) and the last mass (mass n), and another intermediate mass selected automatically by the program as follows:

• If the number of masses n is even, then the intermediate mass is n/2
• If the number of masses n is odd, then the intermediate mass is (n+1)/2

The program consist of four main codes: Gauss_Seidel.m, MatrixK.m, VectorB.m and Gauss_Seidel_Interface2.m, Gauss_Seidel_Interface2.fig. The first three files can work independently starting at the main file “Gauss_Seidel”. On the other hand, we can work from the interface “Gauss_Seidel_Interface2”.

Program Inputs are:

• System Order (Unlimited).
• The K vector of elasticity factors of springs
• The F vector of outer three forces
• Tolerance
• Number of Iterations NOI.

Program Outputs are:

• K Matrix of elasticity
• Numerical Solution by Gauss-Seidel
• Exact solution
• The F vector of the outer forces in the n form
• Relative error
• Number of significant digits.

Program Interface: “Gauss_Seidel_Interface2”

The interface consist of two files: Gauss_Seidel_Interface2.m and Gauss_Seidel_Interface2.fig. The first one has the editable commands and formulas, the second one has the interface figure where the buttons and editable texts and tables. The other attached files are: MatrixK.m and VectorB.m.

The interface has the form in the figure 1, where we have five inputs: System Order, K values and F Values (which modify as soon as the clicking on the button Enter), Tolerance and Max. number of Iterations.

Note: First, enter the System order, then click on the button Enter and start entering the other values. Figure 1 – The interface

The figure 2, has an example of 3 order system. The output values are listed above. Figure 2 – Example of 3 Order system

Gauss–Seidel method, also known as the Liebmann method or the method of successive displacement, is an iterative method used to solve a linear system of equations. It is named after the German mathematicians Carl Friedrich Gauss and Philipp Ludwig von Seidel, and is similar to the Jacobi method. Though it can be applied to any matrix with non-zero elements on the diagonals, convergence is only guaranteed if the matrix is either diagonally dominant, or symmetric and positive definite. It was only mentioned in a private letter from Gauss to his student Gerling in 1823. A publication was not delivered before 1874 by Seidel.

### The Literature of Gauss Seidel:

The Gauss–Seidel method is an iterative technique for solving a square system of n linear equations with unknown x: It is defined by the iteration where x(k) is the kth approximation or iteration of x, x(k+1) is the next or k + 1 iteration of x, and the matrix A is decomposed into a lower triangular component L*, and a strictly upper triangular component U: .

In more detail, write out Ax and b in their components: Then the decomposition of A into its lower triangular component and its strictly upper triangular component is given by: The system of linear equations may be rewritten as: The Gauss–Seidel method now solves the left hand side of this expression for x, using previous value for x on the right hand side. Analytically, this may be written as: However, by taking advantage of the triangular form of L*, the elements of x(k+1) can be computed sequentially using forward substitution: The procedure is generally continued until the changes made by an iteration are below some tolerance, such as a sufficiently small residual.

Share Now!

• Price
:

\$14.99

• Released
:

May 5, 2019

• Last Updated
:

May 28, 2019