Modelling and Simulation (Part 1)4 min read

By | February 2, 2018

The previous post introduced the concept of looking at all physical processes as mathematical models. In this article we will look at converting your computer into a lab by not just talking about it, but actually doing it as well. While the previous article served as introductory material, I think it didn’t do justice (enough) to the topic so I will try and cover some more background in this post before we actually delve into a minimal working example.

Mathematical models:

Caution: Some math involved.

In the previous post I listed some examples of how to make a simple mathematical model from empirical observations. In this post I am going to list a few more and the level of complexity associated with them.

As an introductory model we will look at the behaviour of a spring (which is a common text book example to introduce new students to modelling). A spring, simply put, is a coiled structure that when extended from its resting position and released will try to return to its resting position.

In the act of extending the spring, one end fixed and the other stretched to increase the length of the spring, what you have done is added potential energy to your system (i.e. the spring) and when you release it that potential energy will be converted to kinetic energy to take the spring’s extended portion to its resting position, but when it reaches that resting position, not all of the energy added to the system has been dissipated as the relaxing part of the spring still has kinetic energy. So it moves past the resting position to the other end, during which it tends to decelerate until it reaches the other extreme of being compressed. The back and forth motion of the spring’s perturbed end will continue until all the the energy is dissipated to the surrounding as heat (from friction between the spring’s moving parts and the air) or vibrations from the spring’s motion that are set up in the fixing mechanism. See this simulation which is something we are aiming at.

The above description explains the behaviour of conventional springs. Now let us break that behaviour down and make a mathematical model out of it for which I will introduce the Hooke’s law. This law states that the amount of force required to stretch the spring is directly proportional to the distance you want to stretch it “x” so if 1 Newton (N) is the force required to pull a spring A by 1 meter (m) than you will need 2 Newton to pull the same spring by 2 meters. This can be expressed mathematically as:

Force (required to pull the spring) x (distance to move)

The above expression can be written as:

F = k * x

Where k is the proportionality constant for a given spring.

Now the above expression tells you the force required to pull a spring by a certain distance.

Simple simulation:

So let us try and get some numbers (data) out of Hooke’s law.

Assume a spring with k = 0.5 N/m.

The expression can then be written as

F = 0.5 * x

and to get some number out of it we have to put in different values of x.

For this exercise we can take values of x between 0 and 2 meters. So I am going to save you the work and calculate some of these values for you and plot them.

x (m) k (N/m) F (N)
0 0.5 0
0.25 0.5 0.125
0.5 0.5 0.25
0.75 0.5 0.375
1 0.5 0.5
1.25 0.5 0.625
1.5 0.5 0.75
1.75 0.5 0.875
2 0.5 1

Figure 1: Trend of force required to displace a spring from its mean position.

Now this exercise allowed you to calculate the values of Force at each desired displacement of spring from its mean position “0 m”.

This, however, isn’t very interesting because what this doesn’t show you is how the spring behaves once its released after being stretched e.g. like in this simulation or this other simulation. That requires the use of differential equations and I would like to explain some programming and math basics before I post on that. For now lets leave this temporarily here and introduce a bit of Python and how to calculate the table of values shown above slowly working our way towards the use of differential equations and more advanced libraries e.g. like Matplotlib for making plots etc. See next post for a simple starting Python program.

 

Please like share and subscribe IDRACK’s Facebook page and group. Talk to your friends about us and, as said before, if you have any questions and problems following all this, please feel free to get in touch, either in comments below or Facebook or through details on our Contact Us page.

One thought on “Modelling and Simulation (Part 1)4 min read

  1. Pingback: Programming with Python: A simple example

Leave a Reply

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