M1 · Derive and verify the buck
- Derive the buck converter’s conversion ratio in CCM from volt-second balance, by hand and with sympy.
- Derive its inductor-current ripple from the slope of the current during the on-interval.
- Follow one equation through the site’s checks: its entry in
equations.yaml, its test values, the sympy derivation that must reproduce it, and the generator. Break each on purpose and see which check fails.
Before you start
Section titled “Before you start”- Read volt-second and charge balance and the buck converter.
- Have a clone of the repository with its Python package installed (
pip install -e "python[dev,figures]", as the README says). Run the commands below from the clone’s root. - On this site, is half the peak-to-peak ripple of the inductor current, as in Erickson.
1. By hand
Section titled “1. By hand”In CCM the switch connects the inductor to for , and the diode connects it to ground for the rest of the period. Write the inductor voltage in each interval, with the output voltage taken as constant (the small-ripple approximation). Average it over one period, set the average to zero, and solve for . Compare with the buck's conversion ratio.
2. With sympy
Section titled “2. With sympy”Let sympy do the same algebra. Fill in the two inductor voltages:
import sympy as sp
D, Vg, V = sp.symbols('D V_g V', positive=True)v_on = ... # the inductor voltage while the switch is onv_off = ... # and while the diode conductsprint(sp.solve(sp.Eq(D * v_on + (1 - D) * v_off, 0), V))The repository’s own derivation is python/pe_core/derive/ccm_ratios.py,
shown step by step on the derivations page.
3. The ripple
Section titled “3. The ripple”During the on-interval the inductor current rises at a constant slope. Its rise over is the peak-to-peak ripple, and half of it is . Compare your result with the buck's inductor ripple.
4. The example’s numbers
Section titled “4. The example’s numbers”The buck example has = 24 V, = 0.5, = 100 µH and = 100 kHz. Work out its output voltage and its , and enter them under Acceptance criteria. Then open the ripple in the equation explorer and sweep the inductance: the ripple falls as .
▶ Open in the equation explorer: Buck inductor current ripple (half peak-to-peak), CCM
Preset from the example buck-basic
5. The checks pass
Section titled “5. The checks pass”In your clone, run python scripts/gen_equations.py, pytest and
python scripts/mathlint.py. All three pass, and git status shows that the
generator left packages/pe-core/equations/ as it was.
6. Break a test value
Section titled “6. Break a test value”In packages/pe-core/equations/equations.yaml, change the first expected
value in the tests of buck.ccm.M. Run python scripts/gen_equations.py:
it refuses, and its message names the entry, the test and the value the
expression gives. Undo the change with
git checkout -- packages/pe-core/equations/.
7. Break the equation consistently
Section titled “7. Break the equation consistently”Now change the expression of buck.ccm.M and both of its expected values so
that they agree with each other (halve all three, say). The generator accepts
this, but pytest fails in test_derivation_reproduces_yaml[buck.ccm.M]: the
sympy derivation still gives the ratio you found in step 1. Undo the change as
before; the same checkout also restores the files the generator rewrote.
Acceptance criteria
Section titled “Acceptance criteria”Show the example's value
12 V (from
buck-basic: Buck example)Show the example's value
300 mA (from
buck-basic: Buck example)
Your ticks stay in this browser only: no account, and nothing is sent.
Gotchas
Section titled “Gotchas”- here is half the peak-to-peak ripple. The full swing of the current is twice the value the check expects.
- The ratio holds in CCM only. When the inductor current reaches zero before the period ends, the output rises above (CCM and DCM, and mission M2).
- Run
pytestwith the Python that haspe_coreinstalled. Another interpreter fails at import, before any check runs. - An experiment that the generator accepted also rewrote its output files.
git checkout -- packages/pe-core/equations/restores the YAML and those files together.
Go deeper
Section titled “Go deeper”- Book chapter Principles of Steady-State Converter Analysis (Ch. 2)
The standard derivation of volt-second and charge balance, the small-ripple approximation and inductor/capacitor ripple. - Course Introduction to Power Electronics
First course of the CU Boulder specialization: steady-state analysis, losses and efficiency.
Why is the inductor voltage, averaged over one switching period, zero in steady state?
Answer and explanation
Correct answer: B The change of the inductor current over a period is its average voltage times the period over the inductance. A current that repeats from period to period changes by zero, so the average voltage is zero: that is volt-second balance.
A buck converter in CCM runs from 48 V at a duty ratio of 0.25. What is its output voltage?
Answer and explanation
Correct answer: C The conversion ratio is the duty ratio: 0.25 times 48 V is 12 V.
The inductor current of a buck swings between 1.0 A and 1.6 A. What is in this site's convention?
Answer and explanation
Correct answer: B The peak-to-peak ripple is 0.6 A, and is half of it, 0.3 A, as in Erickson. The average current is 1.3 A.
The inductance of a buck in CCM is doubled, all else unchanged. What happens to ?
Answer and explanation
Correct answer: A The current's slope during the on-interval is the inductor voltage over the inductance, so the rise over the same time halves.
You change the expected value of one test of an equation in equations.yaml and leave its expression alone. What happens?
Answer and explanation
Correct answer: C Loading the catalogue evaluates every test against its expression, so the generator, and pytest, stop at the first mismatch and say where it is.
You change an expression and its expected values so that they agree with each other. Which check still catches it?
Answer and explanation
Correct answer: B The test values only check the expression against itself. The derivation in python/pe_core/derive/ is independent of the YAML, and pytest compares the two.
The numbers in the examples, presets and exercises on this site are synthetic: round teaching values, not data from any real design.