Inspiration
Engineering calculations often look correct even when there is a hidden mistake in the units, dimensions, or conversion process. As engineering students, we regularly work with different unit systems and formulas, and small mistakes such as mixing kN with N, mm² with m², or using a dimensionally inconsistent equation can completely change the final result.
This inspired us to build UnitGuard, a simple tool that helps users check the fundamental building blocks of an engineering calculation before trusting the answer.
What it does
UnitGuard combines three engineering tools in one web application:
- Calculation Checker – evaluates engineering expressions using numerical values and physical units, checks the expected output dimension, and returns the result in both the requested unit and SI/base-unit form.
- Dimensional Checker – checks whether both sides of a complete engineering equation have the same physical dimensions without requiring numerical values.
- Engineering Unit Converter – converts between common engineering units across 33 categories with 177 preset unit options, while also supporting custom unit expressions and Unicode notation such as
mm²,kg·m⁻³, andN·m.
UnitGuard also rejects dimensionally incompatible calculations or conversions instead of returning misleading results.
How we built it
UnitGuard was built in Python using:
- Streamlit for the web interface
- Pint for physical quantities, units, and conversions
- pandas for editable variable tables
- Python's Abstract Syntax Tree (AST) tools for safe mathematical expression parsing
Instead of using unrestricted Python eval(), UnitGuard uses a restricted expression evaluator that only allows approved mathematical operations and defined variables.
We also implemented validation for invalid units, duplicate variables, oversized inputs, invalid exponents, non-finite results, dimensional mismatches, and unsupported expressions.
Challenges we ran into
One major challenge was building the Dimensional Checker so that equations could be analysed without numerical values. We created a separate dimensional evaluation system that tracks the powers of fundamental dimensions such as mass, length, and time.
Another challenge was handling the large variety of engineering unit notation. Inputs such as superscripts, temperature units, percentages, SI prefixes, and different imperial and metric unit systems required careful normalization and testing.
We also had to account for the limitations of dimensional analysis. Different physical quantities can share the same dimensions, such as energy and torque, so dimensional consistency alone cannot always determine the exact physical meaning of a result.
Accomplishments that we're proud of
We are proud that UnitGuard developed from a simple unit-aware calculation checker into a complete engineering validation tool with three integrated functions.
The final prototype includes:
- 33 engineering unit categories
- 177 preset unit options
- Unicode engineering notation support
- Safe AST-based expression evaluation
- Dimensional consistency checking
- Incompatible-unit detection
- Protection against invalid and non-finite calculation results
- 76 automated tests, all passing
We also improved application performance by caching the Pint UnitRegistry while keeping the interface simple and easy to use.
What we learned
We learned how dimensional analysis can be implemented computationally instead of only being performed manually.
We also gained experience with safe expression parsing, unit-aware programming, error handling, automated testing, debugging, and integrating multiple engineering tools into a single application.
Most importantly, we learned that a numerically valid calculation is not necessarily a physically valid calculation. This became the central idea behind UnitGuard.
What's next for UnitGuard
Future improvements could include support for additional mathematical functions such as trigonometric and logarithmic operations, a larger engineering quantity library, saved calculation history, and more guided examples for different engineering disciplines.
We would also like to improve the interface so that variables can be detected automatically from an entered expression and eventually expand UnitGuard into a more complete engineering calculation validation platform.
Log in or sign up for Devpost to join the conversation.