Interactive dashboard for a grid-tied rooftop solar + battery (BESS) + EV-charger warehouse in Bangkok (MEA service area). Drag the sliders to size the solar and battery, schedule EV charging, and change the load — and watch in real time how the system manages energy across the day and what it does to the electricity bill and investment payback.
Built for customer-facing proposals, using real MEA Time-of-Use tariff numbers.
pip install -r requirements.txt
streamlit run app.pyThe dashboard opens at http://localhost:8501.
- Solar — size (kWp) and today's sunshine %.
- Battery — capacity (kWh), power (kW), and dispatch strategy (smart peak-shaving / self-consumption / TOU arbitrage), plus off-peak grid charging.
- Warehouse load — daytime kW and night-time level (% of daytime).
- EV chargers — number, power per charger, and the charging window.
- Day type — weekday vs weekend/holiday (changes the TOU peak window).
- Assumptions — every tariff and financial input is editable in the sidebar expanders.
- KPIs — solar self-use, energy self-sufficiency, daily saving, peak-demand reduction, CO₂ avoided.
- How the warehouse is powered — hour-by-hour stack of solar / battery / grid meeting demand.
- Battery — state of charge plus charge/discharge power.
- Grid exchange — import (red during peak) and export.
- Where the solar goes — self-used vs stored vs exported.
- Investment & payback — CAPEX, annual saving, payback, and a 25-year cashflow chart.
| File | Purpose |
|---|---|
app.py |
Streamlit UI: sidebar controls + Plotly charts + financials |
model.py |
Pure simulation engine: profiles, hourly dispatch, MEA tariff, annual financials |
test_model.py |
Sanity tests (energy balance, SoC bounds, savings) — pytest |
requirements.txt |
Dependencies |
pytest test_model.py -qMEA TOU Type 3 (22–33 kV): peak 4.1025 / off-peak 2.5052 THB/kWh + Ft 0.1623 (May–Aug 2026) + 7% VAT; demand 132.93 THB/kW-mo; service 312.24 THB/mo; export (net billing) 2.20 THB/kWh. Solar yield 1,400 kWh/kWp/yr (Bangkok). CAPEX: solar 30,000 THB/kWp, battery 15,000 THB/kWh (commercial-LFP estimate — verify with local quotes), EV charger 300,000 THB/unit.
The daily chart is a representative day at the chosen sunshine %; annual figures use a full seasonal year, so daily × 365 ≠ annual (this is intentional — weather varies). Payback is computed on the solar + battery assets; EV charger cost is shown separately.