Welcome to the World of Modelling and Simulation

What is Modelling?

This blog is all about system dynamics modelling and simulation applied in the engineering field, especially mechanical, electrical, and ...

My First Code in Python: Adding all Prime Numbers

As Python programming is highly hyped now-a-days and a frequent buzzword in machine learning and AI communities, I have decided to get myself familiar in this area. As I learn and decipher the Python coding day-by-day, I will be more than happy to share my coding in this blog. Here is my first program in Python - to develop a logic that adds all prime numbers between 0 and a given number.

We know that a prime number is an integer, which is greater than one and which is only divisible by one and itself. The following shows an algorithm that adds all prime numbers between 0 and a given number.

Development of an algorithm to add all prime numbers between 0 to n

I. First, we define the lower and upper number to initialize the program. For example, we set the lower number 0 and upper number 10; and we are interested to find the summation of prime numbers in this range.
II. Prime number is greater than one, so our logic begins that it must be greater than one. Therefore, we begin with number 2 and list all the numbers in our range.
III. Since, prime numbers are divisible only by itself and one; we create a loop, which confirms the prime numbers, and display them. We implement this by checking if the remainder of the number is zero or not. If the remainder is zero, then it is not a prime number.
IV. If the remainder of the number is not zero, then it is a prime number.
V. Display the prime numbers in the defined range and group the numbers in a list or array.
VI. Finally, we add all the prime numbers in the list.

The following Python code is developed based on the above algorithm, which displays all the prime numbers in a given range and add those numbers:

lower = 0

upper = 10     #Defining the range

sum1 = 0       #Setting Summation of prime numbers to zero

print("Prime numbers between", lower, "and", upper, "are:")

for num in range(lower, upper + 1):

   if num > 1:                 #Prime number is greater than 1

       for i in range(2, num):

           if (num % i) == 0:  #Calculates & checks remainder of division

           print(num)  # Displays prime numbers
           sum1 += num

Program Outputs:

Prime numbers between 0 and 10 are:

#Blog #Blogger #Python #PrimeNumber #Algorithm

Looking for an Industrial Partner to Implement a Lemon Shaped Guide to Minimize Rubbing


In industries, rotating machines are widely used, because rotation offers a great way to transfer power from one point to another and convert motion to different planes by gears, belts, shaft etc. A rotating machine typically includes a rotor, bearings and a support structure. There are critical relations among these components where each component of a system influences the overall dynamic behavior of a machine. For example, rotor-to-guide rub degrades a mechanical system over the years and may even cause fatal accidents earlier. It is, therefore, paramount in industries, to run rotating machines, operating at high speeds smoothly and reliably. The primary reasons of rubbing between a rotor and a guide are due to a manufacturing error, excessive imbalance, misalignment, bearing wear, smaller radial clearance between the rotating shaft and casing, bad assembly, etc. Rub occurs in rotor casing, seals, unlubricated journal bearings, loose rotor guide attached to restrict a large deflection. The problem is prevalent in the industry and demonstrated in several literatures. To deal with this problem, the industry has already been using circular shaped guide to minimize excessive vibration between a rotor and a stator. Although, the circular shaped guide may reduce the vibration, but the rub, between rotor and guide, may still be present, which may lead to the permanent damage of a mechanical system. The lemon shaped guide is not only effective in minimizing rubbing between rotor and stator, but also it suppresses the excessive vibration similar to the circular shaped guide.

The following video shows an experiment on how to minimize rubbing between a rotor and a guide that typically happens in a high speed rotating machine with a newly developed lemon shaped bearing or guide. We see here as the speed goes high, the system enters into its resonance frequency where it vibrates excessively. The lemon/elliptical shaped guide helps prevent the excessive rubbing while the rotor-bearing assembly is in the natural frequency zone. It has been found from our research that the lemon shaped guide minimizes rubbing better than the circular shaped guide where there the rotational speed is very high (https://doi.org/10.1115/1.4043817). 

The next video shows an experiment on how to minimize rubbing between a rotor and a guide that typically happens in a high speed rotating machine with a circular bearing or guide. This is a traditional approach, which has been in operation in industries for long. We see in the video, as the speed goes high, the system enters into its resonance frequency where it vibrates excessively. The circular guide helps prevent the excessive vibration while the rotor-bearing assembly is in the natural frequency zone. However, if we notice carefully, the rubbing is still present between the rotor and guide, which deteriorates the system gradually.

A US provisional utility patent (US Patent App. 62/956,833) has already been filed for this design. I am looking for industrial partners or investors if they are interested in investing this product.

Learning Mathematica, Lesson 1: Plotting a Function

This is the very first lesson or tutorial on Mathematica. As I am in the process of learning this tool, I will gradually post more articles on this, ranging from basic to advanced level problems. So, the first question is, what is Mathematica? It is simply a tool for computing, but it has an advantage that the symbolic expression is much user-friendly and more interactive than MATLAB.

Although, MATLAB is a much bigger platform than Mathematica, because MATLAB has numerous toolboxes and libraries that are designed for specific fields. Nevertheless, Mathematica, a product from Wolfram Research, is great for symbolic and interactive computing with a very neat interface. You may try it for free here just to see its environment. Let's start, how Mathematica looks like. After you install it (which isn't complex, it's pretty straightforward, if you just follow the instructions), click on your desktop shortcut and it will look like the following:

how Mathematica looks like

Then, you need to click on the "Documentations" to proceed which will bring the following:

how Mathematica looks like

Now, if you like to start writing you very first code on Mathematica, then click File, and select Notebook.

how Mathematica looks like

Now, write you first code here, and execute it. Let's say, we like to plot a function which looks as follows,

plotting a function in Mathematica

To execute the program above, you need to click on Evaluation and then, select Evaluate Notebook. The variable X varies from 0 to 5.

#Mathematica #Matlab #NoteBook #MatlabvsMathematica #Blog #Blogger

A SIMULINK Model to Solve a Simple Shaft-Disk Dynamics Problem

The following figure 1 represents pretty simple model where two circular disks of inertia J1 and J2 are mentioned. Torque (T) is applied to the disk 1. The shaft has its own stiffness which is K. 

two disks are connected by a shaft
Fig.1: Showing a very simple model where two disks are connected by a shaft and torque is applied to one of them.

At first, let's find the state variables for this problem and then write the state equations.

State Variables and State Equations:

State variables

State equations

Next, we assume the following key parameters,

Initial Conditions:

Initial conditions

Parameter Values:

J1 = 100, J2 = 100, K = 100, and T = 10000. (All values are considered unitless for simplicity)

The SIMULINK model is formed by implementing the state equations. And, the above parameter values are considered. The following simulation results are for the acceleration, velocity and position of the disks which are essentially the outputs from the SIMULINK block diagram.

SIMULINK model of shaft-disk system

Fig.2: SIMULINK model of the shaft-disk system.

Showings the results of angular acceleration, velocity and displacement respectively of disk 1
Fig.3: Showings the results of angular acceleration, velocity and displacement respectively of disk 1.

angular acceleration, velocity and displacement respectively of disk 2
Fig.4: Showings the results of angular acceleration, velocity and displacement respectively of disk 2.

#Simulink #Matlab #ShaftDisk #BlockDiagram #Blog #Blogger

Theory of Energy Conversion in Wind Turbine

In wind turbine, the wind energy is converted to first mechanical energy, and then this energy is converted to electrical energy. Damping is an essential part for a generator. However, it is not the key factor for energy conversion. If there were no damping or loss, we would have 100% efficient conversion. This is not possible in real life, as we would have certain losses during the energy conversion process. These losses are represented by non-conservative forces, such as friction, viscous damping etc. which are the essential parts to be considered in the energy conversion process. I want to show the fundamentals behind energy conversion in DC motor.

DC motor converts electrical energy (input voltage) to mechanical energy (shaft rotation). This electromechanical conversion involves Faraday’s law of induction and Ampere’s law for force generated on the conductor moving in a magnetic field. In ideal situation, the torque (T) developed on the motor shaft is proportional to the input current (I) and the induced electromotive force (EMF) (V) or back EMF is proportional to the speed (W) of the motor. This can be expressed as [1];

T = K1 I ..........................................................(1)

V = K2 W .......................................................(2)

Where, K1 and K2 are the proportionality constant.
The electrical power (Pe) input to the motor is the product of the induced EMF and current.

Pe = VI = K2 W T / K1  ..................................(3)

And, the mechanical power output (Pm) is the product of the speed of the motor and torque.

Pm = T W .......................................................(4)

Now, by comparing equation (3) and (4), the following relation is obtained.

Pe = (K2 /K1) Pm  ...........................................(5)

From Ohm’s law, it is known that,

E - V = I R  ..................................................(6)

Where, E is the input voltage to the motor, and R is the resistance of the motor armature.
Moreover, we also know that torque produced at the motor shaft is equal to the product of the inertia of the load (J) and rate of change of angular velocity or angular acceleration.

T = J (dW/dt)  .............................................(7)

Now, from equations (1), (6) and (7), it is found that

J (dW/dt) = K1 I = K1 / R (E - V)  ...........................................(8)

Using equation (2) further, the following expression can be established.

dW/dt = (K1 K2 / J R) W + (K1 / J R) E  ..................................(9)

The above equation refers to the first order linear differential equation model where ‘W’ represents the state of the system and ‘E’ is the external control input. This first order equation is good enough to predict the output speed of the motor. However, in terms of measuring the position’ it is necessary to add the following equation.

W = dθ / dt  ...........................................................................(10)

Where θ is the output position of the DC motor and refers to another state of the system. Therefore, the model has one control input and two state variables (position and velocity).

By the above mathematical analysis, I want to specify, that the electrical energy is converted to mechanical energy by a gyrator which has a constant ratio K. Here, resistance of the armature is the energy loss during the conversion of electrical to mechanical energy which is also mechanical equivalence of a damper. A damper not only signifies the energy dissipation/loss from a system, but also helps to make a system stable by removing oscillations.

[1] Control system design : an introduction to state-space methods / Bernard Friedland.—Dover ed.