 Hello, the next topic that we are going to see is how to model oscillations using system dynamics models. Let us see what do you mean by oscillations. In an oscillatory system, the state of system constantly overshoots its goal or the equilibrium state reverses and then undershoots and so on. Oscillations as you all might have seen is an example could be a say a sine wave or a cos wave. These are examples of system that constantly oscillates. So, oscillations are observed in variety of systems. Most common ones are mechanical systems that we are used to are also in socioeconomic systems and many other aspects of science, we can see such oscillatory behavior. These oscillations are also caused by negative feedback loops with addition that negative feedback loops which has delays results in oscillations, we will see more of that as we go along in today's lecture. Here is an example of oscillations of mechanical systems. The first one is a simple spring balance and on the right side you see a simple pendulum. In both these systems as you can see there is no friction and the system is oscillating about its mean value. In case of simple pendulum it is oscillating about its mean or resting position. Let us look at another example from some other domain. Here on the left side you can see is a image of a normal ECG there is nothing but your heartbeat which measured using the electrocardiogram there is nothing but an oscillations that you can observe with repetitive pattern along the time axis and in the right side what you see is an example of oscillations in business systems. In most of the business systems is characterized by growth which peaks and then followed by a recession which results in a trough and then again the business expands and reaches a second peak and so on and so forth. In this example that is shown here the business there is also an overall growth within the system that is every subsequent peaks is at a higher level than the previous peak that results in actual growth but in typical oscillatory systems such growth need not occur. So, in this case there is both oscillations as well as growth within the system. Here is another example of oscillations this what this graph illustrates is how the population of two different species varies over time. One is the higher population which is shown on the left vertical axis and the values are shown by the blue line and in the right axis we have the population of lynx, lynx is nothing but a large cat which hunts and eats the rabbits. So, the rabbit is the prey rabbit is the prey and lynx is the predator. So, as you can see the population of the prey as well as the predator seems to increase and then fall down and again go back and increase then fall down and keep oscillating, keep oscillating over time. As you can see the x axis goes from 1840s all the way to 1940s over 100 year period you can see the population of lynx as well as the rabbits oscillate. On the left axis you can also observe that the higher population is in 40s to 160 where the lynx population actually is 3 is around from 0 to 12 so very less predators are needed and the prey population is usually very large and whenever the prey population becomes very large for example here you can see the higher population hitting a very large number but subsequently the lynx are going to hunt these preys and the prey population is going to diminish which will result in an increase in the predator's population which again peaks as less and less prey are available the predator population also is going to fall down. As less predator is there that is less predators hunt the prey that is the higher in this case so the higher population is going to thrive and their population is going to increase at a much faster rate and so on and so forth. Now what are the SD structures that causes such oscillations? So the graph on the top left illustrates typical oscillatory behaviour which you can expect where the system state goes up overshoots and then undershoots the goal of the system which is represented by a horizontal line. Now let us first observe the causal structure that is shown on the bottom left. Here you can see we have a state of the system, we have the goal of the system, we have the state of the system, we have the goal of the system and a difference between the state and the goal is observed as a discrepancy and based on the discrepancy some corrective action is taken which affects the state of the system. This loop is a negative feedback system. However, what addition to the system is the presence of delays the first delay that is understanding the state of the system and seeing whether it is how away from the goal it is that is called as a measurement reporting and a perception delay and once the discrepancy is observed again there could be administrative and decision making delays before we actually decide what action to take and even after we take decide what action to take it takes some time to do the action itself that is indicated as action delay in this causal loop model. So as you can see any such presence of any single delay within a negative feedback system is going to result in oscillatory behavior which is kind of summarized here that is overshooting arises from presence of significant time delays in the negative feedback loops. This is because a control action right here is not based on the current system state but on some previously perceived values that is there is some delay in understanding what is the current state of the system and then acting on it and these delays again cause corrective actions to continue even after the goal is reached first in system to adjust too much and triggering a new correction in the opposite direction. Hence we get a overshooting the goal as well as undershooting the goal because you are trying to get it back to the goal and then you realize that you are undershot the goal then again you take some corrective action but then you end up overshooting the goal and so on. Thus a negative feedback system with a significant time delays any one or more delays in any of these links will result in oscillatory behavior within the system. So when you are modeling a system and we understand that there is going to be negative feedback within system if there is significant time delays that will result in oscillatory behavior and this time delays has to be captured within the model explicitly to get the desired system behavior. With that let us go ahead and see what are the types of oscillations that we actually typically encounter. Sustained Oscillations this is the first type of oscillation we are all familiar with which was also shown in the previous slide. So sustained oscillations are this is state of the system so over time the oscillations are not going to diminish it is just going to keep continuing at the same the constant amplitude and there is no stable equilibrium that is actually reached. We can also have damped oscillations amplitude of oscillations dissipate over time and a stable equilibrium is reached an example of that behavior should be something like this where over a long period of time the system is going to converge to some steady state or stable equilibrium value. In exploded oscillations this you can imagine as a system which is actually quite unstable that is we start with a small amplitude and the amplitude just keeps growing bigger and bigger with time. So such systems are said to have exploded oscillations as amplitude increases over time. In many cases this growth in amplitude could even be exponential in nature. A fourth type which if it is not going to adhere to any of these three options of sustained oscillation or damped oscillation or explode oscillations we call them as chaos oscillations where the random time path does not really repeat itself and the amplitude is quite irregular in nature a typical example could be the weather. With this let us build a system dynamics model of a system and capturing this oscillator behavior. As an example we are going to take a look at a simple pendulum model as shown here a simple pendulum consists of a small point mass suspended by rigid rope we are familiar with that and when we are actually trying to model the simulation of a system we usually neglect the mass of the rope neglect friction. Now let us just observe what is happening here. Now when we say a pendulum is moving what do you mean by that? If you observe the left hand side figure it becomes readily apparent. As you can see the red line actually captures oscillatory behavior. Now what oscillates here? What oscillates is the position of this pendulum. Initial pendulum is in the middle and then when it starts to oscillate it moves from one extreme end to the other in such a way that the position keeps changing between the two extremes. Now what else happens in the pendulum? You can see from the right side figure that so in the right side figure we have two arrows one is a blue arrow and other is a red arrow. The blue arrow represents a velocity on the pendulum of the pendulum and a represents the direction of acceleration on the pendulum. We will come back to that in a minute. So now to build a stock and flow model we need to initially define what are the stocks and what are the flows. So we will do just that. Here is a very kind of a typical figure of a pendulum and so we can define this point as a 0.0 and perhaps this as plus 1, plus 2, plus 3 and so on and perhaps here as minus 1, minus 2, minus 3 and so on. So this position or the initial position we typically denote it as the equilibrium position or in system dynamics parlance we can call this as the desired position. That is what we are saying is this is a desired position of the pendulum and wherever it is while it is moving the pendulum will always try to come to this desired position or the equilibrium position. Now this suppose we move the pendulum a bit to the right we get let us denote this distance as say x which is nothing but the displacement or rather the which is nothing but the gap between the desired position and the actual position that is the gap between desired position and actual position. Now based on this description we can safely say that we need to define position as a stock. So we are going to keep track of this position as a stock. Now let us see what happens when the pendulum actually swings at the extreme position on the right or you can observe that the V keeps reducing as we move towards the extreme point and at the most extreme end the value of V comes to 0 that is when position at max displacement the velocity is 0. Again why did you get the velocity the change in displacement is nothing but velocity. So your dx by dt or the change in displacement over time is defined as a velocity and at max displacement the velocity is 0 and at the equilibrium position velocity is maximum this actually causes it to overshoot. And now you saw that the velocity is maximum at the equilibrium position and minimum at the extreme position and it keeps oscillating. So in that sense velocity also oscillates. Now let us define velocity also as a stock. Now we know that this position stock will be need to be changed by your flow. So what flow could it be? The change in position can be defined by the change in position or the displacement which can be act as a flow which affecting this position or nothing but the velocity. Now what affects a velocity over time? So what is the flow that goes into this velocity stock? The flow into this velocity stock will be the change in velocity. So the change in velocity so the change in velocity is also known as acceleration. Go ahead. Now to understand a bit more on the model part let us come back to this model. Now we have this displacement x let l be the length of the rod. Now on this point mass we know that a force acts at that force be the force acts which is nothing but the gravity g. Along the length of the rod we are going to have a tension which acts up against the rod and perpendicular to the tension is what we are going to have is acceleration a. A is the acceleration. Now we actually can see two different triangles. One is a triangle formed by this x and l and it is equilibrium position here which is defined by this theta and another triangle formed by this g as well as a which again forms a triangle and using simple trigonometric relations it is easy to show that both these angles theta are actually the same. So one triangle we have which is formed by the displacement x and the rod length l. The second triangle is formed by the gravity g and acceleration a on the point mass. So we have these two triangles. So basic trigonometry can help us show that x by l will be equal to kind of approximately equal to a by g or a is approximately equal to g by l into x that is acceleration is equal to your gravity divided by the rod length multiplied by the displacement and acceleration again we already seen is nothing but your change in velocity. Now with this we can actually move on to the model. Typically we know gravity is defined as 9.8 meters per second square that is first of gravity which is the same which is what we are going to use in this model also. So now coming back and summarizing the stock and flow model the stocks we are going to define two stocks or we have already defined two stocks one is the position that there is the velocity and position is going to be defined by the flow of change in position is nothing but the velocity and velocity is going to affected by the change in velocity or the acceleration. Now it is important that units has to be consistent. So we know the change in velocity of acceleration is meter per second square velocity is meter per second position can be given a units of meter and change in position is given by meter by second this all the flows are over time and of the respect to stock that they are going to affect. So this is a model that we are going to build we need to use some other values so we will be using the value of gravity as 9.8 meters per second square and value of rod length L as say 1 meter. So G is 9.8 meter per second square and rod length L will just take it as 1 meter. Now all the units are consistent let us define one more variable called as desired position which will be at 0.0 then we can define a gap which is nothing but the displacement as the gap between the desired position minus the actual position the stock position is going to be capturing the actual position. Now let us look at the model. An image of the model shown here as you can see we have a position we have change in position and we have the gap and the velocity which is affected by the change in velocity and we have gravity in the length of the rod. So the change in position the equation for that is nothing but is equal to velocity and the change in velocity is simply given as gravity divided by length length of rod multiplied by the gap and the gap itself as defined is given as difference between desired position and the actual position. The units was described earlier. Again when building this model we will use a small time step and RK4 integration for better precision. Now we are going to go and simulate this in Vensim first we are going to start the model at dynamic equilibrium. So the desired position value we already know is 0. So if actual position is also 0 that means there is no external force acting on the pendulum. So both positions are 0 so system is in dynamic equilibrium so nothing should happen. We can easily induce oscillation by initial displacement that keeping initial position as 0.15 meters. So we are going to simulate both these scenarios in Vensim and see what happens. There is a model then quickly look at the equation the change in velocity again meter per second initial value 0 position again initial value let us just keep it 0 such system starts at dynamic equilibrium. The length of rod is kept as 1 meters and gravity is 9.8 meters per second square. Now if we simulate the model because the model starts at dynamic equilibrium both the position as well as velocity are all always 0. Now let us see what happens if we move the pendulum a bit that is 0.15 meters and let it go then we should expect to see some oscillations around the equilibrium position which is shown here and the velocity is also shown here as you can see velocity is also oscillating as well as the position is also oscillating as required. In such typical models we assume that there is no other external force no other friction but in such SD model is quite easy to add this say component of a friction. So let us assume that there is some friction within the system which can be added as a frictional force which is reducing the velocity by some fraction. Let us give that as a term called as friction proportion some constant multiplier which has an impact on the friction. So now your friction is going to slow down the velocity over time. So this friction proportion let us just say to be 0.25 let us give it seconds friction itself will be velocity multiplied by this friction proportion and velocity now is affected by acceleration minus friction acceleration friction is acting in opposite direction. Now let us simulate the system now let us see what is going to happen. Now if you see the position you can see the position is slowly converging to equilibrium. So this behavior is called damped oscillations which we can now simulate which is purely because there is no frictional force that is acting on the system which is causing the system to lose its velocity thereby converging to the equilibrium point over time. We have simulated only for 10 seconds if you simulated longer you can see the impact. Also let us quickly go to the model settings and see what is happening. So here initial time is 0 final time is 10 look at the time step it is the lowest time step or the smallest possible time step and the integration type is taken as RK4 or Ranjikota 4. So this allows a more precise integration to avoid the integration errors. So to simulate this behavior you need to have very small time step with integration type as RK4. So the learning point is we have seen a model understood oscillations using a simple mechanical systems and we model a simple pendulum using system dynamics. But to exhibit oscillation system must be second order system. First order systems endogenously cannot exhibit oscillations or an SG parlance for system to exhibit oscillatory behavior they need to have at least two interacting stocks and this interaction is in such a way that it is a second order system. So just because an SD model has two stocks does not mean it will oscillate it has to interact such a way that it results in a second order system. That is the one stock affects the flow into the other stock and vice versa should be a feedback system which will result in a second order system which will then can result in oscillatory behavior depending on the initial conditions.