Chapter 14. Quantity Values and Quantity Types

System models need a way to represent quantities and their measurement references (units, scales, coordinate frames) based on established international standards, in particular the International System of Quantities (ISQ), the International System of Units (SI) and the US Customary Units.

ISQ defines seven base quantity types: Length, Mass, Time, Electric Current, Thermodynamic Temperature, Amount of Substance, and Luminous Intensity.

A quantity value is defined as an ordered pair of a numerical value and a measurement reference. In the simplest case, a measurement reference is a simple unit such as the length unit "m".

For example, a length value expressed as 15 mm is of the same type (LengthValue) as a length value expressed as 0.015 m. An attribute can be initialized with a length value in the following way:

attribute width : LengthValue := 0.015 [m];

Or, using the length unit of mm:

attribute width : LengthValue := 15 [mm];

In SysML v1, a quantity value property type combines a quantity type and a unit. Consequently, using different units of the same quantity types, such as gram and kilogram, requires defining different quantity types.

Existing quantity ontologies/schemas (such as QUDT or FIBO Quantities and Units) do not support measurement scales and have only limited support for quantity dimensions, vector/tensor quantities and coordinate frames, which are needed for quantifying vectors and tensors. Interval measurement scales are needed, e.g., for time instants and durations. An example of an ordinal measurement scale is the Rockwell C hardness scale. A logarithmic measurement scale is needed, e.g., for the sound pressure level measured in dB, and a cyclic measurement scale is needed, e.g., for the rotation angle measured in angular degrees.

The Quantities and Units Domain Library of SysML v2 defines a comprehensive set of quantity concepts including the ISQ and SI concepts, the most important of which are:

  1. LengthValue and LengthUnit,
  2. MassValue and MassUnit,
  3. TimeValue and TimeUnit,
  4. ElectricCurrentValue and ElectricCurrentUnit,
  5. ThermodynamicTemperatureValue and ThermodynamicTemperatureUnit.
Figure 14-1. A fragment of the Quantities and Units Domain Library showing Length and Mass concepts.
???

Importing SI Units and ISQ Quantity Types

For being able to use predefined units and predefined unit prefixes, such as milli, the standard library SI is imported first with all its elements. Likewise, for being able to use predefined quantity value types and predefined quantity unit types, such as ElectricCurrentUnit, the standard library ISQ is imported like so:

private import SI::*;
private import ISQ::*;

In the sequel, for simplicity, these import statements will often be omitted.

Typing Attributes by Quantity Types versus Subsetting Them from Predefined Quantity Attributes

Instead of typing an attribute by an ISQ quantity type like

attribute width : LengthValue;

it can alternatively be subsetted from a corresponding quantity attribute predefined in the ISQ library:

attribute width  LengthValue;

User-Defined Units

Units (such as mA for milliampere) that are not predefined in the standard library SI, have to be defined in a user model. Using unit prefixes (such as milli), which are predefined in the SI library, they can be defined like so:

attribute mA : ElectricCurrentUnit = milli * A;

Such a unit definition can then be used when defining variables highLevel in the form of an attribute as follows:

attribute highLevel : ElectricCurrentValue = 20.0 [mA];

Example: Defining the Composition of Atoms

The following example is based on a model of a PWR nuclear power plant presented in the Google Group "SysML-v2-Release". It illustrates the use of units, quantity types and quantity values (and provides an example of a constraint).

// dalton (unified atomic mass unit)
attribute Da : MassUnit = 1.66054*10^-27 [kg];
// elementary charge
attribute e : ElectricChargeUnit = 1.6*10^-19 [C];
part def Particle {
  attribute mass : MassValue;
  attribute charge : ElectricChargeValue;
}
part def Proton specializes Particle {
  redefines mass = 1.0072766 [Da];
  redefines charge = 1[e];
}
part def Neutron specializes Particle {
  redefines mass = 1.008665 [Da];
  redefines charge = 0 [e];
}
part def Electron specializes Particle {
  redefines mass = 1/1837 [Da];
  redefines charge = -1 [e];
}
part def Atom {
  // an atom has up to 118 protons
  part proton[1..118] : Proton;
  // an atom has up to 176 neutrons
  part neutron[0..176] : Neutron;
  // an atom has up to 118 electrons
  part electron[1..118] : Electron;
  attribute mass : MassValue = proton.mass + neutron.mass + electron.mass;
  // an atom must have the same number of protons and electrons
  assert constraint PnE { size( proton) == size( electron) }
}