Measurement units and dimensionals¶
Physical quantities — lengths, times, temperatures, pressures —
appear everywhere in workflow components. The platform models them
explicitly: a value isn't a Double, it's a DimensionalScalar<*>
with a unit; comparisons and arithmetic respect the unit. This page
covers the schema-level surface (declaring fields with units) and
the run-time surface (using literals and operators in value-model
expressions).
Schema fields¶
Atomic dimensional fields (one quantity, one unit slot):
Each is a shortcut for a dimensionalScalar field with the
corresponding unit profile. The shortcut comes from the underlying
data type dependency — when your component depends on
simscale.physics.dimensionals.scalars:length:1.0.0, the length(name)
function appears in scope.
Vectors:
The general form when no per-quantity shortcut exists:
Each dimensional field has two slots in the JSON: a numerical value and a unit reference. The unit ref must be assignable to the field's unit profile — the framework rejects (e.g.) seconds in a length field at validation time.
Number literals¶
When a component depends on a dimensional data type, that type's generators produce extensions on Kotlin numbers:
1.millimeter // DimensionalScalar<*> in length units
2.5.meter
1000.kilometer
5.second
1.hour
293.15.kelvin
20.celsius
These are framework-side DimensionalScalar instances, not value
models. To use one in a value-model expression, lift with
.asValueModel():
Most operators have overloads that accept the framework-side type directly, so explicit lifting is rarely needed:
condition = configValueModel.edgeLength greaterThan 1.millimeter // works
condition = configValueModel.edgeLength greaterThan 1.millimeter.asValueModel() // also works
Unit profiles in UnitProfile(BaseSIUnits.METER) etc. come from
the framework's framework/measurement-units/core/ module. Custom
units are declarable but typically you'll use the standard SI base
units and prefixed variants.
Arithmetic¶
Dimensional value models support the same operators as RealValue /
IntegerValue:
configValueModel.edgeLength * 2.asValueModel() // length * scalar = length
configValueModel.edgeLength + 0.5.millimeter // length + length = length
configValueModel.edgeLength.componentX() // vector → scalar projection
configValueModel.velocityVector.mag() // vector magnitude → scalar
Type-checking is structural: multiplying a length by a scalar gives a length; adding a length to a length gives a length; you can't add a length to a temperature.
Conversions¶
Unit conversion is implicit in value-model evaluation. Two
DimensionalScalarValues of the same physical quantity but different
units (5.meter and 5000.millimeter) compare equal. The
MeasurementUnitValue slot in a dimensional carries the unit; the
framework's converter normalises during comparison.
For programmatic conversion in value-model code:
configValueModel.edgeLength.toRealValue() // strip units, project to RealValue (in the field's unit profile)
When you don't need this¶
Plain integer or real fields (integer("count"), real("alpha"))
have no unit slot — they're just numbers. Use them when the value
isn't physical (counts, ratios, factors).
For physical values, prefer the dimensional types — the unit-aware arithmetic and validation save real bugs.
Cross-references¶
- Schema description language — for the field declarations.
- Value models — for the operator surface.
- Reference: schema DSL — every dimensional field type and unit option.