Using the Onboard Eigenvalue Function

March 15th, 2016 by Mahdieh Mehrabi

Introduction

This article introduces the use of the Dymola function for calculating eigenvalues, with syntax, inputs and interpretation of outputs. It’s also intended to present some examples of diagrams produced in the software that can provide insight into linear systems, and explain a little about what eigenvectors and their eigenvalues are.

There is a separate article that contains a practical example which was chosen to be as simple as possible, that lists some places in engineering where the ideas discussed come up. Some sample code is also included, but note that the diagrams generated come from scripting multiple runs of the code!

Modelica.Math.Matrices.eigenValues

Enter the information in the way described by the following table.

Figure 1_Using the eigenvector function to obtain eigenvectors and associated eigenvalues_2

Figure 1. Using the eigenvector function to obtain eigenvectors and associated eigenvalues

It’s common to say for example that there are a specific number of eigenvectors associated with a matrix1. One really means “eigen-directions” or “eigen-ratios”. Any scalar multiple of any eigenvector is also an eigenvector – so it is the relationship between the components that is key!

By convention eigenvectors are given either as unit vectors, or with the largest component set to unity. In Dymola, the former is used. For useful worked examples that underline and illustrate this, see (Boyce & DiPrima, 2001) or any similar text elaborating linear systems of differential equations.

Phase Portraits

Dymola can model several trajectories, such as the example below.

The diagram below results from integration of the linear system using the matrix2for a range of different initial conditions. The trajectories all converge to an (1) eigenvector (running top left to bottom right) as1.3.1and the other (2) eigenvector (running bottom left to top right) as1.3.2.

Each line corresponds to time integration of the linear system of two coupled differential (Boyce & DiPrima, 2001) equations, based on different initial conditions, i.e. starting values. In this diagram, a series of lines starts in the bottom right, and top left of the diagram, and another series is begun in a circle around the centre.

(3) The lines whose initial conditions place them (very nearly) already on the eigenvector direction with positive real eigenvalue just keep travelling outward along that eigenvector direction, in a straight line.

Figure 2

Figure 2. A phase portrait –with real eigenvectors that are clearly visible (black arrows, labelled 1 & 2, and their counterparts in the opposing directions.) There are trajectories (indicated by the red dotted arrows and “3”) that show a path which is already on an “outward” (i.e. positive-real eigenvalued) eigenvector, and therefore simply continues in a near straight line along it.

Figure 3

Figure 3. With complex eigenvalues/vectors the variables vary sinusoidally according to De Moivre’s law

The matrix of coefficients used for the above system is3.

The spiral phase portrait is the mathematically “more difficult”, but it represents a large class of real systems. A linearised pendulum (hanging down this time) with damping spirals inwards. That means any initial condition results in the speed and displacement oscillating, 90 degrees out of phase.

The elliptical form of the diagram confirms the sinusoidal evolution of the variables, as opposed to the exponential evolution where the eigenvalues are purely real, which we would expect from the second order differential equation in the example (see :).

Example Code

Result Array Dimensioning Requirement

There are aspects of Dymola that aren’t available via this function because of the way the external routine reports an output back to the programme. (View in PDF)

Figure 4

Figure 4. Code not providing sizes of results matrices explicitly fails when using eigenValues

Full Example Model (on a 2×2 linear system)

This is a complete example of the Modelica code demonstrating the use of Dymola’s in-built eigenvalue function. The function is applied to a 2×2 linear matrix, A. In this example the eigenvectors and eigenvalues of the matrix are written to a text file; the values are shown at the end of Figure 5. Try copying this code into Dymola to test the eigenvalue function yourself.

Click here to view the Full Example Model

Figure 5

Figure 5. Code to obtain eigenvectors and write to file

Interpretation of Results & Applications

The idea of eigenvectors and their associated eigenvalues is a central idea in linear algebra so some further exploration has been provided with some interesting references for students and professionals who want an orientation or reminder of important points. Areas of engineering where these pop up, and where one might use the Dymola functions discussed are provided for illustration.

The Concept of Eigenvectors

The “eigen” (meaning own or self) vector of a matrix results in a scalar multiple of itself when operated on by the matrix.

For example, if Mv = 5v then v is an eigenvector of M (because v and 5v have the same direction / ratio between entries). The associated eigenvalue 1 is then 5. M will always scale v by a factor 5.

In the general case, the terms in the eigenvectors, and the scale-factors (that is: eigenvalues) will be complex numbers. A 2D vector in which each term has real and imaginary parts is difficult to visualise, and scaling by a complex factor is hard to conceive of too.

Figure 6

6.1

Example applications, and a familiar worked example are to be found in the companion article.

By: Sas Harrison – Systems Engineer

 

[1] Eigenvalues are very often complex numbers however

References

Adhikari, S. & Srikantha, P. A., 2008. Rayleigh Quotient and Dissipative Systems. Journal of Applied Mechanics, p. 6.

Boyce, W. E. & DiPrima, R. C., 2001. Elementary Differential Equations & Boundary Value Problems. 7th ed. Troy, NY: John Wiley & Sons Inc..

Inman, D. J., 2001. Engineering Vibration, Second Edition. Upper Saddle River: Prentice Hall.

Inman, D. J. & Lallement, G., 1995. A Tutorial On Complex Eigenvalues. Orlando FL, Society for Experimental Mechanics.

Lay, D. C., 1997. Linear Algebra & It’s Applications, Second Edition. Boston MA: Addison Wesley.

Ruijgrok, P. i. d. G. J. J., 1990. Elements of Airplane Performance. Delft: Delft University Press.

Various, 2015. http://www.netlib.org/lapack/. [Online] Available at: http://www.netlib.org/lapack/[Accessed 22 December 2015].

Wakker, p. i. K., 2001. Astrodynamics Lecture Notes – AE4874 I. Delft: Delft University Press.

Archives

2017

2016

2015

2013

2012

2011

2010