Lite / Engineering Complex Systems / Week 10
Is the code right? Is the model right?
Your simulation of a cooling cup is bug-free and matches the equation perfectly. It is still wrong by 10 °C. How can both be true?
Why should I care?
Every engineering simulation can fail in two separate ways: the code can be wrong, or the physics can be wrong. Engineers check both, in that order, and write down which they checked. A model that passes only one is not yet evidence.
- Define verification (solving the equations correctly) and validation (solving the right equations).
- Verify a simulation against an exact solution and a step-size convergence check.
- Validate a model against data that was not used to fit it.
Predict
A simulation agrees with the exact solution of its equation to four decimal places. What has that proved?
- The model matches reality
- The code solves the equation correctly
- Both
- Neither
Guess first, then reveal
It proves the code is right (verification). Whether the equation describes the real cup, with its evaporation and changing room temperature, needs measurements (validation).
Discover
Investigation: in the feedback lab, set a first-order plant with K = 1, τ = 2 s under P control with Kp = 1 and a set point of 1. Theory says the loop settles at 0.5 with a time constant of 1 s, so y(1 s) ≈ 0.5 × 0.632 = 0.32. Read y at t = 1 s from the plot. If it agrees, you have a verification check; write down what it does not tell you about a real motor.
What the interactive shows (text version)
In the feedback lab, a first-order plant under P control (K = 1, τ = 2 s, Kp = 1) rises smoothly towards 0.5 and is at about 0.32 after 1 s, matching the formula. That agreement is a verification check.
Understand
Verification: solving the equations right
Check the code against cases with known answers: an exact solution, a conserved quantity, a limit like 'no input means no change'. Then halve the time step: if the answer still changes noticeably, the step was too big. These checks say nothing about the real world.
Validation: solving the right equations
Compare the model with measurements, ideally from runs not used to fit its parameters. Fitting τ to one cooling curve and then predicting a second cup at a different starting temperature is a real test; matching the curve you fitted to is not.
Order matters, and so does honesty
Verify first: a bug can masquerade as a physics problem. Then validate, report the error, and list the assumptions the model makes (constant room temperature, uniform cup temperature). Saying 'validated for these conditions' is honest; 'validated' alone rarely is.
Explain it another way
Intuitive
Verification asks whether you followed the recipe correctly. Validation asks whether the recipe makes the cake you wanted.
Technical
Verification: code-to-model agreement (convergence order, analytic benchmarks, unit tests). Validation: model-to-reality agreement on held-out data, with quantified error and a stated domain of validity.
Applied
Every integrator behind this term's diagrams is unit-tested against its closed-form solution: that is verification. None of them has been validated against a real motor or lift, which is why they are called educational models.
Worked example 1
Euler's method on dy/dt = −y/2 from y(0) = 1 gives y(2) = 0.3487 with dt = 0.2 and 0.3660 with dt = 0.02. The exact value is e^(−1) = 0.3679. What does this tell you?
The error falls from 0.019 to 0.0019 when dt shrinks ten times: first-order convergence, as expected for Euler. The code is verified for this case. It says nothing yet about whether dy/dt = −y/2 describes the real system.
Common mix-ups
If the simulation matches the exact solution, the model is right.
✓ That only verifies the code. The equations can still miss real physics.A model either is or isn't valid.
✓ Validity has a domain: a cooling model can be good from 80 °C to 40 °C and poor near room temperature.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Write a half-page verification and validation plan for a model of your choice (cooling drink, falling paper cone, charging phone). List two verification checks, one validation dataset you could collect, and the error you would accept.
Reflect
Which is harder to do well for a student project, verification or validation? Why?
Write your answer on paper or in your own notes. Lite never stores what you write.