A Python simulation of a hydrogen electrolyser control system: voltage and power setpoints, ramp profiles, inverter frequency, safety limits and a small REST API. This post runs it for real, shows what works and what is broken. Simulation only, not for operating real electrolysers. The repository is archived (read-only).
Open-Source Tools · How-To · Energy & fuels models
How to use hydrogen-electrolyser-control: a simulated PEM, AEM and alkaline electrolyser controller
Revised
· v1.0.0 · what changed
Code: github.com/herrrickshaw/hydrogen-electrolyser-control
Watch the walkthrough
Watch on YouTube: youtu.be/1MpY6jGGDkE
Why it is useful
- Who benefits: students and engineers who want a runnable sketch of how an electrolyser controller is structured (setpoints, ramps, safety limits, logging, an API) before touching hardware.
- What it replaces: writing the plumbing yourself. One command compares three electrolyser types and another exposes control over HTTP.
- Evidence from the run: 7 of 8 bundled examples completed; the PEM, AEM and alkaline comparison printed efficiencies of 75.0, 72.0 and 68.0 percent.
- It also shows the limits honestly: I found a crash, a voltage setpoint that is silently clamped, and a production table that is physically wrong. Those are listed below so you do not trust the wrong numbers.
What it is for
The repository holds a control system for three electrolyser types, an advanced layer with ramp profiles, data logging and safety interlocks, a Flask REST API with a Python client, and eight runnable examples. Everything runs against a software model, not a device.
Its own validation notes say that every test used synthetic power profiles and that no hardware testing was done. Simulation only, not for operating real electrolysers. The repository is archived, so it will not receive fixes; treat it as a teaching reference.
Who it is for
- Students learning how electrolyser control is organised
- Energy analysts who want a toy model to explain ramping and safety limits
- Non-programmers who want an AI assistant to walk through each module
- Operating, commanding or commissioning a real electrolyser. This is simulation only.
- Sizing, costing or certifying hydrogen plant. It is not an engineering design.
- Quoting its hydrogen production numbers. The production table I ran is physically wrong (see limits).
What you need
| Requirement | Why | How to get it |
|---|---|---|
| Python 3.7 or newer | runs the modules | python.org or your package manager |
| Flask, Flask-CORS, numpy, requests | the REST API and ramp maths | pip install -r requirements.txt |
| Nothing else | no GPU, no hardware, no accounts | runs on a laptop in seconds |
Get the code and an AI assistant
You do not have to be a programmer. Get the repository, give it to an AI assistant, and ask in plain language. Any of these routes works:
| Tool | What you need | Best for |
|---|---|---|
| GitHub | Free account to fork or star; git to clone, or the green Code button, then Download ZIP, or open in Codespaces | Getting the code and keeping up with updates |
| Claude Code | Claude subscription or API key; run claude inside the cloned folder | Letting the AI read and run the whole repo |
| Gemini CLI | Google account; run gemini inside the cloned folder | The same hands-on workflow with Gemini |
| Claude.ai, Gemini or ChatGPT in the browser | A chat account; upload README.md and the files you care about (or paste the output of git ls-files) | Understanding the project and asking questions without installing anything |
| Other tools (Copilot Chat, Cursor, Codex CLI) | Open the cloned folder in the tool and point it at README.md first | Editing and extending the code |
git clone https://github.com/herrrickshaw/hydrogen-electrolyser-control.git
cd hydrogen-electrolyser-control
claude # or: gemini
Install
- Get the code (the repository is archived, so you can clone it but not push)
git clone https://github.com/herrrickshaw/hydrogen-electrolyser-control.git cd hydrogen-electrolyser-control - Create an environment and install
python3 -m venv .venv && source .venv/bin/activate pip install -r requirements.txt
Quick start: commands and what you should see
Run one example. The menu is interactive, so pipe the choice in
echo 5 | python electrolyser_examples.py
Three runs (PEM, AEM, alkaline) and a comparison summary.
Run the ramp profile example
echo 4 | python electrolyser_examples.py
A time series of voltage, power and efficiency as a ramp is applied.
Start the REST API and drive it with curl
python electrolyser_web_api.py PEM 5000
curl -X POST localhost:5000/api/control/start
curl -X POST localhost:5000/api/control/voltage -H 'Content-Type: application/json' -d '{"voltage": 45.0}'
curl localhost:5000/api/status
JSON replies. Note the README mentions a /api/production path, but the code serves /api/monitoring/production.
Run example 7 (safety limits) to see the crash
echo 7 | python electrolyser_examples.py
The limits print, then an AttributeError traceback.
Sample outputs
Real output from a run on the date shown in the sources line; trimmed to fit.
Comparing the three electrolyser types (example 5)
echo 5 | python electrolyser_examples.py
Type Efficiency H2 (Nm³) Water (L)
------------------------------------------------------------
PEM 75.0% 0.0079 0.0075
AEM 72.0% 0.0075 0.0083
ALKALINE 68.0% 0.0071 0.0100
Best Efficiency: PEM (75.0%)
Best H2 Production: PEM (0.0079 Nm³)
Efficiencies are the model's configured maxima. The hydrogen quantities are for a short simulated run.
A power ramp (example 4, trimmed rows)
echo 4 | python electrolyser_examples.py
t=0.0s: V=30.3V, P=1027W, Eff=63.2%
t=4.0s: V=37.0V, P=1383W, Eff=64.3%
t=8.0s: V=44.5V, P=1987W, Eff=66.2%
t=12.0s: V=47.2V, P=3040W, Eff=69.5%
t=16.0s: V=47.2V, P=3998W, Eff=72.5%
t=18.0s: V=47.2V, P=3998W, Eff=72.5%
Voltage saturates at 47.2 V while power keeps rising, and efficiency climbs with power.
Production at different power levels (example 8): wrong
echo 8 | python electrolyser_examples.py
Power(W) Voltage(V) Current(A) Eff(%) H2(Nm³/h) O2(Nm³/h)
------------------------------------------------------------------------------
500 0.00 0.00 61.6 316.4381 158.2191
1000 0.00 0.00 63.1 316.4381 158.2191
2000 0.00 0.00 66.2 316.4381 158.2191
4000 0.00 0.00 72.5 316.4381 158.2191
4500 0.00 0.00 74.1 316.4381 158.2191
The hydrogen rate is the same 316 Nm³/h at 500 W and 4,500 W, and the voltage and current columns are zero. The stack's own spec says about 0.95 Nm³/h. Do not use this table.
Safety limits and a crash (example 7)
echo 7 | python electrolyser_examples.py
PEM Safety Limits:
Voltage: 30.0V - 60.0V
Current: 10.0A - 150.0A
Temperature: 5.0°C - 80.0°C
Pressure: 1.0 - 35.0 bar
Setting voltage to 45V (normal)... Safe: True
Attempting to set voltage to 65V (exceeds 60.0V limit)...
Safe: False
Alert: Voltage too high: 65.0V > 60.0V
AttributeError: 'ElectrolyserControlSystem' object has no attribute 'safety_monitor'
The limit check itself works, then the script fails on a missing attribute.
REST API session
curl against python electrolyser_web_api.py PEM 5077
POST /api/control/start -> {"status":"started", ...}
POST /api/control/voltage -> {"success":true,"voltage":45.0}
GET /api/status -> "mode":"RAMP_UP", "voltage":0.0, "power":0.0,
"safety":{"alerts":[],"safe":true}, "type":"PEM"
POST /api/control/stop -> {"status":"stopped", ...}
The voltage call reports success, yet the status afterwards shows 0.0 V in the RAMP_UP mode.
Ways to use it
| Method | How it works |
|---|---|
| Command line | Pick an example from the menu or pipe a number into electrolyser_examples.py. |
| Python import | Create an ElectrolyserControlSystem, call start_operation, set_power, ramp_to_power and read status. |
| REST API | Run electrolyser_web_api.py and call it with curl or the ElectrolyserClient class. |
| Ask an AI assistant | Have it explain the PID voltage regulator or fix the broken examples. |
Sample prompts for your AI assistant
Copy, paste and edit the parts in [brackets].
- Claude: Read electrolyser_control_system.py and explain in plain language how the voltage regulator and the safety monitor work together.
- Gemini: Run example 5 and tell me why the alkaline type produces less hydrogen than PEM in this model.
- ChatGPT: I pasted the output of example 8. Why would the hydrogen rate be identical at 500 W and 4,500 W, and what should the formula depend on?
- GitHub (Copilot Chat): Fix example_safety_monitoring so it no longer calls system.safety_monitor.clear(), and re-run example 7.
- Claude: List every place where the README and the code disagree, for example the production endpoint path.
Limits and honest caveats
- Simulation only, not for operating real electrolysers. The repository's own validation notes say all testing used synthetic power profiles and that no hardware testing was done.
- The repository is archived: no fixes will be merged.
- Example 7 crashes with AttributeError (the control system has no safety_monitor attribute). Examples 1 to 6 and 8 completed.
- Setting 45 V does not take effect in the runs I did: example 1 reports 30.0 V throughout, and the log shows 'Voltage 30.0V out of range' errors at start-up.
- Example 8 prints 316 Nm³/h of hydrogen at every power level with 0 V and 0 A, which contradicts the 0.95 Nm³/h spec in the same code.
- Example 2 prints many 'Voltage too low' warnings during the ramp from near zero.
- The README says 'Status: Production Ready' and quotes performance figures; I did not verify those and the validation notes contradict the readiness claim.
- The examples write log and CSV files into the current folder.
Sources: Cloned github.com/herrrickshaw/hydrogen-electrolyser-control (archived) into a clean folder and ran electrolyser_examples.py choices 1 to 8 and electrolyser_web_api.py in a throwaway virtualenv with Python 3.14 on 23 October 2026. Output is copied from those runs and trimmed. The repository was not modified.
- v1.0.0 — 23 October 2026 — first published.
About this article: Researched, written and edited by Umashankar Triplicane Dwarakanathan, with AI research assistance; every figure is meant to trace to the primary source cited. See the Editorial Policy for how sourcing, AI use and corrections work.