Stiffness matrix maker for continuous beams

I’ve been messing around with finite element method solution methods, partly for school purposes. I noticed that when I was compiling a stiffness matrix for a large system, I kept on making mistakes.

One of the best ways to get rid of mistakes, especially when they are due to sloppiness is to remove the human factor in the equation.
As the world is becoming more and more automated I think it should be standard procedure for any engineer to think how he or she could automate their work more.

What is a stiffness matrix?

In order to solve systems in a computerized way you need to reduce the model that you are analyzing to very discreet, finite elements.

For example if you are examining the stresses on a beam, you need to split up that beam in smaller beams that will allow you to get a clear picture of the entire system.

And in order to do that you need to use stiffness matrices. The global stiffness matrix of a system is no more than the sum of the individual stiffness matrices of the elements that compose the system.

stiffness matrix of a beam element

The small Excel script I made only takes a look at beams. Hence above is the stiffness matrix of a single beam element shown.

The stiffness matrix basically defines the relation between the forces acting on the element and the different spatial deformations that happen as a result of those forces.

This ties in to Hooke’s law: F = k*x. Where F is the force acting on a spring and x is its movement. k is what defines how much or how little a spring would change shape. k is called the spring constant, however in our analogy k is the stiffness matrix.

Summation of matrices.

The more complicated a system gets, the more elements you will need to get an accurate result from your calculations. As a result the global stiffness matrix is calculated by summing the stiffness matrices of the elements together in the following way:

In the above example we have a beam that is clamped on both ends and a force acting on the beam in the middle. We split this system into 2 analyzable elements. Without taking degrees of freedom into account, the stiffness matrix of this system is the sum of the two individual elements’ stiffness matrices.

We see that the common elements in both matrices are summed together and the remaining elements of both matrices simply used to fill up the gaps in the global matrix.

If we were to completely solve this example we would then “fix” some degrees of freedom in this matrix. As the beam is clamped on both ends it is impossible for it to move anywhere at either ends. Nor will it twist or turn as the connection to the wall is extremely stiff.

In this case the matrix reduces to a matrix where we only view V2 and Theta2.

How to use my excel in your homework assignments or self study practices.

I’ve written this program relatively fast as I needed to hand in the paper in a few days. Hence there are some bugs here and there.

For one make sure to always press “calculate stiffness matrix” before running any other calculations. If you press the “calculate force vector” button twice, your computer will freeze up.


  1. Always FIRST press calculate stiffness matrix and only then press anything else.

But other than that here is how it works:

You first you enter the Young’s Modulus, the second moment of area for the beam and the length of the beam. Also if there is a continuous force acting on the beam, now’s the time to enter its value.

Then you enter into how many elements you want to divide the beam. Unfortunately this quick excel only allows you to divide the beam into equally long elements.

Once you have clicked the “Calculate stiffness matrix”-button, you can then enter degrees of freedom as they appear in your problem. So for a clamped end you would select both X1 and X2 (translation at the first end and rotation at the first end are fixed).

Then simply add any additional point loads if there are any and finally press the calculate “calculate force vector and forces” button to get an overview of the external reaction forces of the system.

Some notes

As this was a quick and dirty fix for me, the program is buggy and some values are unnecessarily long stored in the memory. So just to make sure you get the right results you might need to click “calculate stiffness matrix” and then “calculate forcevector” a few times.

Basically run through the program a few times to make sure all values are the right ones.

I’ve for one noticed that on occasion it shows me the wrong result, but when I then click again on “calculate stiffness matrix” and then on the “caculate force-vector” it then shows the right result.

To make sure it works you can try and calculate some standard examples to verify for yourself that my program works.

For example you can calculate the reaction forces at the supports of a beam clamped at both ends. You’ll see that using my program then you’d need to select X1 and X2 as fixed, as well as X5 and X6.

If you defined a point load at the middle node (at X4) then you’ll find that the deflection value is (1/192)*F*L^3/EI, as well as the reaction forces at X1 and X5 to be F/2.


Hope this is of some help to someone!

For anyone looking for more information, I highly recommend this book!

Leave a Reply

Your email address will not be published. Required fields are marked *