Why unit tracking matters
Imagine planning a solar energy system for a small business park. The goal is simple: generate enough energy to offset grid electricity while staying within budget. But hidden in that simplicity are several layers of complexity. Solar panels produce power in kilowatts (kW), energy storage is measured in kilowatt-hours (kWh), and costs are calculated in euros per megawatt-hour (€/MWh). Without careful tracking, mixing these units could lead to disastrous miscalculations.
For instance, if a model accidentally compares solar power (kW) to energy demand (kWh), it might recommend a system that only meets demand for a single hour rather than a full day. Similarly, confusing metric tons of CO₂ with kilograms could make a carbon reduction strategy appear 1,000x more effective than it truly is. In sustainability, where every decimal point translates to real-world impact, units are not just numbers, they are the foundation of our future.
Unit tracking:
- Prevents errors by catching mismatches early.
- Keeps models clear so you know exactly what each number represents.
- Builds trust in our results, giving clients confidence in the data.
How we track units
Optimisation models are the backbone of much of our consulting work. Specialised software libraries allow us to encode problems with thousands of variables and constraints, from energy mix calculations to supply chain logistics. However, these tools focus on the math, not the meaning behind the numbers. Without built-in unit tracking, the responsibility falls on the human modeler.
To tackle this, we developed our own package to integrate two Python libraries: Pint, a powerful unit-handling tool, and Linopy, a modeling library. The result is a system where every variable, constraint, and result carries its units natively, ensuring consistency and clarity.

Benefits for our team and clients
- Reduced human error
Having the units integrated into the code means we catch mistakes quickly. This translates into more reliable results and less time debugging. - Automatic unit conversions
Our system handles the arithmetic of units smoothly. For example, when modeling a battery’s state of charge, you can multiply a power flow by a time step to automatically get energy in whatever unit is desired. Similarly, adding quantities in different but related units (e.g. kilograms and tonnes) “just works”, eliminating tedious manual conversions. - Clearer model documentation
Anyone reading or modifying the model can see immediately which units each variable or parameter holds. This clarity makes the models more accessible to new team members and stakeholders. - Consistent collaboration
Models often live in shared repositories. With unit tracking, a new collaborator cannot inadvertently break the unit consistency without noticing. Pint and our integration with Linopy will raise flags when something does not match up. - Enhanced trust in optimization outcomes
Clients rely on robust, transparent solutions. By building unit tracking directly into our optimization workflow, we offer an extra layer of assurance that our models are built on a solid foundation.
By integrating unit tracking into our modeling process, we ensure that our sustainability solutions are both innovative and reliable. If you would like to learn about our approach to sustainability consulting through data-driven modeling, contact us at info@doingthemath.nl.
Let us keep “doing the math” to power a more sustainable future—one accurately tracked kilowatt-hour at a time!


