Units

Units are at the heart of Insight Maker. The flows into a stock should have the same units as the contents of that stock. Similarly, you should be able to specify the units for the different variables and converters in your model.

Insight Maker allows you to enforce units using its unit mechanisms. As you construct your model, you may define the units for the different parts of your model. For instance, you may add a stock representing a lake with units of Cubic Meters. You may have a river flowing into the lake with units of Cubic Meters per Second. When you run a simulation, Insight Maker will check to make sure that the units you have defined are consistent. If they are not consistent (for instance you try to subtract a number with units of Meters from one with units of Liters) Insight Maker will display an error and terminate the simulation.

When you define a number in Insight Maker, it is automatically defined as Unitless. When the value of a valued primitive (stock, flow, variable, or converter) whose units are defined is referenced elsewhere in your model, Insight Maker will evaluate its equation. If the result of this evaluation is a Unitless number, Insight Maker will then assign the units of that primitive to the value. If, however, the value is not Unitless and the units conflict with the primitive’s units, then an error will be displayed.

Defining Values With Units

You may define a number with specified units in your equations using a special, curly-bracket notation:

{2 Meters} + {10 Centimeters}

Unit names are case-insensitive, and singular and plural forms are equivalent, so {1 meter}, {1 Meter}, and {1 Meters} all mean the same thing:

{1 meter} + {50 centimeters}

Automatic Unit Conversion

Insight Maker automatically converts between compatible units in calculations. When you add or subtract quantities, the result is expressed in the units of the left-hand value:

{5 Miles} + {2 Kilometers}
{1.5 Hours} + {30 Minutes}

Subtraction works the same way, converting the right-hand value before subtracting it:

{100 Inches} - {1 Meter}

Conversion also applies to comparisons, so quantities can be compared regardless of the units they are expressed in:

{2 Meters} = {200 Centimeters}
{1 Mile} > {1 Kilometer}

Compound Units

Units can be combined with *, /, and ^ to form compound units like speeds, flow rates, and areas. When you multiply or divide quantities, their units multiply and divide too:

{120 Kilometers} / {2 Hours}

Units cancel algebraically. Dividing a volume by a flow rate yields a time. This is how long it takes to fill a 2,000 liter tank at 25 liters per minute:

{2000 Liters} / {25 Liters/Minute}

Multiplying a rate by a time yields a quantity:

{7 Widgets/Year} * {10 Years}

Dividing a compound unit by a plain number leaves the unit untouched:

{2 Meters/Second} / 4

Exponents work on units as well. Squaring a length produces an area, and taking a square root halves the unit exponents:

{2 Meters}^2
{25 Meters^2}^(1/2)

Compound units are tracked symbolically through any calculation. For example, multiplying a mass by an acceleration produces a force (this result, kilograms meters/second², is the definition of a Newton):

{70 Kilograms} * {9.8 Meters/Second^2}
{1 Newton} = {1 Kilogram} * {1 Meter/Second^2}

When a multiplication or division combines quantities from different unit systems, Insight Maker may express the result in canonical base units rather than the units you typed. The result is correct, but it may not be displayed in the units you expect:

{60 Miles/Hour} * {10 Minutes}

That result, 16,093.44 meters, is exactly 10 miles. The "Converting and Removing Units" section below shows how to convert it back to the units you want.

Incompatible Units

When an equation combines incompatible units, Insight Maker reports an error rather than computing a meaningless result. During a simulation, that error stops the run:

{1 Grams} + {3 Centimeters}

Adding a plain, unitless number to a value with units is also an error, as Insight Maker cannot know what units the plain number was meant to have. The error message suggests the likely fix:

1 + {3 Centimeters}

Some functions are only defined for unitless values. Logarithms, exponentials, and trigonometric functions such as Ln, Log, Exp, Sin, and Cos will report an error if given a value with units:

Ln({1 Meter})

Custom Units

Insight Maker comes with a large number of units built-in (see the reference table at the bottom of this page). But you are not limited to them: any name you use in the curly-bracket notation automatically becomes a custom unit. This lets you model quantities in whatever terms your system uses, such as products, patients, tickets, or animals:

{7 Widgets} + {3 Widgets}

Custom units participate fully in compound units and cancellation:

{5 Widgets/Day} * {1 Week}

Distinct custom units are not interchangeable:

{3 Widgets} + {2 Gadgets}

Because unrecognized names silently become new custom units, a misspelled built-in unit creates a separate, incompatible unit rather than an error where you defined it. Here Metre (a misspelling of the built-in Meter) becomes its own custom unit, so the addition fails:

{1 Metre} + {1 Meter}

If you see an "incompatible units" error you didn't expect, check the unit names in the error message for typos.

Converting and Removing Units

Sometimes you need a plain number, either for a function that requires unitless input or to report a ratio. Dividing two quantities with the same dimensions produces a unitless result, which makes division a natural way to both convert and strip units:

{1 Year} / {1 Day}
{100 Meters} / {1 Kilometer}

Units and Functions

Most mathematical functions work naturally with units:

Round({2.5 Meters})
Abs({-5 Meters})

Aggregation functions such as Mean, Max, Min, and Sum convert their arguments to compatible units before combining them:

Mean({1 Meter}, {2 Meters}, {6 Meters})
Min({5 Seconds}, {1 Minute})

Functions that are mathematically defined only for pure numbers (Ln, Log, Exp, and the trigonometric functions) report an error when given units. Use RemoveUnits to convert such values explicitly first.

Units and Vectors

Units and vectors follow the normal vector arithmetic logic:

{1, 2, 3} * {2 Meter}
Sum({1, 2, 3} * {1 Meter})

Built-in Units

The following units are built into Insight Maker, organized by the quantity they measure. All names are case-insensitive and may be written in singular or plural form. Units within a category convert automatically; units from different categories do not mix (except through multiplication and division).

Category Units
Length Millimeters, Centimeters, Meters, Kilometers, Inches, Feet, Yards, Miles
Area Square Millimeters, Square Centimeters, Square Meters, Square Kilometers, Hectares, Square Inches, Square Feet, Square Yards, Square Miles, Acres
Volume Cubic Millimeters, Cubic Centimeters, Cubic Meters, Cubic Kilometers, Liters, Fluid Ounces, Quarts, Gallons, Acre Feet
Time Seconds, Minutes, Hours, Days, Weeks, Months, Quarters, Years
Mass Milligrams, Grams, Kilograms, Tonnes, Ounces, Pounds, Tons
Speed & Acceleration Meters per Second, Meters per Second Squared, Feet per Second, Feet per Second Squared, Miles per Hour, Miles per Hour Squared, Kilometers per Hour, Kilometers per Hour Squared
Flow Rates Liters per Second, Cubic Meters per Second, Gallons per Second, Gallons per Minute, Pounds per Second, Kilograms per Second
Power Watts, Kilowatts, Megawatts, Gigawatts
Energy Joules, Kilojoules, Calories, Kilocalories, BTUs
Electrical Amperes, Coulombs, Volts, Millivolts, Kilovolts, Farads
Force Newtons, Pounds Force
Pressure Pascals, Kilopascals, Bars, Atmospheres, Pounds per Square Inch
Currency Dollars, Euros (plus rates such as Dollars per Year)
Angle Degrees, Radians
Quantity Atoms, Molecules

Compound forms of any of these can always be written directly in the curly-bracket notation, such as {5 Kilograms/Day}, {100 Dollars/Month}, or {9.8 Meters/Second^2}. As described above, any name not in this table defines a custom unit.