Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Running Your Model

A structure, a state machine and a requirement can all be valid declarations before anyone runs them. Checking answers “is this model well formed?” Running asks a different question: “given these inputs and this schedule, what happens?” This chapter uses one calculation, one timed controller and the instrumented machine from Chapter 10. Run the commands from the root of this edition.

16.A What It Means for a SysML v2 Model to Run

Start with the distinction that everything else depends on:

the model     a file (or workspace) of declarations. Has a tree shape,
              cross-references, types. Has no time and no current value.

a run of it   one trajectory through that model. Has a clock, a current
              value for every observable, a history, and a current state
              for every state machine.

The model is not the run. The model is what you wrote. A run is one execution of it. One model has many possible runs.

The language already has vocabulary for this, in KerML rather than SysML. A definition classifies; the thing classified is an occurrence, and clause 9.2.4.2.13 of the KerML specification puts it plainly: “An Occurrence is Anything that happens over time and space (the four physical dimensions). Occurrences can be portions of another Occurrence within time and space, including slices in time, leading to snapshots that take zero time.”

That sentence is the whole abstraction. A run is an occurrence. A tick is a snapshot of it. Asking “what is waterTemp?” of the model is a category error; you ask it of a snapshot.

Authors coming from static tools blur the two. They edit the model when they want to change one run; they talk about the answer when there are many. Hold the distinction and three later patterns become obvious: overriding a binding (§16.C) changes the run, not the model; verification (§16.D) checks a run; a Monte Carlo sweep is N runs over one model.

A run you can read

The controller model distinguishes cold, heating and ready. It starts in cold, waits one simulated second, enters heating, then waits five more seconds. Advancing six seconds lets both timers become due. Here is the timed model used by both commands:

state def BoilerController {
    entry; then cold;
    state cold; state heating; state ready;
    transition switchOn first cold accept after 1 [s] then heating;
    transition reachTarget first heating accept after 5 [s] then ready;
}

Instantiate the part that exhibits the state machine before starting the clock. The first command gives you an initial observation, the second the trace through the two deadlines:

sysml -instantiate Orchestration::EspressoMachine -state 'Orchestration::BoilerController Orchestration::EspressoMachine' src/examples/coffee-machine
sysml -instantiate Orchestration::EspressoMachine -trace -state 'Orchestration::BoilerController Orchestration::EspressoMachine' -advance 6 src/examples/coffee-machine

Without -advance the state command takes the initial transition. Follow the second run’s trace to see what changed. These are delays in the controller example: they do not establish that a physical heater warms water in six seconds. An action is a different kind of behavior. The -action option runs a named action. The successions in BrewController put preparation before extraction and extraction before dispensing:

sysml -action Orchestration::BrewController src/examples/coffee-machine

The example passes the modeled inlet temperature of 93 °C from prepare to extract, and the resulting 36 g dose from extract to pour. A completed action with a 36 g result is different evidence from an assertion that the boiler started in its cold state.

16.B Continuous and discrete models

A controller state such as heating selects a mode. Water temperature is a continuous state variable. In a simple lumped boiler model with constant heat capacity C, the rate is dT/dt = (heaterPower − heatLoss) / C. Multiplying a rate by a duration is valid if the rate stays constant over that interval. If heat loss depends on temperature, the right-hand side must be evaluated along the trajectory. A threshold transition may occur between two samples.

SysML’s StateSpaceRepresentation library names the state equation (GetDerivative), output equation (GetOutput), and dynamics (ContinuousStateSpaceDynamics). Declaring these constructs is not an instruction to use a specific integrator. See Appendix E for hybrid models and the distinction between a computed value and a trajectory.

The thermal example solves the constant-net-power case algebraically. Heating from 20 °C to 93 °C at 1,350 W net with a heat capacity of 1,045 J/K takes about 56.5 s. Watts are joules per second; the kelvin temperature difference cancels the per-kelvin in heat capacity. The calculation in the project is:

calc def HeatTime {
    in thermalMass : Real;
    in target : Real;
    in ambient : Real;
    in heaterPower : Real;
    in heatLoss : Real;
    return seconds : Real = thermalMass * (target - ambient) / (heaterPower - heatLoss);
}

This simple estimate omits pump and control transients. It is undefined at zero net power and does not describe heating if net power is negative.

sysml -calc 'CoffeeMachineAnalysis::HeatTime(1045.0, 93.0, 20.0, 1400.0, 50.0)' src/examples/coffee-machine

16.C One model, many runs

The analysis asks whether heating can finish in 60 seconds. The thermalCheck usage supplies a nominal input; the definition also accepts other heater powers. Vary the input to the definition rather than redefining an already bound value on the nominal usage:

sysml -analysis CoffeeMachineAnalysis::thermalCheck src/examples/coffee-machine
sysml -instantiate CoffeeRequirements::benchMachine -analysis 'CoffeeMachineAnalysis::ThermalAnalysis CoffeeRequirements::benchMachine.brewer' -sweep 'heaterPower=1200..1600:200' src/examples/coffee-machine

At 1,200 W the estimated time is about 66.3 s: this scenario misses the target. At 1,600 W the same formula gives about 49.2 s. All three rows use the same model. OpenSysML returns exit status 1 for this sweep because the first row misses its objective; the other two satisfy it. Inspect the rows rather than discarding the unsuccessful design. None of the estimates is a bench measurement.

16.D Verdicts and traces

A satisfaction claim, a result returned by a verification case and the trace that explains an execution answer different questions. The requirement model gives an instrumented machine a measured extraction temperature. Evaluate the claim against that subject, then run the case which names it:

sysml -satisfy src/examples/coffee-machine
sysml -instantiate CoffeeRequirements::benchMachine -analysis 'Verification::BrewTempTest CoffeeRequirements::benchMachine' src/examples/coffee-machine

A case giving pass for a sample does not prove the temperature never left the band. For a timing problem, inspect the state trace instead. For example, stop the boiler run at time 3 and at time 6; only the latter interval includes the deadline for entering ready. If two steps may run in either order, record the scheduling policy with the evidence; a single trace witnesses one execution. The -schedule, -trace and -render-run options are OpenSysML facilities, not new SysML keywords.

For repeatable evidence, retain the model revision, inputs, tool version, simulated duration, command and result together. That lets a reviewer distinguish a changed design from changed test conditions. Appendix D gives the tool entry points; Appendix F explains when an error prevented a check from running at all.