Calculating with units

Units

Unit conversion is one of the most tedious jobs when doing calculations. Although not very difficult, it is repetitive and time consuming.

For example, lets calculate the stress in a steel beam. Assume that span length is in meters, section dimensions are in mm, geometrical properties are in cm2 (cm3, cm4), section forces are in kN (kNm) and stress is in MPa. That requires you to include a lot of conversion factors in your formulas. So, it would be very helpful if you could write the units next to the respective values and let the software do all the conversions for you.

The most recent version Calcpad Pro 3 supports physical units in calculations. For now, only metric units (SI compatible) are included, but more units will be added in the next versions.

You can attach units to every value in an expression and obtain the result in the specified target units. The target units are added at the end, separated by a vertical bar “|”.  , Open the online calculator and try the following expression by yourself:

2m + 50 cm + 200 mm|dm

Since the target units are “dm“, the answer is 27dm (not just adding 20 + 50 + 200 = 252). That is because all values are converted automatically to the same units before the addition: 20dm + 5dm + 2dm = 27dm. If you do not specify any target units, the units of the first operand will be used.

If you want to do simple unit conversion, just write the value, followed by the source units, a vertical bar and the target units:

25m/s|km/h

The result is 90km/h, which is correct.

You can also attach units to variables and functions. If you have units in an expression that defines a variable, the result will be stored in the variable, together with the calculated units. If you specify target units at the end, they will be used instead. From this point further, the variable will be substituted always with the internally stored units. You can try the following examples:

Input Output
Example 1: Speed
'Distance -'S = 50m
'Time -'t = 2s
'Speed -'V = S/t|km/h
Distance – S = 50m
Time – t = 2s
Speed – V = S/t = 50m/2s = 90km/h
Example 2: Force
'Mass - 'M = 500t
'Acceleration - 'a = 4m/s^2
'Force -'F = M*a|kN
Mass – M = 500t
Acceleration – a = 4m/s2
Force – F = M·a = 500t·4m/s2 = 2000kN
Example 3: Stress in column
'Column load -'F = 2000kN
'Section size -'b = 500mm
'Section area -'A = b^2|cm^2
'Stress -'σ = F/A|MPa
Column load – F = 2000kN
Section size – b = 500mm
Area – A = b2 = (500mm)2 = 2500cm2
Stress – σ = F/A = 2000kN/2500cm2 = 8MPa

If you specify target units after a function definition, they will be attached permanently to this function. The result will be converted to them whenever the function is used further. However, you have to be careful to provide the proper units for the arguments. Otherwise, you can get an error.

Although Excel is still the most popular platform for engineering spreadsheets, it lacks such advantages as automated units. I think that math software is more appropriate for engineers in general, but this will be a topic for future discussions.

Read the next post to see how do units actually work. We will lift the cover and have a quick look inside the Calcpad engine, together.

Published by Calcpad

Hi, my name is Ned. I am a structural engineer with over 20 years of experience in the design of nuclear and industrial facilities, factories, residential and public buildings. I am a fan of engineering, mathematics and computer programming. I spend a lot of time for developing of useful tools that help structural design.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: