Simulation and ModelingUnit 210 min read
Continuous vs. Discrete Systems: Models, Equations & Simulation
Unit 2 of Simulation and Modeling explores how continuous systems (like fluid flow or pendulums) and discrete systems (like traffic queues or digital circuits) are mathematically modeled, simulated, and analyzed using differential equations, difference equations, and state-space representations.
TAKEAWAYS:
- Continuous systems are modeled using differential equations (e.g., Newton’s laws, heat transfer), while discrete systems use difference equations (e.g., population growth, digital filters).
- State-space models (e.g., , ) unify both types, where = state variables, = inputs, = outputs.
- Simulation steps: Discretize time, solve equations numerically (Euler, Runge-Kutta), and validate with real-world data.
- Applications: Continuous = NTC’s power grid stability; Discrete = Pathao’s ride-matching algorithm.
- Trade-offs: Continuous models are precise but computationally heavy; discrete models are faster but may lose accuracy.
- Exam focus: Compare systems, derive equations, and interpret simulation outputs (e.g., stability, steady-state).
1. Continuous Systems: Modeling the Real World
Continuous systems evolve smoothly over time (e.g., temperature in a room, voltage in a circuit). Their behavior is described by differential equations (DEs), which relate rates of change (derivatives) to system states.
Key Concepts
- State Variables: Quantities that define the system’s behavior (e.g., position , velocity of a pendulum).
- Inputs/Outputs: External forces (e.g., torque applied to a pendulum) and measurable responses (e.g., angle ).
- Ordinary Differential Equations (ODEs): For lumped systems (e.g., for a spring-mass-damper).
- Partial Differential Equations (PDEs): For distributed systems (e.g., heat equation ).
Example: Pendulum Motion
Real-world tie: A wind turbine’s blade (continuous rotation modeled as a pendulum with air resistance). Model:
- State variables: Angle , angular velocity .
- Equation of motion (ignoring friction): Simplified for small angles ():
- Solution: , where .
Simulation Steps:
- Discretize time: , s.
- Use Euler’s method to approximate derivatives:
- Plot vs. time to visualize oscillations.
Visualization: Exam Tip: Always check units! Here, must be in .
2. Discrete Systems: Digital and Event-Driven Models
Discrete systems change in jumps (e.g., bank transactions, digital signals). They are modeled using difference equations or state transitions.
Key Concepts
- State Equations: , where is the discrete time step.
- Input-Output Relations: .
- Z-Transform: Tool to solve difference equations (analogous to Laplace transform for DEs).
- Applications: Digital filters, queueing networks, financial models.
Example: Bank Loan Repayment (Amortization)
Real-world tie: Nabil Bank’s home loan calculator uses discrete compounding to compute monthly payments. Model:
- State variable: Remaining loan balance at month .
- Difference equation:
where:
- monthly interest rate (e.g., 0.5% = 0.005),
- fixed monthly payment.
- Goal: Find such that after months.
Worked Example:
- Loan: $100,000, annual interest rate = 6% (), term = 20 years ( months).
- Derivation: The closed-form solution for is: Plugging in values:
- Simulation:
Use a spreadsheet to iterate:
Month Balance Payment Interest Principal Paid 0 100,000.00 659.96 500.00 159.96 1 99,840.04 659.96 499.20 160.76 ... ... ... ... ... 240 0.00 659.96 0.00 659.96
Visualization:
3. State-Space Representation: Unifying Both Worlds
State-space models represent both continuous and discrete systems in a unified framework:
Example: Temperature Control System
Real-world tie: NTC’s smart grid adjusts heater power discretely to maintain room temperature continuously. Model:
- Continuous dynamics (heat transfer):
where:
- = room temperature,
- = thermal capacitance,
- = heat loss coefficient,
- = heater power (input).
- Discrete control (thermostat):
- If , turn heater on ().
- Else, turn off ().
Simulation Trace:
Visualization:
4. Comparison: Continuous vs. Discrete Systems
| Feature | Continuous Systems | Discrete Systems |
|---|---|---|
| Math Model | Differential equations (ODEs/PDEs) | Difference equations, state transitions |
| Time | Continuous () | Discrete () |
| Example | Pendulum, fluid flow | Digital clock, bank transactions |
| Simulation Method | Euler, Runge-Kutta | Iterative recursion |
| Stability | Eigenvalues of matrix (Lyapunov) | Schur stability (discrete eigenvalues) |
| Real-World Use | NTC power grid, Daraz delivery routes | Pathao ride matching, NEPSE stock updates |
5. Simulation Techniques
A. Continuous Systems
- Numerical Methods:
- Euler’s Method: Simple but inaccurate for stiff systems.
- Runge-Kutta 4th Order (RK4): More accurate.
- Validation: Compare simulation output to real data (e.g., lab-measured pendulum period).
B. Discrete Systems
- Iterative Methods:
- Directly solve .
- Z-Transform:
- Convert difference equations to algebraic form (e.g., solve ).
## In the Real World
NTC’s Power Grid (Continuous):
- Uses PDEs to model voltage distribution across transmission lines. Simulations predict blackout risks by solving (Laplace’s equation) with boundary conditions.
- Why it matters: Prevents cascading failures like the 2015 Nepal blackout.
Pathao’s Ride-Matching (Discrete):
- Treats driver locations as state variables in a discrete-event simulation. The algorithm:
- Models drivers as nodes in a graph.
- Uses priority queues to match riders to nearest available drivers.
- Updates states (e.g., "driver busy") after each ride.
- Key equation: if and .
- Treats driver locations as state variables in a discrete-event simulation. The algorithm:
Khalti’s Transaction Queue (Discrete + Continuous):
- Discrete: Processes payments as atomic events (e.g., "transfer $500 from A to B").
- Continuous: Models network latency as a Poisson process (average 200ms delay).
- Simulation: Uses queueing theory (M/M/1 model) to predict peak-hour failures.
## Exam Tip
Derive Equations from First Principles:
- For continuous systems, start with physics (e.g., ) or conservation laws (e.g., mass/energy).
- For discrete systems, define state transitions clearly (e.g., "if balance > threshold, pay interest").
Compare Systems in Tables:
- Examiners love questions like "How would you model a traffic light system? Continuous or discrete? Justify." Use the comparison table above.
Show Simulation Steps:
- For numerical methods, write out one iteration of Euler/RK4 with sample values (e.g., , ).
- For discrete systems, provide a state transition table (like the loan example).
Real-World Applications:
- Link models to Nepalese contexts:
- Continuous: "How would you simulate Kathmandu’s traffic flow?" → Use PDEs for vehicle density.
- Discrete: "Design a queue for Daraz’s order fulfillment." → Use M/G/1 queueing model.
- Link models to Nepalese contexts:
Common Pitfalls:
- Units: Always check (e.g., must be ).
- Stability: Continuous systems may blow up if is too large in Euler’s method.
- Discretization Error: Smaller = more accurate but slower.
Based on the PU BE Computer (PU) syllabus for Simulation and Modeling (CMP338), unit 2.
Discussion
Loading…