6
$\begingroup$

When doing engineering calculations it is great convenience to do have software that keeps track of units.

Example when calculate something trivial as stress:

$\sigma = \frac FA$

And be able to write:

$\frac {1kN}{1m*1mm}$ and get the answer in MPa

This is by nature a poll thread that i know is frowned upon on StackOverflow, is it going to be closed?

  • 0
    Write that as an answer, I guess F# is an answer too though I was looking for a GUI app.2012-11-01

11 Answers 11

6

Google Calculator does this nicely for units it knows about:

enter image description here

And you can't beat the price.

  • 0
    You also need to be able to put your expression on one line, or re-do a bunch of cutting and pasting every time you need to update a subexpression.2016-10-10
2

One of the top search results for "units software" is the appropriately named GNU Units, which lets you say

You have: ten furlongs per fortnight You want: kilometers per hour 

and tells you "0.0059871429".

  • 0
    Can still be some use with a comprehensive list. I up-voted.2012-11-01
2

There is SpeQ Mathematics for Windows environments. It is probably more of what your looking for.

http://www.speqmath.com/index.php?id=1

1

I'll add F# to the list.

Floating point and signed integer values in F# can have associated units of measure, which are typically used to indicate length, volume, mass, and so on. By using quantities with units, you enable the compiler to verify that arithmetic relationships have the correct units, which helps prevent programming errors.

1

MathCad handles units in a nice way but it is too expensive for home use.

  • 0
    There is a limited feature no cost version now.2016-10-10
1

You might be interested in Frink.

It has an interpreter that you can download as a desktop app. It also has a web interface, which lets you type

in  >> 1 kN / (1 m * 1 mm) out >> MPa 

to get

result >> 1 MPa 

There is a list of sample calculations covering a wide variety of physical applications.

1

I'll throw my hat in the ring too. Maxima [1] has an add-on package ezunits which carries out various dimensional operations. Quantities can be symbolic (e.g. x meters per year) as well as numerical. The notation is, I hope, convenient: single left quote to indicate units, double left quote to indicate conversions. For the given example:

load (ezunits); F : 1 ` kN; A : 1 ` m * 1 ` mm; sigma : F/A `` MPa;   => 1 ` MPa 

There's more to be said, but I'll let it be enough for now. Disclaimer: I wrote the ezunits package.

[1] http://maxima.sourceforge.net

1

The Squants library provides units of measure for Scala, including a natural-language DSL:

val load1: Power = Kilowatts(12)        // returns Power(12, Kilowatts) or 12 kW val load2: Power = Megawatts(0.023)     // Power: 0.023 MW val sum = load1 + load2                 // Power: 35 kW - unit on left side is preserved sum should be(Kilowatts(35))             sum should be(Megawatts(0.035))         // comparisons automatically convert scale   val load1 = 100 kW                  // Simple expressions don’t need dots val load2 = 100 megaWatts val time = 3.hours + 45.minutes     // Compound expressions may need dots 

(Example taken from the README.)

1

insect has both web- and terminal-based versions. It does support parsing, handling and conversion of physical units, for example:

>>> 4kN / (0.8m * 2mm) -> MPa     = 2.5MPa  >>> 2min + 30s     = 2.5min  >>> 40000km / speedOfLight -> ms     = 133.426ms  >>> 6Mbit/s * 1.5h -> GB     = 4.05GB  >>> 2J·s + 3W    Unification error:      Cannot unify unit W (base units: kg·m²·s⁻³)             with unit J·s (base units: kg·m²·s⁻¹) 
0

I would suggest finding a package for doing this in your programming language of choice, since you're going to be using that to check/automate your engineering calculations anyways.

For R

The units library is one option. It looks something like this:

> library('units') > m <- ud_units$m; mm <- ud_units$mm; kN <- ud_units$kN; MPa <- ud_units$MPa > sigma <- 1*kN/(1*m * 1*mm) > units(sigma)= MPa > sigma 1 MPa 

If you try an operation that mixes dimensions, it throws an error:

> 1*m + sigma Error: cannot convert MPa into m 

However, if you try an operation that mixes units of the same dimensions, it just puts the result in one of those units:

> 1*m + 1*mm 1.001 m 

I haven't used the units library enough to vouch for its stability, but R libraries are typically very stable and well tested.

For Python:

There are a few options available (one of the curses of a language that's popular among CS folks), but I think the magnitude module is the cleanest looking. It works like this:

>>> from magnitude import mg >>> x= mg(1,'m') >>> y= mg(1,'mm') >>> F= mg(1,'kN') >>> sigma= F/(x*y) >>> print(sigma.ounit('MPa')) 1.0000 MPa 

This module still has a semi-serious bug which causes it to give very misleading output if you try to assign an invalid unit to an existing variable. It also has the downside that you can't freely switch between the objects created my mg() and the usual numeric types. e.g., instead of numpy.pi*mg(5,'m')**2 you'd have to wrap pi in mg() with no units as in mg(numpy.pi)*mg(5,'m')**2.