Introduction to Computer Simulation Continuous Simulation Basics - - PowerPoint PPT Presentation

introduction to computer simulation continuous simulation
SMART_READER_LITE
LIVE PREVIEW

Introduction to Computer Simulation Continuous Simulation Basics - - PowerPoint PPT Presentation

Introduction to Computer Simulation Continuous Simulation Basics Jonathan Thaler Department of Computer Science 1 / 25 Continuous Simulation Figure: In a continuous model the state Figure: In a discrete model the state changes at changes


slide-1
SLIDE 1

Introduction to Computer Simulation Continuous Simulation Basics

Jonathan Thaler

Department of Computer Science

1 / 25

slide-2
SLIDE 2

Continuous Simulation

Figure: In a discrete model the state changes at discrete points. Figure: In a continuous model the state changes continuously.

A discrete model does not arise out of artifical discretisation of time but by the nature of things: the process observed in reality is actually discrete. Therefore time can be discretised without loss of precision.

2 / 25

slide-3
SLIDE 3

Continuous Simulation

Figure: Simulation goal: When assuming a varying inflow, determine the times required, to control both ventiles so that no overflow happens and even flow as much as possible.

3 / 25

slide-4
SLIDE 4

Continuous Simulation

Particularly suited to investigating strategic issues. Takes an endogenous point of view. Model the system as a causally closed structure that itself defines its behavior. Discover the feedback loops in the system. Identify stocks (accumulations) and the flows that affect them. Stocks are the memory of the system, and sources of disequilibrium. Take a continuous view where events and decisions are blurred. Unlike discrete event and agent-based models, system dynamics models are deterministic. Output are dynamics of the stocks (change of aggregates) and flows (change of rates). Mathematically: A system of coupled, nonlinear, firstorder differential equations. Solved (simulated) with numerical methods such as Euler and Runge-Kutta. They partition simulated time into discrete intervals of length ∆t and step the system through time one ∆t at a time.

4 / 25

slide-5
SLIDE 5

Continuous Simulation

For continuous simulation exist specific modelling techniques and diagrams: Causal Loop Diagram (Wirkungsdiagramm) Stock & Flows Diagram (Flussdiagramm) They have their origin in System Dynamics developed by J. Forrester at MIT in the 1950s. The main reference is John Sterman, Business Dynamics - Thinking and Modeling for a Complex World. McGraw-Hill 2000.

5 / 25

slide-6
SLIDE 6

Continuous Simulation Causal Loop Diagram

6 / 25

slide-7
SLIDE 7

Causal Loop Diagram

Elements Variables Causal connections between variables. Causal loops. Purpose Quick notes of hypotheses about the origin of the system dynamic. Discuss/document mental models of a system individually or within a group. A first explanation for a problem to solve. Preparation for a simulation model.

7 / 25

slide-8
SLIDE 8

Causal Loop Diagram

Reinforcement If x increases (decreases), y increases (decreases). Balancing / Dampening If x increases (decreases), y decreases (increases).

8 / 25

slide-9
SLIDE 9

Causal Loop Diagram

Cause vs. Correlation

Figure: Correlation

Wrong: although there is a correlation between ice cream sales and homicide rate, there is no causal connection.

Figure: Cause

Correct: the average temperature causes the ice cream sales and the homicide rate to increase.

9 / 25

slide-10
SLIDE 10

Causal Loop Diagram

Figure: Midnight Oil Example (Sterman, p 149). R reinforcement cycle: variable values

  • increasing. B balancing cycle: variable values decreasing.

10 / 25

slide-11
SLIDE 11

Continuous Simulation Stocks & Flows Diagram

11 / 25

slide-12
SLIDE 12

Stocks & Flows

Elements Containers: Stocks Flows with flow rates between Stocks: Flows Variables (similar to Stocks but without flows) Causal relations between variables/Stocks and variables/Flows. Purpose Define a precise simulation model. The influence on variables are of qualitative nature in a causal loop diagram, but for simulation we need a quantiative model. A network of Stocks and Flows defined the system dynamic: stocks are increasing and decreasing due to precise flow rates.

12 / 25

slide-13
SLIDE 13

Stocks & Flows

Figure: Dynamics of a consumer population: potential consumers are becoming adopters, which can influence other customers.

13 / 25

slide-14
SLIDE 14

Stocks & Flows

Figure: Stock Figure: Rate Figure: Flow Figure: Variable Figure: Source / Sink Figure: Relation (determines)

Difference between Stock and Variable: Stock: change is described by rates. Variable: change is modeled through scenarios or functions of other variables or stocks.

14 / 25

slide-15
SLIDE 15

Stocks & Flows

Figure: Hydraulic Metaphor for Stock & Flows Figure: Diagram of Stock & Flows

Mathematically it is a differential equation (more on that later).

dStock dt

= net change in stock per infinitely small time unit at time t. This is the same as inflow(t) - outflow(t). Important: inflow(t) and outflow(t) are rates: stock per time unit.

15 / 25

slide-16
SLIDE 16

Stocks & Flows

Change rates can be absolute or relative:

  • 1. Absolute: change of a stock per time unit.
  • 2. Relative: change of a stock per time unit and additional unit...
  • a. ... of the stock itself (feedback).
  • b. ... of another variable.

16 / 25

slide-17
SLIDE 17

Stocks & Flows

Modeling with change rates: Feedback Model relative change rates with feedback: birth rate = relative birth rate · population death rate = relative death rate · population =

population average life span

17 / 25

slide-18
SLIDE 18

Stocks & Flows

Modeling with change rates: Duration The reciprocal of a relative rate can be interpreted as a duration d =

1 decreasing rate is the (average) duration of a unit in a stock.

Example: a decreasing rate of 0.1 means:

1 10th of a stock unit leaves the

stock per time unit (if rate stays constant in this time unit). This means that in d = 10(=

1 0.1) time units exactly 1 (= 10 · 0.1) units are leaving the

stock, therefore their (average) duration in this stock. d =

1 increasing rate is (average) time between two ”births” of a new unit of

the given stock.

18 / 25

slide-19
SLIDE 19

Continuous Simulation Defining Continuous Simulations with Differential Equations

19 / 25

slide-20
SLIDE 20

Defining Continuous Simulations

Defining Continuous Simulation Systemvariables with continuous ranges (float, double) Variables are changing continuously, depending on the flow of time. Changes over time are described using differential equations: they model continuous increase/decrease of systemvariables through a mathematical function. Continuous Simulation is a numerical approach to find solutions of a dif- ferential equation system.

20 / 25

slide-21
SLIDE 21

Defining Continuous Simulations

Differential Equations Differential equations describe the rate of change dy(t)

dt

  • f a time-dependent

function y(t). Given this rate, we need to determine the change over time of y(t). The solution of a differential equation is a function which explicitly depends

  • n t.

A differential equation describes a time-dependent function only indirectly in the form of an equation. To make the time-dependent behaviour of the function explicit, the differential equation needs to be solved, similar to a ”normal” equation. Ordinary differential equations (ODE) contain only derivations after time t (otherwise we speak of partial differential equations such as time and distance).

21 / 25

slide-22
SLIDE 22

Defining Continuous Simulations

Quadratic function: y2 + y = 6 has solutions: y = 2, −3 Differential equation: dy

dt = 0.2y has solution: y(t) = e0.2t

A solution y = y(t) of a differential equation dy

dt = f(t, y) satisfies the equation dy dt (t) = f(t, y(t)) for each t.

22 / 25

slide-23
SLIDE 23

Defining Continuous Simulations

Differential equation example: free fall with friction Differential equation: dv

dt (t) = −g − γ mv(t)

Solution (velocity at time t): v(t) = − m·g

γ

+ const · e− γ

m ·t

There are infinitely many solutions (γ = 0) because const can be chosen arbi- trary.

23 / 25

slide-24
SLIDE 24

Defining Continuous Simulations

Initial value problem: differential eqution and value for initial point guarantee a unique solution.

  • 1. Define initival value for differential equation:

dv dt (t) = −g − γ mv(t) with v(0) = 0

  • 2. Define a function for const in the solution:

v(t) = − m·g

γ

+ m·g

γ e− γ

m t = m·g

γ (e− γ

m t − 1)

  • 3. Define parameters: g = 9.8 m

sec2 , m = 10kg, γ = 2 kg sec

  • 4. Substituting parameters into DE: dv

dt (t) = −9.8 − 0.2 · v(t)

  • 5. Substituting parameters into solution: v(t) = 49 · (e−0.2t − 1)
  • 6. For stable state solution:

v(t) = 49 · (e−0.2t − 1)

t→∞

− − − → vfinal = −49 m

sec = −176.4km/h

24 / 25

slide-25
SLIDE 25

Defining Continuous Simulations

dv dt (t) = −g − γ mv(t) with v(0) = 0

Differential equation as problem model of Free fall with friction. v(t) = − m·g

γ

+ m·g

γ e− γ

m t

Explicit solution of the differential equation of Free fall with friction. We are modeling dynamical systems in form of differential equations and not in form of an explicit solution of a differential equation. A differential equation is the right form for a dynamical model where we model change over time. However, many problems expressed as differential equations do not have an explicit solution. In these cases we therefore have to simulate!

25 / 25