Invntr
Source

All instruments

bode_margins

Frequency response of an open loop L(s) = gain * num(s)/den(s) * exp(-s T) on a log sweep: gain and phase margins with their crossover frequencies, delay margin, -3 dB bandwidth and resonant peak of L, unity-feedback closed-loop and sensitivity peaks, closed-loop stability by Routh (and delay margin when T > 0); bode.csv and crossovers.csv.

Field
Dynamics and control
Version
0.1.0
Runs as
Compiled (Rust)
Typical run
0.05 s

Compiled from source: run sh packs/install.sh once before admitting it.

Known answers it must pass

Admission replaybode_margins 0.1.0 · files c6c4b39482e0…ff3e
  1. r0001textbook K/(s(s+1)(s+2)), K=1: phase crossover at sqrt(2) rad/s, gain margin 6/K = 6 = 20 log10 6 = 15.563025 dB (closed form, rel 1e-6)passed

    phase_crossover_rad_s1.41421 ± 1.4e-061.41421lockedunder 0.01 % of the tolerance used
    gain_margin6 ± 6e-066lockedunder 0.01 % of the tolerance used
    gain_margin_dB15.563 ± 1.6e-0515.563lockedunder 0.01 % of the tolerance used
    closed_loop_stable= truetruelockedexact match
  2. r0002Routh limit of K/(s(s+1)(s+2)) is K = 6: at K=10 the closed loop is unstable and the gain margin is 6/K = 0.6 (closed form, rel 1e-6)passed

    gain_margin0.6 ± 6e-070.6lockedunder 0.01 % of the tolerance used
    phase_crossover_rad_s1.41421 ± 1.4e-061.41421lockedunder 0.01 % of the tolerance used
    closed_loop_stable= falsefalselockedexact match
  3. r0003first-order lag 1/(s+1) at its corner w = 1: -10 log10 2 = -3.0103 dB and -45 deg; -3 dB bandwidth = 1 rad/s (closed form, rel 1e-6)passed

    gain_at_w_dB-3.0103 ± 3e-06-3.0103lockedunder 0.01 % of the tolerance used
    phase_at_w_deg-45 ± 4.5e-05-45lockedunder 0.01 % of the tolerance used
    bandwidth_rad_s1 ± 1e-061lockedunder 0.01 % of the tolerance used
  4. r0004integrator 1/s: |L| = 1 at w = 1 rad/s, phase margin 90 deg, delay margin pi/2 s, no phase crossover (closed form, rel 1e-6)passed

    gain_crossover_rad_s1 ± 1e-061lockedunder 0.01 % of the tolerance used
    phase_margin_deg90 ± 9e-0590lockedunder 0.01 % of the tolerance used
    delay_margin_s1.5708 ± 1.6e-061.5708lockedunder 0.01 % of the tolerance used
    phase_crossover_count= 00lockedexact match
  5. r0005integrator with dead time T = 0.5 s: phase margin 90 deg - T rad = 61.352110 deg at w = 1; phase crossover at pi/(2T) = pi rad/s with gain margin pi/(2T) = pi; delay margin pi/2 - T (closed form, rel 1e-6)passed

    phase_margin_deg61.3521 ± 6.1e-0561.3521lockedunder 0.01 % of the tolerance used
    gain_crossover_rad_s1 ± 1e-061lockedunder 0.01 % of the tolerance used
    phase_crossover_rad_s3.14159 ± 3.1e-063.14159lockedunder 0.01 % of the tolerance used
    gain_margin3.14159 ± 3.1e-063.14159lockedunder 0.01 % of the tolerance used
    delay_margin_s1.0708 ± 1.1e-061.0708lockedunder 0.01 % of the tolerance used
    closed_loop_stable= truetruelockedexact match
  6. r0006second order wn^2/(s^2 + 2 z wn s + wn^2), wn = 2, z = 0.3: resonant peak 1/(2 z sqrt(1-z^2)) = 1.7471414 at wn sqrt(1-2z^2) = 1.8110770 rad/s; bandwidth wn sqrt(1-2z^2+sqrt(4z^4-4z^2+2)) = 2.9073789 rad/s (closed forms, rel 1e-6; the peak frequency is found by golden section, good to ~1e-8 relative)passed

    resonant_peak1.74714 ± 1.7e-061.74714lockedunder 0.01 % of the tolerance used
    resonant_peak_dB4.84656 ± 4.8e-064.84656lockedunder 0.01 % of the tolerance used
    resonant_rad_s1.81108 ± 1.8e-061.81108locked0.33 % of the tolerance used
    bandwidth_rad_s2.90738 ± 2.9e-062.90738lockedunder 0.01 % of the tolerance used
6 of 6 cases passed · sandbox macos-seatbeltrecorded from the kernel in a fresh lab

Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.

Inputs

NameUnitDefaultMeaning
num[1]Numerator coefficients, highest power of s first: [1, 2] is s + 2. Up to degree 30.
denDenominator coefficients, highest power of s first: [1, 3, 2, 0] is s^3 + 3 s^2 + 2 s. Up to degree 30.
gain11.0Loop gain K multiplying num/den; any finite non-zero number (negative flips the sign).
dead_time_ss0.0Pure dead time T: the loop is multiplied by exp(-s T).
w_min_rad_srad/s0.001Lowest sweep frequency.
w_max_rad_srad/s1000.0Highest sweep frequency (above w_min_rad_s).
points_per_decade1100Base sweep density; the sweep is refined further wherever the phase turns fast.
eval_w_rad_srad/sOptional: one frequency (inside the sweep) at which to report gain and phase of L.

Readings

NameUnitMeaning
gain_margin1
gain_margin_dBDecibels (20 log10 of the ratio); dB is not in the kernel's unit table, so no unit is declared.
phase_crossover_rad_srad/s
phase_margin_degdeg
gain_crossover_rad_srad/s
delay_margin_ss
closed_loop_stabletrue/false, or null when not decided (see stability_basis).
stability_basisHow closed_loop_stable was decided.
closed_loop_rhp_poles_no_dead_time1
open_loop_rhp_poles1
dc_gain1
dc_gain_dBDecibels (20 log10 of the ratio); dB is not in the kernel's unit table, so no unit is declared.
bandwidth_rad_srad/sFirst frequency where |L| falls 3.0103 dB below its DC gain.
peak_gain1
peak_gain_dBDecibels (20 log10 of the ratio); dB is not in the kernel's unit table, so no unit is declared.
resonant_peak1Largest |L| inside the sweep divided by |L(0)|, when above 1.
resonant_peak_dBDecibels (20 log10 of the ratio); dB is not in the kernel's unit table, so no unit is declared.
resonant_rad_srad/s
closed_loop_peak1Largest |L/(1+L)| in the sweep.
closed_loop_peak_rad_srad/s
closed_loop_bandwidth_rad_srad/s
sensitivity_peak1Largest |1/(1+L)| in the sweep (Ms).
sensitivity_peak_rad_srad/s
gain_at_w1
gain_at_w_dBDecibels (20 log10 of the ratio); dB is not in the kernel's unit table, so no unit is declared.
phase_at_w_degdeg
gain_crossover_count1
phase_crossover_count1
sweep_points1
warningsCaveats in words: crossovers outside the sweep, open-loop right-half-plane poles, undecided stability.
crossovers
bode.csv
crossovers.csv

Try the call

Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.

Terminal
MCP call