Module 02

Modeling Dynamic Systems

Learn to translate physical systems into mathematical models — the essential first step in any control design process.

Why Modeling Matters

Before we can control a system, we need to understand how it behaves. A mathematical model captures this behavior in equations we can analyze and simulate.

The Modeling Process

We observe a physical system, identify the relevant physics (Newton's laws, Kirchhoff's laws, conservation of energy), and translate them into differential equations. The model is always an approximation — but a good one captures the essential behavior.

In this module, we'll learn to model four types of systems:

The Analogy Insight

Remarkably, these different physical systems often share the same mathematical structure. A mass-spring-damper behaves identically to an RLC circuit! Understanding one helps you understand all.

Part 1: Mechanical Systems

Mechanical systems are the most intuitive starting point. We can literally see and feel the physics: push a mass, stretch a spring, feel resistance from a damper.

The Building Blocks

Mass (m)

Resists acceleration. Newton's second law:

$$F = m\ddot{x}$$

Force equals mass times acceleration. The heavier the mass, the more force needed to accelerate it.

Spring (k)

Stores potential energy. Hooke's law:

$$F = -kx$$

Force is proportional to displacement and opposes it. Stiffer springs (higher $k$) push back harder.

Damper (b)

Dissipates energy. Viscous friction:

$$F = -b\dot{x}$$

Force is proportional to velocity and opposes motion. Think of moving through honey — faster motion means more resistance.

External Force

Our input to the system:

$$F_{ext}(t)$$

This is what we apply to control the system. It could be a motor, a push, or any external influence.

The Mass-Spring-Damper System

Combining these elements, we get the classic second-order system. Summing forces (Newton's second law: $\sum F = ma$):

$$m\ddot{x} + b\dot{x} + kx = F_{ext}(t)$$

Reading the Equation

  • $m\ddot{x}$ — inertial force (mass resisting acceleration)
  • $b\dot{x}$ — damping force (friction opposing velocity)
  • $kx$ — spring force (restoring force opposing displacement)
  • $F_{ext}(t)$ — external input force

Interactive: Mass-Spring-Damper Response

1.0
4.0
1.0
Experiment: Start with low damping to see oscillations. Increase damping to see them die out faster. Try to find the "critically damped" point where it settles fastest without overshooting.

Standard Form and Key Parameters

Dividing the equation by $m$ and rearranging:

$$\ddot{x} + 2\zeta\omega_n\dot{x} + \omega_n^2 x = \frac{F_{ext}(t)}{m}$$

Where:

$$\omega_n = \sqrt{\frac{k}{m}}$$

Natural frequency: How fast the system oscillates when undamped. Stiffer springs or lighter masses = higher frequency.

$$\zeta = \frac{b}{2\sqrt{km}}$$

Damping ratio: How quickly oscillations decay. $\zeta < 1$ oscillates, $\zeta = 1$ is critical, $\zeta > 1$ is sluggish.

Example: Belly Flop vs Olympic Dive

Both start from the same height. Both hit water. VERY different outcomes:

  • Belly flop: Maximum surface area = maximum damping = ALL your momentum stops instantly = PAIN
  • Olympic dive: Fingers first, body like a needle = minimal damping = smooth entry = glory

The pool is your damper. The belly flopper experiences critically-overdamped-to-the-face. The diver slices through with low damping. Same physics, different life choices.

Example: Dropping Your Phone

That slow-motion moment of horror as your phone tumbles toward concrete:

  • No case, hits concrete: Near-zero damping on impact. All energy goes into shattering your screen and your soul (ζ ≈ 0)
  • Rubber case: Some bounce, but energy absorbed. Screen survives. You live another day (ζ ≈ 0.5)
  • Lands on your foot: Your foot is the damper now. Phone survives. Toe doesn't (ζ = you're the hero)

Phone cases are literally just adding damping to the impact system. The squishier the case, the higher the ζ!

Example: Why Lowriders Bounce Forever

You've seen those cars bouncing at intersections. That's not magic, it's BAD SHOCKS:

  • Normal car: Hit a bump, bounce once, done (ζ ≈ 0.7, well-tuned)
  • Lowrider with worn shocks: Bounce, bounce, bounce, bounce... (ζ << 1, underdamped AF)
  • Lowrider with hydraulics: They REMOVED the damping on purpose and added springs they can control!

Those hydraulic systems are literally controllable springs with adjustable damping. The bouncing is underdamped oscillation, and they're doing it FOR FUN.

Part 2: Electrical Systems

Electrical circuits follow the same mathematical patterns as mechanical systems. The physics is different, but the equations are identical!

The Building Blocks

Resistor (R)

Dissipates energy. Ohm's law:

$$v = Ri$$

Voltage drop proportional to current. Like a damper, it resists flow.

Capacitor (C)

Stores charge (electrical "spring"):

$$i = C\frac{dv}{dt}$$

Current flows when voltage changes. Stores energy in an electric field.

Inductor (L)

Resists current change (electrical "mass"):

$$v = L\frac{di}{dt}$$

Voltage appears when current tries to change. Stores energy in a magnetic field.

Voltage Source

Our input to the circuit:

$$v_{in}(t)$$

The control signal we apply. Could be a battery, power supply, or signal generator.

The RC Circuit: A First-Order System

A resistor and capacitor in series is the simplest dynamic circuit. Using Kirchhoff's voltage law (voltages around a loop sum to zero):

$$v_{in} = Ri + v_C = RC\frac{dv_C}{dt} + v_C$$

Rearranging into standard first-order form:

$$\tau\frac{dv_C}{dt} + v_C = v_{in} \quad \text{where} \quad \tau = RC$$

The Time Constant

The time constant $\tau = RC$ has units of seconds (ohms × farads = seconds). It tells us how fast the capacitor charges or discharges. After $5\tau$, the capacitor is essentially fully charged.

Example: Why the Last 10% of Your Phone Takes FOREVER

You're late, phone is at 87%, you need to leave in 5 minutes. Classic tragedy:

  • 0% → 50%: Zooms up in like 20 minutes. You feel like a charging god.
  • 50% → 80%: Okay, slowing down... still reasonable...
  • 80% → 100%: Time stops. Heat death of universe approaches. You'll never make it.

It's not your charger being lazy. The capacitor equation $v_C = V_{in}(1 - e^{-t/\tau})$ says the closer you get to full, the harder it is to push more in. Like stuffing that last sock into an already-full suitcase. Physics is trolling you.

Interactive: RC Circuit Charging

5.0
50
Observe: The time constant τ = RC determines charging speed. Higher R or C means slower charging. The current (dashed) starts high and decays exponentially.

The RLC Circuit: A Second-Order System

Adding an inductor creates a second-order system that can oscillate — just like a mass-spring-damper!

$$L\frac{d^2q}{dt^2} + R\frac{dq}{dt} + \frac{1}{C}q = v_{in}(t)$$

The Mechanical-Electrical Analogy

Mechanical Electrical Behavior
Mass (m) Inductance (L) Stores kinetic/magnetic energy
Damping (b) Resistance (R) Dissipates energy
Spring (k) 1/Capacitance (1/C) Stores potential/electric energy
Position (x) Charge (q) State variable
Velocity (v) Current (i) Flow variable
Force (F) Voltage (V) Effort variable

Example: The Defibrillator Scene in Every Medical Drama

"CHARGING... CLEAR!" — That's an RLC circuit saving lives (or adding drama):

  • "Charging..." = Capacitor slowly filling up (you can hear the whine getting higher)
  • "CLEAR!" = Dump all that energy through the patient in milliseconds
  • The beeping = RLC oscillation as circuit resets

The dramatic pause isn't just for TV tension — they're literally waiting for $v_C = V_{in}(1 - e^{-t/\tau})$ to get close enough to $V_{in}$. Physics doesn't care about your plot pacing!

Example: Why Bass Makes Your Chest Vibrate at Concerts

Stand near the subwoofer at a concert and feel your organs rearranging:

  • Subwoofer cone = Heavy mass, big spring = low natural frequency (20-80 Hz)
  • Your ribcage = ALSO a mass-spring system with similar natural frequency!
  • Result: Resonance! The speaker's frequency matches your chest's natural frequency. Maximum energy transfer. You feel it in your SOUL.

This is also why opera singers can shatter wine glasses — hit the glass's natural frequency with enough amplitude and BOOM. RLC circuits and broken glass: same math.

Example: Why Cheap Earbuds Sound Terrible

Your $5 gas station earbuds vs your friend's fancy ones:

  • Cheap drivers: Wrong mass-spring ratio, can't oscillate at all frequencies equally = muddy sound
  • Poor damping: Resonances at certain frequencies = that annoying tinny quality
  • Good headphones: Carefully tuned m, k, b to have flat response = sounds like the artist intended

Audio engineers are literally just tuning mass-spring-damper systems. Those expensive headphones? You're paying for good ζ and ωₙ.

Interactive: RLC Circuit Response

50
10
50
Experiment: Low resistance gives oscillations (underdamped). High resistance gives sluggish response (overdamped). This is exactly like the mass-spring-damper!

Part 3: Fluid and Thermal Systems

The same mathematical patterns appear in fluid flow and heat transfer. These systems often involve storage (tanks, thermal mass) and resistance (valves, insulation).

Tank Systems

Consider a tank with water flowing in and out. The fundamental principle is conservation of mass: rate of accumulation = rate in - rate out.

$$A\frac{dh}{dt} = q_{in} - q_{out}$$

Where $A$ is the tank cross-sectional area, $h$ is the water height, and $q$ represents volumetric flow rates.

Flow Through a Valve

For flow through a restriction (valve, pipe), the flow rate depends on pressure difference. For turbulent flow: $q = k\sqrt{\Delta P}$. For laminar flow (or linearized): $q = \frac{\Delta P}{R}$ where $R$ is the fluid resistance.

For a tank draining through a valve (linearized model):

$$A\frac{dh}{dt} = q_{in} - \frac{\rho g h}{R} = q_{in} - \frac{h}{R_f}$$

This is a first-order system with time constant $\tau = AR_f$.

Example: The Ketchup Bottle Betrayal

You shake, you tap, you wait... NOTHING. Then suddenly: ketchup tsunami.

  • Ketchup is "non-Newtonian": Acts solid when still, liquid when stressed
  • You tap the bottle: Building up pressure (charging the system)
  • Suddenly it flows: Once it starts moving, resistance drops dramatically — EVERYTHING comes out

This is why you shouldn't point the bottle at your food when convincing it to flow. The transition from "nothing" to "everything" is a nonlinear flow resistance. Your shirt is collateral damage.

Example: Why You Can't Rush at the Urinal

Sorry, but this is perfect first-order dynamics:

  • Your bladder = tank with pressure (full = high pressure = fast flow)
  • As it empties: Pressure drops = flow rate decreases exponentially
  • The last bit: Takes forever because almost no pressure difference

You're literally watching $q = \frac{h}{R}$ in action. The flow rate is proportional to the "head pressure." When pressure is low, flow is slow. Physics doesn't care that you're in a hurry.

Interactive: Tank Level Dynamics

2.0
1.0
1.0
Observe: The tank level rises exponentially toward a steady state where inflow equals outflow. Larger tanks or higher valve resistance means slower response.

Thermal Systems

Heat transfer follows similar patterns. The fundamental principle is conservation of energy: rate of energy storage = rate of heat in - rate of heat out.

$$mC_p\frac{dT}{dt} = \dot{Q}_{in} - \dot{Q}_{out}$$

For convective heat transfer (like a heated object cooling in air):

$$mC_p\frac{dT}{dt} = -hA_s(T - T_{ambient})$$

Thermal Time Constant

Rearranging gives $\tau\frac{dT}{dt} + T = T_{ambient}$ with $\tau = \frac{mC_p}{hA_s}$. This is the thermal time constant — larger mass or lower heat transfer coefficient means slower temperature change.

Example: Hot Pockets - Lava Outside, Frozen Inside

The microwave beeps. You bite in. Third-degree burns AND brain freeze. How?!

  • Microwave heats from outside in: Surface hits 1000°C (approximately, feels like it)
  • Center is still frozen: Heat hasn't conducted inward yet
  • The "let it sit" instructions: You're waiting for thermal equilibrium. Heat diffusing inward (large thermal mass, slow τ)

The recommended "let stand 2 minutes" is literally waiting for the temperature gradient to flatten. But you're hungry, so you bite in anyway. Regret follows the laws of thermodynamics.

Example: Why Your Car is an Oven in Summer

Parked in the sun for 1 hour. Open the door. Welcome to actual hell.

  • Glass lets sunlight IN: Energy enters easily (short wavelength)
  • Heat can't get OUT: Interior radiates infrared, but glass blocks it (greenhouse effect)
  • Air has LOW thermal mass: Small $mC_p$ = temperature rises FAST

Cracking windows helps because you're changing the thermal resistance. AC on max is adding a huge negative heat flow. The steering wheel that could fry an egg? That's thermal equilibrium with the sun, baby.

Example: The Shower Temperature Dance of Death

You vs the shower. An eternal battle of instability:

  • Turn knob: Nothing happens for 3 seconds (water traveling through pipes = delay)
  • Still nothing: Must need more! Turn it more!
  • SCALDING: Overcorrect to cold. Wait. Nothing. Turn more.
  • FREEZING: You've become an oscillator. Underdamped. ζ = your poor decisions.

Time delay + human impatience = unstable feedback loop. The secret? Tiny adjustments, then WAIT for 5τ worth of pipe length. But you won't. Nobody does. The dance continues.

Part 4: State-Space Representation

So far we've written differential equations in various forms. State-space is a unified framework that works for any system — and scales beautifully to complex, multi-variable systems.

What is State?

The State Vector

The state of a system is the minimum set of variables that, together with the inputs, completely determines the future behavior. Think of it as a "snapshot" of the system — everything you need to know to predict what happens next.

Example: Walking Your Drunk Friend Home

It's 2 AM. Your friend is... not doing great. Can you predict their path?

  • Position alone isn't enough: They're at the corner. Great. But which way are they going?
  • Velocity alone isn't enough: They're moving north. But from where?
  • Position + Velocity = State: NOW you can predict the trajectory (toward the kebab shop, obviously)

Their "state" is completely defined by where they are AND how fast they're moving in each direction. You don't need to know how many drinks they had (input history). Just the current state predicts the future (collision with lamppost in 3...2...1...).

Example: Parallel Parking (The Nightmare)

Why is parallel parking so hard? Because the state space is HUGE:

  • Position: x, y (where your car is)
  • Angle: θ (which way you're pointing)
  • Velocity: Hopefully slow

That's a 4-dimensional state space you're navigating while someone honks behind you. You need to get to the goal state [x=in spot, y=close to curb, θ=parallel, v=0] from wherever you currently are. Miss any one of these and you either hit something or get a ticket.

Example: Why "Where Are You?" Isn't Enough

Your friend texts: "Almost there!" Are they?

  • "I'm 5 miles away" (position) — But are you driving or walking?
  • "I'm driving 60 mph" (velocity) — But from WHERE?
  • "I'm 5 miles away, driving 60 mph toward you" — NOW I know you'll be here in 5 minutes!

Knowing the full state = you can predict the future. Knowing partial state = just guessing. This is why "I'm on my way" is useless information — no state, no prediction!

For a mass-spring-damper, the state is position and velocity:

$$\mathbf{x} = \begin{bmatrix} x \\ \dot{x} \end{bmatrix} = \begin{bmatrix} \text{position} \\ \text{velocity} \end{bmatrix}$$

For an RLC circuit, the state is capacitor voltage and inductor current:

$$\mathbf{x} = \begin{bmatrix} v_C \\ i_L \end{bmatrix}$$

The State-Space Equations

Any linear system can be written as:

$$\dot{\mathbf{x}} = A\mathbf{x} + B\mathbf{u}$$ $$\mathbf{y} = C\mathbf{x} + D\mathbf{u}$$

The Four Matrices

  • A (State matrix) — How the current state affects the rate of change
  • B (Input matrix) — How inputs affect the rate of change
  • C (Output matrix) — Which states we can measure
  • D (Feedthrough matrix) — Direct input-to-output path (often zero)

Converting to State-Space

Let's convert our mass-spring-damper equation:

$$m\ddot{x} + b\dot{x} + kx = F$$

Define states: $x_1 = x$ (position), $x_2 = \dot{x}$ (velocity). Then:

$$\dot{x}_1 = x_2$$ $$\dot{x}_2 = \ddot{x} = \frac{1}{m}(F - b\dot{x} - kx) = -\frac{k}{m}x_1 - \frac{b}{m}x_2 + \frac{1}{m}F$$

In matrix form:

$$\begin{bmatrix} \dot{x}_1 \\ \dot{x}_2 \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ -\frac{k}{m} & -\frac{b}{m} \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} + \begin{bmatrix} 0 \\ \frac{1}{m} \end{bmatrix} F$$

Interactive: State-Space Trajectory

Watch how the state (position, velocity) evolves in the "phase plane" — a powerful visualization for understanding system behavior.

0.3
1.0
0.0
Observe: The trajectory spirals toward the origin (equilibrium). With low damping, it spirals many times. With high damping, it goes more directly. This "phase portrait" shows system behavior at a glance.

Why State-Space is Powerful

Advantages

  • Handles multiple inputs and outputs naturally
  • Computer-friendly (just matrix operations)
  • Eigenvalues of A give stability directly
  • Foundation for modern control (LQR, Kalman filter)

Key Insight

The eigenvalues of matrix A are exactly the system's poles — they determine stability and natural response modes. If all eigenvalues have negative real parts, the system is stable.

Part 5: The Modeling Workflow

Here's the general process for modeling any dynamic system:

Step-by-Step Modeling

  1. Identify the system — What are the boundaries? What flows in and out?
  2. Choose state variables — What quantities capture the system's "memory"?
  3. Apply physical laws — Newton's laws, Kirchhoff's laws, conservation principles
  4. Linearize if needed — Many real systems are nonlinear; we often linearize around an operating point
  5. Put in standard form — State-space or transfer function form
  6. Validate — Does the model behavior match reality?

Common Modeling Pitfalls

  • Sign errors — Forces opposing motion should be negative
  • Unit mismatches — Always check dimensions
  • Forgetting initial conditions — The state at t=0 matters!
  • Over-complicating — Start simple, add complexity only if needed

Summary: Your Modeling Toolkit

Physical Analogs

  • Mass ↔ Inductance ↔ Fluid inertia
  • Damper ↔ Resistor ↔ Valve
  • Spring ↔ 1/Capacitor ↔ Tank stiffness
  • Force ↔ Voltage ↔ Pressure

Key Equations

$$m\ddot{x} + b\dot{x} + kx = F$$
$$\dot{\mathbf{x}} = A\mathbf{x} + B\mathbf{u}$$

The Big Picture

Modeling transforms the messy physical world into clean mathematics we can analyze. The remarkable unity across domains — mechanical, electrical, thermal — means learning one teaches you all. Next, we'll learn the Laplace transform, which turns these differential equations into simple algebra.