Phápmohammadrezwankhan/matlab-simulink-energy-lab
Run reduced-order battery, thermal, converter and BESS control models with transparent equations and repeatable testing.
Thành tựu nổi bật
Những danh hiệu mới nhất của dự án
#1 Repository của tuần
#1 Repository của tuần
#1 Repository của tuần
⚡ MATLAB Simulink Energy Lab

See the equations become waveforms—and inspect every assumption in between.
MATLAB Simulink Energy Lab is a growing collection of small, runnable, and highly inspectable energy-system examples for students, researchers, and hobbyists. Start with a battery RC model or an averaged converter calculation, trace every parameter, run the checks, and extend the foundation for your own study.
Shareable Documentation Map
- Start in 60 Seconds for the fastest runnable path.
- Models at a Glance for the model-to-question map.
- Requirements for MATLAB and toolbox expectations.
- Scope and Limitations before reusing outputs.
- Validation results for the complete expected output.
- Contribute a Scoped Improvement for focused changes.
- Citation metadata and release notes for published or shared work.
[!TIP] If a model helps you learn or saves you setup time, star this repository. Your star helps more energy-engineering learners discover the lab and shows which open examples are worth expanding next.

What You Can Explore
- Simulate the terminal-voltage and state-of-charge response of a first-order battery RC model on uniform or native irregular time grids.
- Separate fast and slow battery polarization with an exact two-RC model.
- Identify positive two-RC parameters from voltage data and test them on an independent held-out pulse profile.
- Generate and validate a native Simulink two-RC battery block diagram.
- Estimate real-time battery SOC and RC polarization from noisy current and terminal-voltage measurements with a transparent extended Kalman filter.
- Preserve charge/discharge voltage history with a one-state OCV hysteresis model and validate a deterministic same-SOC reversal minor loop.
- Explore how irreversible electrical losses, reversible entropic heat, and cooling change a lumped cell temperature and temperature-dependent resistance.
- Quantify how lumped cooling conductance changes peak temperature, thermal-limit exposure, and net cooling energy under one shared duty cycle.
- Resolve six cell temperatures along a serial liquid-cooling channel, including coolant warming, cell-to-cell conduction, and module temperature spread.
- Resolve a pouch cell's through-thickness temperature profile with a conservative finite-volume model, asymmetric face cooling, and hot-spot tracking.
- Generate and validate a native Simulink electro-thermal feedback diagram.
- Generate and validate a native Simulink battery RC block diagram.
- Validate model behavior from the command line without opening plots.
- Estimate output voltage, load current, and ripple for an averaged converter.
- Inspect bounded closed-loop voltage tracking for an averaged buck converter.
- Compare open-loop, PI, and filtered-PID load-step regulation on the same averaged buck plant.
- Generate and validate a native Simulink averaged buck-converter diagram.
- Exercise one unified BESS controller through grid-following, grid-forming, islanding, load support, synchronization, saturation, fault, and recovery scenarios with requirement-level traceability.
- Trace every parameter, unit, sign convention, and limitation before extending a model.
Start in 60 Seconds
Seventeen established no-plot checks cover the battery and converter examples.
The unified BESS entry point adds a focused 31-result MATLAB/Simulink suite, so
run_all_checks now invokes eighteen check entry points. All are configured
for MATLAB R2026a, and the validation workflow runs them whenever executable
model code changes.
To try the lab in a browser, use the Open in MATLAB Online badge above. After the repository opens, run this from its root folder:
addpath('examples');
run_all_checks
For a local command-line run:
git clone https://github.com/mohammadrezwankhan/matlab-simulink-energy-lab.git
cd matlab-simulink-energy-lab
matlab -batch "addpath('examples'); run_all_checks"
Concise validation evidence
The latest published validation snapshot is release v0.9.0.
The verified MATLAB R2026a run reports:
| Evidence | Result |
|---|---|
| Repository regression | All 18 MATLAB and Simulink check entry points pass. |
| Two-RC identification (synthetic) | 0.440 mV held-out voltage RMSE; 0.401 mV calibration RMSE. |
| SOC EKF (synthetic) | 0.0066 SOC RMSE; 1.581 mV posterior voltage RMSE. |
| Unified BESS focused suite | 31 focused MATLAB/Simulink results pass across eight mandatory scenarios. |
| Environment | MATLAB R2026a; Simulink is required for generated diagrams. |
These are deterministic regression checks for reduced-order educational models, not physical-cell, hardware, or grid-code validation. In particular, the two-RC identification benchmark uses transparent synthetic voltage records with deterministic sensor-like perturbations, not measured cell data. See the full expected output and provenance and Scope and Limitations before reusing results.
To reproduce the plotted battery response above, run:
run('examples/battery-rc-model/run_battery_rc_model.m')




Models at a Glance
| Example | Question It Explores | Validation | Requirements |
|---|---|---|---|
| Battery RC model | How do charge and discharge pulses affect SOC, terminal voltage, charge throughput, and delivered energy? | check_battery_rc_model.m | Base MATLAB |
| Native Simulink battery RC | Can a generated diagram reproduce the exact first-order battery pulse response and nonlinear OCV lookup? | check_battery_rc_simulink_model.m | MATLAB and Simulink |
| Battery 2RC model and identification | How do fast and slow polarization branches shape voltage recovery, and can their positive parameters generalize to a held-out pulse profile? | check_battery_2rc_model.m, check_battery_2rc_fit.m | Base MATLAB |
| Native Simulink battery 2RC | Can a generated diagram reproduce both exact battery polarization time scales? | check_battery_2rc_simulink_model.m | MATLAB and Simulink |
| Battery SOC EKF | Can noisy voltage measurements correct a biased real-time SOC and polarization estimate? | check_battery_soc_ekf.m | Base MATLAB |
| Battery OCV hysteresis | How does charge/discharge history create different equilibrium voltages at the same SOC after a current reversal? | check_battery_ocv_hysteresis.m | Base MATLAB |
| Temperature-aware battery model | How do loss, entropic heat, cooling, resistance feedback, limit exposure, and cooling-conductance sensitivity affect lumped cell temperature? | check_battery_thermal_model.m, check_battery_cooling_sensitivity.m | Base MATLAB |
| Battery module liquid-cooling network | How do nonuniform heat generation, serial coolant warming, and cell-to-cell conduction determine the hottest cell and module temperature spread? | check_battery_module_cooling_network.m | Base MATLAB |
| Pouch-cell thermal gradient | How do asymmetric face cooling and through-thickness conduction determine the internal hot spot and spatial temperature gradient? | check_pouch_cell_thermal_model.m | Base MATLAB |
| Native Simulink battery thermal | Can a generated discrete diagram reproduce coupled electrical, entropic, and thermal feedback sample by sample? | check_battery_thermal_simulink_model.m | MATLAB and Simulink |
| Converter average model | What do duty cycle and component values imply for average voltage, load current, and first-pass ripple? | check_converter_average_model.m | Base MATLAB |
| Switching buck converter | How do ideal PWM switching waveforms compare with averaged voltage, current, and ripple estimates? | check_switching_buck_converter.m | Base MATLAB |
| Closed-loop converter | How do bounded cascaded control and open-loop, PI, and filtered-PID strategies respond to voltage and load steps? | check_closed_loop_converter.m, check_converter_controller_comparison.m | Base MATLAB |
| Native Simulink averaged buck | Can a generated block diagram reproduce the exact transient and lossy steady state of the averaged equations? | check_average_buck_simulink_model.m | MATLAB and Simulink |
| Unified grid-tied and grid-forming BESS control | Can one controller transition among grid-following, grid-forming, islanded support, synchronization, recovery, and fault-safe behavior with reproducible numeric evidence? | check_bess_unified_control.m (31 focused results) | MATLAB and Simulink |
Current release status: the battery examples, module liquid-cooling network, and three converter references run as MATLAB scripts. Native battery RC, battery 2RC, battery thermal, and averaged buck references additionally generate, compile, and simulate Simulink diagrams. The unified BESS reference generates its model, runs eight mandatory scenarios through MATLAB and Simulink, and publishes requirements, source/assumption boundaries, and validation artifacts.

Why This Lab Is Inspectable
Foundational engineering models are often either too abbreviated to trust or too elaborate to learn from. This repository takes a middle path:
- Small models: the governing logic fits in a short script.
- Visible assumptions: parameters, units, and sign conventions live beside the equations.
- Repeatable checks: no-plot scripts assert basic physical and numerical behavior.
- Engineering context: every example begins with a question and ends with limitations and next steps.
- Extension-friendly: simple baselines make it easier to add controls, higher-order dynamics, measured data, or Simulink implementations.
The examples index connects each model to reproducibility, unit consistency, validation, and review guidance. Shared conventions live in the modeling standards.
Who It Is For
- Students learning how electrical assumptions become executable models.
- Instructors looking for compact examples that can be discussed and modified in class.
- Researchers who need a transparent baseline before introducing higher-fidelity behavior.
- Hobbyists and engineers exploring battery and converter fundamentals without a large framework.
Project Structure
matlab-simulink-energy-lab/
|-- assets/ # Result images used in the documentation
|-- docs/ # Full expected validation output
|-- examples/
| |-- battery-rc-model/ # RC simulation, pulse data, and check
| |-- battery-simulink-model/ # Generated native battery RC diagram
| |-- battery-2rc-model/ # Fast/slow polarization model and check
| |-- battery-2rc-simulink-model/ # Generated native two-RC diagram
| |-- battery-soc-ekf/ # Real-time SOC and polarization estimator
| |-- battery-ocv-hysteresis/ # Dynamic OCV history and minor loops
| |-- battery-thermal-model/ # Coupled electrical-thermal cell model
| |-- battery-module-cooling-network/ # Six-cell liquid-cooling network
| |-- pouch-cell-thermal-gradient/ # Through-thickness finite-volume model
| |-- battery-thermal-simulink-model/ # Generated thermal feedback diagram
| |-- converter-average-model/ # Average-model scaffold and check
| |-- converter-switching-model/ # Ideal PWM switching model and check
| |-- converter-closed-loop-model/ # Dynamic plant, controller, and check
| |-- converter-simulink-model/ # Generated native Simulink model and check
| |-- bess-unified-control/ # Unified BESS modes, builder, tests, evidence
| `-- guides/ # Reproducibility and review notes
|-- notes/ # Repository-wide modeling standards
|-- CONTRIBUTING.md
`-- LICENSE
Requirements
- MATLAB R2026a is the verified release.
- The script-based examples and their validation checks use base MATLAB only.
- Simulink is required for the five generated block-diagram examples, including unified BESS control.
- No power-electronics, control, or testing toolbox is required.
If you run the examples on another MATLAB release, please share the result in an issue so the compatibility record can grow.
Scope and Limitations
- These examples are educational engineering references, not calibrated design models.
- The unified BESS controller is a transparent research translation rather than an exact paper reproduction. Its reduced-order averaged plant, transition/fault supervisor, synchronization thresholds, limits, and tuning include explicit project assumptions. It is not a qualified controller, protection system, or grid-code certification model.
- The battery models use a deliberately simple, replaceable OCV-SOC lookup table that must be calibrated before cell-specific use. The two-RC fitter requires OCV values estimated independently from the terminal-voltage fit.
- The native battery RC diagram receives the reference model's prevalidated, SOC-feasible current trace rather than duplicating its boundary limiter.
- The native battery 2RC diagram uses that same prevalidated current policy and independently integrates both polarization branches.
- The native thermal diagram reproduces a checked discrete educational model; it is not a spatial, safety, or thermal-runaway simulation.
- Its SOC-indexed entropic-coefficient table is illustrative, varies neither with temperature nor ageing, and must be replaced with measured cell data.
- The module cooling network uses lumped cell temperatures and a quasi-steady one-dimensional coolant path; it omits spatial gradients, pressure drop, manifolds, coolant transport delay, pump power, and runaway propagation.
- The pouch-cell thermal model resolves only the through-thickness direction with effective homogeneous properties; it omits tabs, in-plane gradients, layer detail, and electrochemical heat-generation nonuniformity.
- Battery current is zero-order held between supplied timestamps; RC polarization states are propagated exactly over each interval, and applied current is limited to the interval charge available before SOC reaches zero or one.
- The parameter-identification benchmark uses transparent synthetic voltage records with deterministic sensor-like perturbations; it does not claim validation against a physical cell.
- Ageing and cell-to-cell variation are not yet modeled. The OCV hysteresis example is a single-state educational reference with illustrative parameters, not a calibrated chemistry-specific model.
- The SOC EKF uses illustrative OCV and covariance data, assumes exact electrical parameters, and omits current bias, temperature, hysteresis, ageing, and constrained-filter theory.
- The switching converter resolves ideal PWM and inductor copper loss but omits semiconductor loss, dead time, parasitics, EMI, protection, and switched closed-loop control.
- The native Simulink converter is an averaged open-loop model and therefore omits PWM ripple and switching events.
- Parameters and expected outputs must be revalidated before use with real cells, converters, or control designs.
What Should Come Next?
The most useful next additions are likely to be:
- a traceable physical-cell dataset for the two-RC identification workflow;
- switched closed-loop control or a source-backed semiconductor loss model;
- hysteresis-aware SOC estimation with held-out measured reversals; or
- measured thermal-parameter identification and held-out drive-cycle validation.
Request an example, open a focused issue, or propose an implementation through a pull request.
Contribute a Scoped Improvement
Choose an item from the roadmap above or browse the open issues. Before starting substantial work, open or comment on a focused issue so the assumptions, acceptance checks, and ownership are visible. The contribution guide explains the local checks, modeling standard, pull request workflow, and attribution policy.
Releases and Citation
Versioned snapshots and engineering highlights are available on the releases page. See the changelog for the model and validation history.
If you use the lab in research, coursework, or teaching material, use GitHub's
Cite this repository control to export APA or BibTeX metadata. The source
metadata, including the author's ORCID, is available in
CITATION.cff.
Contributing
Contributions are welcome—especially measured-data validation, sourced parameter sets, equivalent-circuit variants, converter topologies, automated checks, and clearer teaching notes. Read CONTRIBUTING.md before opening a pull request.
If the lab saves you time or helps you understand a model, please leave a ⭐. It is the simplest way to support continued open engineering work.
License
Released under the MIT License.
Dự án tương tự
Khám phá các dự án và mô hình AI khác có sự tương đồng.
The Marine Systems Simulator (MSS) is software that supplements the textbook "Handbook of Marine Craft Hydrodynamics and Motion Control," 3rd Edition, by T. I. Fossen, published in 2027 (in progress) by John Wiley & Sons Ltd.
An awesome list of helpful resources for students learning MATLAB & Simulink. List includes tips & tricks, tutorials, videos, cheat sheets, and opportunities to learn MATLAB & Simulink.
This repository contains the MATLAB/Simulink source code to reproduce the experiments presented in the book: "Introduction to Microcontroller Programming for Power Electronics Control Applications"
The Simulink Agentic Toolkit gives your AI agent both the tools and the expertise to work effectively with Simulink and Model-Based Design.
This repository includes codes for comprehensive tutorials in Control / Robotics Engineering. The link of YouTube video tutorials are mentioned in description.
A Simulink-like power electronics simulation environment built on LTspice, featuring ready-to-use circuit libraries and custom tools.
The MATLAB Agentic Toolkit brings proven MATLAB capabilities to AI agents, making engineering and scientific workflows agent-ready.