Proektsoftbg / Calcpad

Free and open source software for mathematical and engineering calculations.
https://calcpad.eu
MIT License
367 stars 45 forks source link

Multiplying Ah and V results in kNm #310

Open fwolter opened 5 months ago

fwolter commented 5 months ago

When you calculate the capacity of a battery in Wh, the result is returned in a strange kNm number. When you force the correct unit, the result is OK.

2Ah*3V
2Ah*3V|Wh

grafik

Proektsoftbg commented 5 months ago

Hi!

Thank you for your feedback. This is because the way of which unit arithmetic works. Composite units are internally represented by vectors of basic units (mass, length, time, etc.). So arithmetic operations are actually performed between those vectors. A a result, we obtain a unit like [kg, m^2, s^-2, ...]. After that, Calcpad looks up in a table and composes the resulting unit back. You can read more about that in this blog post: https://calcpad.blog/2018/01/28/how-units-work/

However, it happens that some units have the same internal representation but different meaning in different engineering/physics fields as it is in your case (torgue - Nm and energy - Wh). But Calcpad does not understand physics and does not "know" what you are trying to calculate. It always looks up in a predefined order - first for mechanical units, then electrical and so on. To be honest, we made it like that for a bit of a selfish reason. We are structural engineers and we made it first to be comfortable for us :).

But we can improve that further of course. We can introduce and option for the user to specify a field (mechanical, electrical, thermal, etc.) and make Calcpad to output the respective units with priority when ambiguous. Even further, it can scan your input units and try to guess what field you are working automatically.

fwolter commented 5 months ago

OK, understood. Thanks for the explaination! I guess it's a feature request, then 😊