Holarch
Course chapters

Training · Track 9. SysML v2 Fundamentals · Chapter 9.7 of 8

9.7 Constraints and Calculations 4:26

Write constraints and calculations, check the sedan's values with units, and mark open values.

Shows Holarch 2.22.

What you’ll learn

  • Write a constraint definition and a calculation definition with parameters
  • Bind a constraint usage's parameters to values in the model
  • See a constraint pass and fail in a Parametric View, and check every constraint with Solve All
  • Mark open values with TBD and TBR metadata and find them in the TBD/TBR register
  • Roll up a part's mass in Budgets & TPMs

Write SysML v2 constraints and calculations in Holarch, following the SysML v2 tutorial Constraints and Calculations on a small Hybrid Car project: a constraint definition and a calculation, a constraint usage bound to the sedan's values, a Parametric View where the check fails and passes, Solve All, an analysis case, TBD and TBR values with their register, and a mass roll-up in Budgets. SysML is a registered trademark of Object Management Group, Inc.

Project files

  • Finished project (.holarch.json; Manage Projects → Project Files ▾ → Import Project (.json)…)

The video plays from holarch.app; see the Privacy Policy.

Practice

Do this yourself in Holarch, on the Hybrid Car demo project (SysML v2).

  1. Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package VehicleRequirements.
  2. After constraint def SpeedLimit, add constraint sedanBatteryCheck : MassLimit { in mass = fleet.sedan.powertrain.battery.mass; in limit = 50 [kg]; }.
  3. On the Diagrams page, click + New Diagram, choose Parametric View and VehicleRequirements under Shows, and click Create. The new check passes: 48 kg is within 50 kg.
  4. In the package Vehicles, change the sedan battery's mass to 52 [kg]; the view shows the check failing. Press ⌘Z / Ctrl+Z, then click Solve All to check every constraint again.
  5. In requirement def <'VR-2'> Acceleration, replace attribute zeroToHundred : TimeValue; with attribute zeroToHundred : TimeValue { @TBD { owner = "Test lead"; rationale = "The test track is not booked yet."; } }. Open Needs & Requirements → TBD/TBR and find the requirement with its owner.
  6. Open Architecture → Budgets & TPMs, click Select Root Part… and choose sedan. Under Quantity, choose Mass and find the battery's 48 kg.

You're done when sedanBatteryCheck shows Pass in the Parametric View and the TBD/TBR register lists the Acceleration requirement with the owner Test lead.

Check yourself

  1. What is the difference between a constraint def and a calc def?
  2. A constraint in the Parametric View shows Needs input. What is missing?
  3. Why mark an open value with #TBD or @TBD { … } instead of writing TBD as the value?
  4. What does an analysis case add to a calculation?
Show the answers
  1. What is the difference between a constraint def and a calc def?

    A constraint definition states a condition over its parameters that holds or not, such as mass <= limit. A calculation definition computes and returns a value, such as return ratio = power / mass;.

  2. A constraint in the Parametric View shows Needs input. What is missing?

    A parameter has no value yet. Bind every parameter to a value, for example in mass = fleet.sedan.curbMass;.

  3. Why mark an open value with #TBD or @TBD { … } instead of writing TBD as the value?

    TBD in place of a value is not valid SysML. The metadata from Holarch's HolarchMetadata package keeps the text valid; TBD and TBR specialize the standard StatusInfo metadata, so other SysML v2 tools read them as status annotations.

  4. What does an analysis case add to a calculation?

    It applies the calculation to a subject, such as the sedan, returns the result, and has an objective whose require constraint Holarch evaluates like any other constraint.

Read more

Transcript

Show the transcript (narration and what is on screen)

Introduction

Chapter seven: constraints and calculations. They turn the model's values into checks and results that Holarch evaluates with units.

In this chapter you write a constraint and a calculation, bind a check to the sedan's values, see it fail and pass in a Parametric View, run an analysis case, and mark open values.

Start the tutorial

Start the tutorial Constraints and Calculations from Project Files, Start a Tutorial. Its starter project holds the sedan with its engine and battery values, and two targets: the maximum curb mass and the minimum power to weight.

On screen: Project Files ▾ → Start a Tutorial… → SysML v2: Constraints and Calculations → Start; Model → Editor.

Constraints and calculations

A constraint definition states a condition over its parameters. After the constraints comment, write the mass limit: the mass is at most the limit.

On screen: After // ---- Constraints and calculations ----: constraint def MassLimit.

Below it, a calculation: power to weight divides the power by the mass, and returns the ratio.

On screen: Below it: calc def PowerToWeight.

A constraint usage binds each parameter to a value: here, the sedan's curb mass and the maximum curb mass.

On screen: Below it: constraint sedanMassCheck : MassLimit with bound inputs.

The Parametric View

Open the Diagrams page, click New Diagram, and choose Parametric View. Choose the vehicle analysis package under Shows, and click Create.

On screen: Diagrams → + New Diagram → Parametric View; Shows: VehicleAnalysis; Create.

The check shows its expression, with its parameters bound to the values. Fifteen hundred eighty kilograms is within sixteen hundred fifty, so it passes.

On screen: The mass check: pass.

In the Editor, change the sedan's curb mass to seventeen hundred kilograms. Back in the Parametric View, the mass check now fails.

On screen: Model → Editor: curbMass 1580 → 1700; Diagrams → the Parametric View: fail.

Change it back to fifteen hundred eighty in the Editor. In the view, Solve All checks every constraint again, with units.

On screen: Model → Editor: 1700 → 1580; the view → Solve All → Pass; Close.

An analysis case

An analysis case computes a result for a subject. At the end of the package, add the power to weight analysis, and apply it to the sedan. Its objective requires at least the minimum, and the checker evaluates it like any constraint.

On screen: Model → Editor; after sedanMassCheck: analysis def PowerToWeightAnalysis; analysis sedanPowerToWeight.

TBD and TBR

Values that are still open get a mark. First import Holarch's metadata package after the other imports.

On screen: After the imports: private import HolarchMetadata::*;

Then add a charge time requirement. TBR marks the time limit to be reviewed, and TBD marks the charger power to be determined, with an owner, a due date and a rationale. Both come from Holarch's metadata library and specialize the standard status metadata, so other SysML v2 tools see them as status annotations.

On screen: At the end: requirement def <'VR-5'> ChargeTime with #TBR and @TBD.

Open Needs and Requirements, then TBD/TBR. The charge time is listed with the owner and the due date from its metadata. The register only lists them: to change them, edit the metadata in the Editor.

On screen: Needs & Requirements → TBD/TBR; the ChargeTime row with owner and due date.

Budgets

Last, open Architecture, then Budgets, and select the sedan as the root part. The quantity Mass reads each part's mass attribute with its unit: the battery shows the sedan's own forty eight kilograms.

On screen: Architecture → Budgets & TPMs → Select Root Part… → sedan; the battery 48 kg.

Recap

Every step is ticked off. Click Mark as Done.

On screen: Step panel → Mark as Done.

Let's recap. You wrote a constraint and a calculation, bound a check to the sedan's values, saw it fail and pass in a Parametric View, ran an analysis case, marked open values for the register, and rolled up the mass.

Next, variants and configurations describe a product line.