# Buck simulation data for learning This folder contains a small, reproducible simulation bank for learning how to prepare data, train a model and check its limits. The circuit is a synchronous buck converter. Its output voltage averages 5 V. None of these rows are measurements from a real converter. The quantity called `loss_W` is **resistive conduction loss** in the inductor winding and the two switching paths. It does not include switching losses, core losses or all the other losses of real hardware. Use that full description when showing a prediction. ## Start with the table Open `buck-simulated.csv` in a spreadsheet or load `buck.json` in a program. A CSV is a text file with a header and one row per simulation. Each row describes one design at one input voltage, load current and switching frequency. Units appear in the column names. `fsw_Hz = 100000` means 100 kHz. `L_uH = 80` means 80 microhenries, or 0.000080 H. Use these inputs for the loss exercise: `Vin_V`, `Iout_A`, `fsw_Hz`, `L_uH`, `C_uF`, `Ron_ohm`, `Roff_ohm` and `DCR_ohm`. The answer is `loss_W`. The IDs and split names describe where a row belongs, not the physics to learn. Columns such as `irms_A`, `input_power_W` and `output_power_W` come from running the simulation, so they are not valid inputs for a tool whose purpose is to avoid running it. A design is one combination of component values. One design appears at 36 operating points. A row is one of those operating points. Keeping entire designs together stops a model from being evaluated on another row of a design it already saw during training. ## Which rows can I use? The 864 rows belong to 24 designs, with no design in two splits: | Split | Designs | Rows | Purpose | | --- | --- | --- | --- | | train | 10 | 360 | Fit a model and any learned preparation | | validation | 4 | 144 | Compare choices and revise the model | | milestone-test | 3 | 108 | Check the frozen lesson 08 choice | | development-bank | 4 | 144 | Request more examples in lesson 21 | | final-test | 3 | 108 | Check the frozen final project in lesson 24 | These are public learning files. The final cases can be inspected by a determined reader, so this is not a secure examination. Do not tune a model using a final set and then describe its result as a fresh independent evaluation. If a milestone result influences later work, include that use in the development history. The final project has a different set of designs. All splits come from the same circuit equations. A new design checks transfer within that model. It is not evidence that a result will work on hardware. ## How the reference is calculated The two state variables are inductor current `iL` in amperes and capacitor voltage `vC` in volts. The load is a resistor, `Rload = 5 / Iout_A` ohms. During the high-side on-time: ```text diL/dt = (Vin - vC - (DCR + Ron) * iL) / L dvC/dt = (iL - vC / Rload) / C ``` During the low-side on-time: ```text diL/dt = (-vC - (DCR + Roff) * iL) / L dvC/dt = (iL - vC / Rload) / C ``` For each condition, the program adjusts the PWM duty until the mean output is 5 V. This is a numerical setup step, not a simulated feedback controller. Each linear interval has a matrix-exponential solution. The program finds the state that repeats after one switching cycle, then integrates the power in each resistance. It also checks that input power equals load power plus conduction loss. Every accepted periodic row has positive minimum inductor current. This is continuous conduction mode, or CCM. The separate startup signal begins at zero current and voltage. It uses forced synchronous switching and can show reverse current during the transient. It is not a steady-state training row or a recommended hardware startup method. The component resistances are generic teaching choices. They are not a particular manufacturer's device model. See `provenance.json` for the complete equations, assumptions, units, hashes and omitted physics. `verification.json` records energy balance, current minima and a second RK4 integration check. ## Waveforms and RMS `waveform-uniform.csv` and `waveform-nonuniform.csv` describe the same steady-state current and voltage over one period. The second file places more samples near the beginning. `waveform-startup.csv` shows 1000 cycles from a zero-energy initial state. `waveform-bank.json` groups these signals for the lesson application. RMS is the square root of the time average of current squared. In Python, a calculation that respects the time axis is: ```python import numpy as np signal = np.genfromtxt("waveform-nonuniform.csv", delimiter=",", names=True, dtype=None, encoding="utf-8") t = signal["t_s"] i = signal["current_A"] rms = np.sqrt(np.trapezoid(i * i, t) / (t[-1] - t[0])) print(rms) ``` An ordinary mean of squared sample values gives each sample the same weight. That can be appropriate for evenly spaced samples over a consistent window. It gives the wrong time weighting for the nonuniform file. Even the uniform file includes both endpoints, so the time integral is the cleaner comparison here. Exact numerical checkpoints are in `waveform-checkpoints.json`. ## Review priority is a teaching rule `priority_review` and `review_label` are the same binary label. A value of 1 means the peak-to-peak ripple divided by mean current is at least 0.20. This threshold is a stated classroom choice, not a universal design limit. It describes a waveform to review, not a component fault or its cause. A direct rule on the waveform defines this label exactly. A classifier cannot prove additional diagnostic truth by learning that same rule. Compare the rule with the classifier and explain which inputs would actually be available at the time of use. ## Repair practice `buck-repair-practice.csv` is a clearly marked copy with planted errors: a frequency in the wrong units, a missing value, a decimal comma, a negative inductance, an accidental duplicate and a column that copies the answer. `buck-repair-reference.csv` contains the original 12 rows. `repair-log.json` explains each change and how to recover the correct value from the source configuration. Do not treat every repeated operating condition as an accidental duplicate. Two different run IDs could be legitimate repetitions. The planted duplicate here repeats the same run ID and all its values. ## Reproduce the files Use Python 3.12 and the small NumPy dependency listed in `requirements.txt`. No simulator license, account, GPU or private file is required. ```text python -m venv .venv .venv\Scripts\python -m pip install -r requirements.txt .venv\Scripts\python generate_buck_dataset.py --output reproduced ``` On macOS or Linux, the environment's Python path is `.venv/bin/python`. The command writes into `reproduced`, leaving the delivered files available for comparison. SHA-256 hashes are listed in `provenance.json`. JSON provenance records the runtime, so minor platform or numerical-library differences can produce different last digits without changing the stated physical model. Compare numerical tolerances as well as file hashes. A simple physical approximation may already solve this small problem very well. A learned model earns its place only if a measured comparison supports the intended use. This dataset makes no claim about model accuracy, engineering time saved or learning outcomes. ## License and references These original teaching materials are covered by [AI-Native Power Teaching Permission v1.0](LICENSE.txt), copyright (c) 2026 Rafael Collado. You may download, run and modify the covered code, generated data and model examples for your own learning and internal experiments. Keep the permission notice with your copies. This is not a general permission to republish the materials. The package notice covers these buck simulation data, waveform exercises, notebooks and prediction scripts; third-party materials retain their own terms. The circuit equations in this package are explicitly stated above. The [Texas Instruments synchronous buck loss application report](https://www.ti.com/lit/an/slpa009a/slpa009a.pdf) supports the distinction between resistive conduction losses and switching mechanisms omitted here. The document itself is not redistributed or relicensed. NumPy documents the [eigendecomposition routine](https://numpy.org/doc/stable/reference/generated/numpy.linalg.eig.html) used by the generator.