Systems-Modeling / SysML-v2-Pilot-Implementation

Proof-of-concept pilot implementation of the SysML v2 textual notation and visualization
GNU Lesser General Public License v3.0
128 stars 24 forks source link

ST6RI-534 Expression arithmetic for quantities and measurement references #467

Closed hpdekoning closed 1 year ago

hpdekoning commented 1 year ago

The update to the Quantities and Units Domain Library enables automated unit / scale conversion, support for coordinate frame transformations, and type checking of expressions that contain quantity values.

The main points are:

  1. Reviewed and updated the concepts and use of QuantityDimension and unitPowerFactors : UnitPowerFactor on MeasurementUnit, also in relation with free and bound vector spaces (isBound : Boolean).
  2. Updated VectorCalculations for calculation definition signatures and to ensure compatibility with the KerML packages VectorValues and VectorFunctions for coordinate frame computations.
  3. Added TensorCalculations with calculation definition signatures.
  4. Added MeasurementRefCalculations to support measurement unit arithmetic.

This update is builds on PR #406 (ST6RI-523 Extended coordinate transformation).

hpdekoning commented 1 year ago

There needs to be a MeasurementReferenceCalculations model (or maybe just UnitCalculations), and the semantic of this needs to be covered in the technical note and specification.

Just added library MeasurementRefCalculations.sysml (keeping the name a little shorter). Will update the Technote and Spec accordingly.

hpdekoning commented 1 year ago

@seidewitz Realized that also multiplication '*' and division '/' operators for CoordinateFrame (VectorMeasurementReference) and MeasurementUnit are required. Can we do that in the same library MeasurementRefCalculations, or since it gives name clashes should it be another library package?

seidewitz commented 1 year ago

Can we do that in the same library MeasurementRefCalculations, or since it gives name clashes should it be another library package?

You can put them in the same package, just give them different names, but specializing the general functions with the standard operator names. The expression syntax keys off the generic function names, so the names of the specialized functions aren't supposed to actually matter (we just try to keep them the same for simplicity when we can).

There is an example of this in CollectionFunctions in which [ is specialized for OrderedCollection, but then it is also further specialized for Arrays, with the name array[.

seidewitz commented 1 year ago

@hpdekoning Also, make the imports private in MeasurementRefCalculations.