jackstev's picture
Deploy HW3 explainer app
f915d94 verified
|
Raw History Blame Contribute Delete
2.35 kB
---
title: Step Response Explainer
emoji: 📈
colorFrom: pink
colorTo: yellow
sdk: gradio
sdk_version: 6.28.0
python_version: "3.13"
app_file: app.py
pinned: false
license: mit
short_description: Second-order step response, computed and explained
models:
- Qwen/Qwen3-0.6B
---
# Step response explainer
Enter an underdamped second-order system, either as ωn and ζ or as a physical mass, damper, and spring. The app computes its step response from first principles, checks it against optional design limits, and then asks a small language model to explain the numbers in plain words. Built for 24-679 Designing and Prototyping AI Systems, Homework 3.
## What it calculates
For $G(s) = K\omega_n^2 / (s^2 + 2\zeta\omega_n s + \omega_n^2)$ with a step of size $A$:
$c(t) = 1 - \frac{e^{-\zeta\omega_n t}}{\sqrt{1-\zeta^2}}\sin(\omega_d t + \theta)$, with $\omega_d = \omega_n\sqrt{1-\zeta^2}$ and $\theta = \tan^{-1}(\sqrt{1-\zeta^2}/\zeta)$.
The app reports percent overshoot, peak value and time, 10 to 90% and 0 to 100% rise time, settling time (exact and the textbook $4/\zeta\omega_n$ estimate), damped frequency and period, and pole locations. It also checks optional overshoot and settling limits, giving the ζ or ωn that would pass a failed check.
## Scope and valid inputs
Underdamped only, with $0.05 \le \zeta \le 0.95$ and $0.1 \le \omega_n \le 500$ rad/s. The system is linear, has no zeros, starts from rest, and receives an ideal step at $t = 0$. Mass-spring-damper inputs are converted with $\omega_n = \sqrt{k/m}$ and $\zeta = c/(2\sqrt{km})$, and the output is shown in mm. Out-of-scope values, such as an overdamped system, return a message saying which value to change.
## How the explanation is kept honest
The calculator produces a structured record. Its text form, shown in the app, is the only thing the language model ([Qwen/Qwen3-0.6B](https://huggingface.co/Qwen/Qwen3-0.6B), pinned revision, greedy decoding on CPU) receives. Two worked examples generated by the calculator itself set the style. A deterministic check then flags any number in the explanation that is not in the record, and any pass or fail statement that contradicts it. The table is always the source of truth.
## Credits
Calculator, app, and prompt by Jack Stevens with Claude (Anthropic) as a coding assistant. MIT licence. Qwen3 is Apache 2.0.