Elective Simulation and Modeling

Simulation and ModelingUnit 29 min read

Continuous vs. Discrete Systems: Models, Examples & Simulation

Unit 2 of Simulation and Modeling explores the fundamental distinction between continuous and discrete systems, their mathematical modeling techniques, and practical simulation approaches using real-world examples like traffic flow and manufacturing processes.

TAKEAWAYS:

  • Continuous systems model real-valued, time-dependent variables (e.g., temperature, fluid flow) using differential equations, while discrete systems model countable, event-driven states (e.g., customer arrivals, machine cycles) using difference equations or state transitions.
  • Hybrid systems combine both (e.g., a chemical reactor with discrete control valves and continuous temperature changes).
  • Simulation tools like Simulink (continuous), AnyLogic (discrete), or Python (custom scripts) bridge theory and practice.
  • Key metrics for validation: steady-state error, transient response (continuous); queue lengths, cycle times (discrete).
  • Real-world applications span manufacturing (assembly lines), logistics (warehouse robots), and finance (portfolio optimization).

1. Definitions and Core Concepts

Continuous Systems

  • Definition: Systems where state variables change smoothly over time (e.g., temperature, velocity, pressure).
  • Mathematical Model: Governed by ordinary differential equations (ODEs) or partial differential equations (PDEs).
    • Example: A heating system’s temperature follows: where is a cooling constant.
  • Key Features:
    • Infinite possible states between any two values.
    • Time is continuous (e.g., seconds, milliseconds).
    • Example Systems: Pendulums, electrical circuits, fluid dynamics.

Discrete Systems

  • Definition: Systems where state changes occur at distinct points (e.g., customer arrivals, machine states).
  • Mathematical Model: Described by difference equations or state transition diagrams.
    • Example: A bank teller’s queue:
      • State : Number of customers at time step .
      • Transition: .
  • Key Features:
    • Countable, often integer-valued states.
    • Time progresses in discrete steps (e.g., per second, per hour).
    • Example Systems: Traffic lights, inventory management, digital circuits.

2. Visualizing the Systems

Continuous System: Pendulum Motion

  • Real Picture:

Discrete System: Traffic Light Cycle

stateDiagram-v2
    [*] --> Green
    Green --> Yellow: after 30s
    Yellow --> Red: after 5s
    Red --> Green: after 45s
  • Real Picture:

3. Modeling Techniques

Continuous Systems

Method Equation Type Tools Example
Analytical ODEs/PDEs MATLAB, Maple Heat equation in a rod:
Numerical Finite Difference Python (SciPy), Simulink Euler’s method for
Hybrid ODE + Event Triggers Simulink Cruise control with discrete gear shifts

Discrete Systems

Method Representation Tools Example
State Transition Graphs/Markov Chains AnyLogic, Python ATM machine states: Idle → Insert Card → Enter PIN
Event-Driven Timelines SimPy, Arena Factory: Machine breaks → Repairman called
Agent-Based Multi-agent systems NetLogo, Mesa Ant colony foraging paths

4. Worked Examples

Example 1: Continuous – Drug Concentration in Blood

Scenario: A drug is injected into a patient. Its concentration (mg/L) decays exponentially: Solution:

  1. Separate variables: .
  2. Integrate: .
  3. Solve: . Simulation (Python):
import numpy as np
import matplotlib.pyplot as plt

k, C0 = 0.2, 100  # decay rate, initial concentration
t = np.linspace(0, 20, 100)
C = C0 * np.exp(-k * t)

plt.plot(t, C, 'r-', label='C(t) = 100e^(-0.2t)')
plt.xlabel('Time (hours)')
plt.ylabel('Concentration (mg/L)')
plt.legend()
plt.grid()

Graph:

Example 2: Discrete – Inventory Management

Scenario: A shop orders 50 units every 2 weeks. Demand is 10 units/week with 5% variability. State Transition:

  • States: = inventory at week .
  • Transitions:
    • (if ).
  • Simulation Steps:
    1. Start with .
    2. Week 1: Demand = 10 → .
    3. Week 2: Demand = 10.5 → (order 50) → .

Mermaid Diagram:

flowchart LR
    A["Start: S₀=50"] --> B["Week 1: Demand=10 → S₁=40"]
    B --> C["Week 2: Demand=10.5 → S₂=30 → Order 50 → S₂=80"]
    C --> D["Week 3: Demand=9.5 → S₃=70.5"]

5. Hybrid Systems: Real-World Bridge

Example: Nepal’s NTC Electricity Grid

  • Continuous: Voltage in transmission lines (PDEs).
  • Discrete: Switching stations (event-driven). Model:
  1. Continuous: (inductive load).
  2. Discrete: At , open switch to reroute power.

Real Picture:


6. Advantages and Limitations

System Type Advantages Limitations When to Use
Continuous Accurate for smooth processes Computationally expensive for PDEs Physics, fluid dynamics
Discrete Simple for event-driven systems Approximates continuous behavior Logistics, digital systems
Hybrid Captures both aspects Complex to implement Smart grids, autonomous vehicles

7. In the Real World

  1. eSewa (Nepal):

    • Discrete System: Transaction processing as a queue.
      • States: Pending → Verified → Completed.
      • Simulation Use: Model peak-hour delays (e.g., Dashain sales) to optimize server capacity.
    • Worked Example: If 10,000 transactions arrive/hour and servers process 5,000/hour, the queue grows linearly until more servers are added.
  2. Pathao (Ride-Hailing):

    • Hybrid System:
      • Continuous: Driver’s speed (ODE: ).
      • Discrete: Ride requests (event-driven).
    • Simulation: Optimize driver dispatch to minimize wait times (e.g., during Kathmandu traffic jams).
  3. Nepal’s NEPSE Stock Market:

    • Discrete Events: Buy/sell orders at specific prices.
    • Continuous: Stock price modeled as a stochastic differential equation (SDE): where is Wiener process (random walk).

8. Exam Tip

  1. Differentiate Clearly:

    • Continuous: Use ODEs/PDEs, terms like "derivative," "smooth."
    • Discrete: Use difference equations, "state transitions," "events."
    • Example Question: "Model a thermostat’s temperature control as continuous or discrete. Justify." Answer: Continuous (temperature changes smoothly; ODE: ).
  2. Hybrid Systems:

    • Look for mixed keywords: "digital control of a continuous process" (e.g., cruise control).
    • Example: "A chemical reactor has continuous flow but discrete valve openings. Model it."
      • Solution: ODE for temperature + event triggers for valve states.
  3. Numerical Methods:

    • For ODEs, expect Euler’s method or Runge-Kutta in exams.
    • Example: Given , , compute using Euler with .
      • Steps:
        1. .
        2. Repeat for .
  4. Validation:

    • Always check:
      • Steady-state: Does the system stabilize? (e.g., ).
      • Transient response: How fast does it reach equilibrium?
    • Example: For a queue, validate by comparing simulated vs. real average wait times.
  5. Tools:

    • Mention in answers: "Simulated in Python using scipy.integrate.odeint" or "Modeled in Simulink with S-function blocks."
    • Avoid: Writing code unless asked; focus on mathematical setup.

Final Note: Master the visual distinction between smooth curves (continuous) and step changes (discrete). Examiners test this with sketching questions—always draw the system’s behavior!

Based on the TU BIT syllabus for Simulation and Modeling, unit 2.

Discussion

Loading…