A single-file Python calculator that projects how tariff hikes, loss reduction, collection efficiency and subsidy timeliness change an electricity distribution company's debt, and what each path does to a household bill. This post runs it and shows the results and two problems I found. A conceptual scenario tool, not a forecast. The repository is archived (read-only).
Open-Source Tools · How-To · Energy & fuels models
How to use discom-debt-and-revenue-models: a scenario calculator for electricity distribution company debt
Revised
· v1.0.0 · what changed
Code: github.com/herrrickshaw/discom-debt-and-revenue-models
Watch the walkthrough
Watch on YouTube: youtu.be/u9zelV_adSM
Why it is useful
- Who benefits: students, policy analysts and journalists who want to see why distribution company debt grows and which levers change it, with the consumer bill trade-off shown next to the debt.
- What it replaces: a hand-built spreadsheet of the cost-of-supply versus revenue gap. The calculation is a short, readable loop of about forty lines.
- Evidence from the run: on the default inputs, doing nothing takes debt from 40,000 to 175,288 crore rupees over seven years, and only the most aggressive scenario brings it down, at a 50.4 percent rise in the household bill.
- Every input can be changed from the command line, so you can test your own what-ifs in seconds.
What it is for
discom_debt_calculator.py models the yearly economics: energy billed after losses, revenue collected, cost of supply, state subsidy actually received, interest on the debt, and the resulting closing debt. It compares five scenarios and prints a debt trajectory for the best one plus a household bill table.
It is a conceptual scenario calculator, not a forecast. Its own header says it uses flat cost growth, a single blended tariff and no demand response, and that it is no substitute for a regulatory tariff filing or audited accounts. The default company is illustrative. The repository is archived.
Who it is for
- Students and analysts learning why electricity distribution companies accumulate debt
- Writers who want a transparent model to illustrate policy trade-offs
- Non-programmers who want an AI assistant to explain each line
- Forecasting any real company's debt. The defaults are illustrative and the model is deliberately simple.
- Tariff petitions, rating work or investment decisions.
- Concluding that a real policy mix will deliver the numbers printed here.
What you need
| Requirement | Why | How to get it |
|---|---|---|
| Python 3 (tested on 3.13) | runs the script, which only uses the standard library | python.org. Python 3.14 crashes at start-up, see limits |
| Nothing else | no packages, accounts or data files for the calculator | download one file |
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/discom-debt-and-revenue-models.git
cd discom-debt-and-revenue-models
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/discom-debt-and-revenue-models.git cd discom-debt-and-revenue-models
Quick start: commands and what you should see
Run the default illustrative company
python3.13 discom_debt_calculator.py
A header of inputs, a five-scenario table, a year-by-year trajectory for the best scenario, a household bill table and a short interpretation.
Change the inputs
python3.13 discom_debt_calculator.py --debt 50000 --acs 7.2 --arr 6.1 --loss 18
The same report for a company with a wider cost-revenue gap.
Get machine-readable output
python3.13 discom_debt_calculator.py --json
Inputs and year-by-year rows for every scenario as JSON.
Sample outputs
Real output from a run on the date shown in the sources line; trimmed to fit.
Default inputs: five scenarios
python3.13 discom_debt_calculator.py
Opening debt: ₹40,000 Cr | Energy input: 60,000 MU
ACS ₹6.8/kWh vs ARR ₹6.2/kWh (gap ₹0.60/kWh) | AT&C loss 15.0% | collection 98.0%
Interest 9.5% | horizon 7 yrs
Scenario Final debt ₹Cr Δ vs today ₹Cr Outcome
Status Quo (no action) 175,288 +135,288 ▲ debt grows
Tariff hike only (5%/yr) 108,496 +68,496 ▲ debt grows
Loss + collection reform 139,081 +99,081 ▲ debt grows
Combined (UDAY-style) 79,852 +39,852 ▲ debt grows
Aggressive turnaround 36,496 -3,504 ▼ debt cut
Debt in crore rupees after seven years, with the 40,000 crore starting point.
Best scenario, year by year (rows 1, 2, 4, 5, 7 of 7)
Yr ARR ACS Gap Loss% OpGap ₹Cr Debt ₹Cr
1 6.57 7.07 0.50 13.0 -447 44,247
2 6.97 7.35 0.39 11.0 +1,199 47,251
4 7.83 7.96 0.13 7.0 +4,438 49,035
5 8.30 8.27 -0.02 5.0 +6,280 47,413
7 9.32 8.95 -0.37 1.0 +11,073 36,496
The cost-revenue gap closes in year 5, and the operating gap turns positive from year 2.
Household bill at 250 units a month
Scenario Bill yr0 Bill yr7 Increase
Status Quo (no action) ₹ 1,550 ₹ 1,550 0.0%
Tariff hike only (5%/yr) ₹ 1,550 ₹ 2,181 40.7%
Loss + collection reform ₹ 1,550 ₹ 1,550 0.0%
Combined (UDAY-style) ₹ 1,550 ₹ 2,040 31.6%
Aggressive turnaround ₹ 1,550 ₹ 2,331 50.4%
The bill is 250 units times the blended tariff. Operational reform leaves the bill unchanged because it only changes losses and collection.
A harsher company (50,000 crore, cost 7.2, revenue 6.1, losses 18%)
python3.13 discom_debt_calculator.py --debt 50000 --acs 7.2 --arr 6.1 --loss 18
Opening debt: ₹50,000 Cr | ACS ₹7.2/kWh vs ARR ₹6.1/kWh | AT&C loss 18.0%
Status Quo (no action) 239,657 +189,657 ▲ debt grows
Combined (UDAY-style) 147,672 +97,672 ▲ debt grows
Aggressive turnaround 106,051 +56,051 ▲ debt grows
No built-in scenario brings debt down here.
Python 3.14 start-up crash
python3.14 discom_debt_calculator.py
$ python3.14 discom_debt_calculator.py
File ".../argparse.py", line 1750, in _check_help
raise ValueError('badly formed help string') from exc
ValueError: badly formed help string
(cause: help="AT&C loss (%)" has a bare percent sign; Python 3.13 runs fine)
A bare percent sign in an argparse help string. Newer Python versions check help strings when the option is defined.
Ways to use it
| Method | How it works |
|---|---|
| Command line | Change the debt, energy, cost, tariff, loss, collection, interest and horizon flags. |
| JSON for your own charts | Use --json and plot the yearly rows in a spreadsheet or notebook. |
| Edit the scenarios | default_scenarios() lists the five lever mixes; add your own. |
| Ask an AI assistant | Have it explain each line of project() or fix the Python 3.14 crash. |
Sample prompts for your AI assistant
Copy, paste and edit the parts in [brackets].
- Claude: Read discom_debt_calculator.py and explain in plain language how closing debt is computed each year.
- Gemini: Run it with --horizon 3 --collection 90 and tell me why every scenario still grows the debt.
- ChatGPT: I pasted the five-scenario table. Does the script's interpretation line that operational levers cut debt without the tariff burden match the numbers?
- GitHub (Copilot Chat): Change the help string for --loss so the script starts on Python 3.14, and re-run it.
- Claude: Add a scenario where the state subsidy grows with energy cost, and show how it changes the table.
Limits and honest caveats
- A conceptual scenario calculator, not a forecast. The defaults are illustrative, not any real company's accounts.
- Flat cost growth, one blended tariff, no demand response, and a fixed subsidy amount that does not grow with costs, so debt is very sensitive to those assumptions.
- It crashes at start-up on Python 3.14 (ValueError: badly formed help string). I ran it on Python 3.13.
- The script's interpretation text says operational levers cut debt without the full tariff burden, but on the default inputs reform alone ends with higher debt (139,081 crore) than a tariff-only path (108,496 crore).
- The README's heading says subscription-model-revenue, and the second file (a Dirichlet random-numbers script exported from a notebook) is unrelated to power. I did not run it.
- Not a tariff filing, rating opinion or investment advice.
Sources: Cloned github.com/herrrickshaw/discom-debt-and-revenue-models (archived) into a clean folder and ran discom_debt_calculator.py with Python 3.13 (and Python 3.14 to see the crash) on 23 October 2026, using default inputs and the flags shown. The Dirichlet script and the Colab notebook were not run. 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.