## Stimuli Model

The Stimuli Model contains stimulus and clock objects.

### Stimuli

A stimulus is responsible to activate processes. The following different types are available:

- SingleStimulus: Activates the process only once.
- ArrivalCurveStimulus: A list of time-borders in which a specified number of occurrences are expected.
- PeriodicStimulus: Periodic activations based on an offset, a recurrence and (optionally) a jitter.
- PeriodicSyntheticStimulus: Defines a periodically triggered stimuli depending on a defined list of occurrence times.
- PeriodicBurstStimulus: Defines a periodic burst pattern of the process.
- RelativePeriodicStimulus: Periodic activation based on offset and a recurrence.
  In contrast to PeriodicStimulus the recurrence is relative to the last occurrence and a deviation is mandatory.
- VariableRateStimulus: Periodic activations based on other events, like rotation speed.
- InterProcessStimulus: Activations based on an explicit inter-process activation.
  Contains a Counter element if activation is either shifted and / or happening every nth time.
- EventStimulus: Activation triggered by an event, defined in the event model.
  Contains a Counter element if activation is either shifted and / or happening every nth time.
- CustomStimulus: To describe own custom types of activations, including properties.

- PeriodicStimulus: The Time object in the role of offset must not contain a negative value!
- PeriodicStimulus: The Time object in the role of recurrence must not contain a negative value!
- PeriodicBurstStimulus: The Time object in the role of offset must not contain a negative value!
- PeriodicBurstStimulus: The Time object in the role of recurrence must not contain a negative value!
- PeriodicSyntheticStimulus: The Time object in the role of offset must not contain a negative value!
- PeriodicSyntheticStimulus: The Time object in the role of recurrence must not contain a negative value!
- TimestampList: The Time objects in the role of timestamps must not contain a negative value!
- SingleStimulus: The Time object in the role of occurrence must not contain a negative value!
- ArrivalCurveEntry: The Time object in the role of lowerTimeBorder must not contain a negative value!
- ArrivalCurveEntry: The Time object in the role of upperTimeBorder must not contain a negative value!

#### Single

Single allows to specify an activation at a single relative point in time. The single activation occurs after the time units specified by occurrence.

#### Arrival Curves

An arrival curve is described as a list of time-borders in which a specified number of activations are expected. The picture below shows an example for this. In the first picture there is a number of occurrences on a timeline.

In the picture below every distance between two activations is measured. The minimum and the maximum distance is added to the table as time-border for the occurrence of two activations. This means that after one activations there has to be at least a gap of one time-unit before the next activations can occur. It also means that there will be always a second activations within eight time units after the last activations. Basically this would be enough to describe an Arrival Curve Stimulus. But it is possible to create a more precise stimulus by describing additional time borders for greater number of occurrences. This is shown in the steps below.

The same as for two activations in the picture above is done here for three activations. Like already mentioned above, this is an additional restriction for occurrence of an activations.

And for four activations:

The picture below shows the table as arrival curve graph. The red line is the upper-time-border that shows the latest time where the activations will occur. The green line shows the earliest possible time where the activations can occur.

#### Common properties of fixed periodic stimuli

The abstract class FixedPeriodic defines the common attributes of Periodic, PeriodicSynthetic and PeriodicBurst. In general all period based Stimuli specify periodic occurrences based on an offset and a recurrence. The first occurrence happens after the time units specified by offset, and then every following occurrence happens after the time units specified by recurrence. This means, in general, an occurrence of instance i is happening at time t = offset + i * recurrence.

The following figure shows a Periodic Stimulus example with only a fix offset and recurrence time.

#### Periodic

In addition to the standard periodic behavior the Periodic Stimulus can be extended by a Jitter e.g. an Gaussian deviation. The activation time of each occurrence jitters according to the values of the distribution as depicted in the following figure. Depending on the Jitter distribution the upper bound of the current and the lower bound of the next activation can be close to each other or even overlap. The minDistance value allows the user to define the minimum distance between the current and the next activation.

The recurrence of a Periodic Stimulus is absolute. This means that a recurrence of 10ms points exactly to the next activation every 10ms. The Jitter describes the deviation of the occurrence around this absolute value.

#### PeriodicSynthetic

PeriodicSynthetic allows to specify a periodic activation of trigger patterns. It is defined by a list of List of occurrenceTimes, a period recurrence, and an offset. Each time value in occurrenceTimes specifies a single activation at a relative point in time. The moment in time these time values are relative and is defined the following way: an activation of instance i is triggered at time t = offset + floor(i / m) * recurrence + occurrenceTimes[i modulo m].

The following figure shows a Synthetic Stimulus example with two periodic activations after the time units T1 and T2.

#### PeriodicBurst

The PeriodicBurst Stimulus specifies a set of burst activations that are periodically repeated. This means that multiple activations occur very close to each other and this recurs in a periodic matter. The burst pattern has a fixed recurrence period and every burst results in multiple activations.

The number of occurrences per burst are specified via occurrenceCount. The occurrenceMinDinstance defines the minimal distance between them. The burstLength defines the maximum time the burst pattern can last. If the number of occurrences multiplied with the minimum distance between activations is bigger than the burstLength only the number of activations that fit into the burstLength are executed.

#### RelativePeriodic

In contrast to the Periodic Stimulus the RelativePeriodic Stimulus allows to specify relative recurrences. The next activation depends on the current activation time and the added deviation for the next step. The lower and upperBound are specified in the nextOccurrence deviation similar to the Jitter specification in the Periodic Stimulus.

#### VariableRateStimulus

With the VariableRate Stimulus the description of task activation based on e.g. the crankshaft rotation speed or other adaptive variable rate activations.

The step has to be defined as a base value for the following specifications.
In the deviation occurrencesPerStep the lower and upper frequency of the variable rate are described. The distribution can be used to describe the standard frequency occurrences. The user can describe that the frequency is distributed e.g. uniformly over the complete frequency band or as another example the occurrences happens mostly at the Boundaries of the frequency band that can be specified with the CornerCase samplingType in the distribution.
The user can set maxDecrease and maxIncrease values to describe the number of additional respectively reduced task activations that can occur within a predefined time step. With these values, the maximum acceleration and maximum deceleration of the stimuli can be calculated.

An additional feature for the variableRate Stimulus is the description of simulationScenario that specifies the progression of the variableRate over time.
In contrast to the generic specification via statistical values the scenario defines the computation via the samplingOffset and samplingRecurrence property that is modified by a factor based on a clock.

### Clocks

The Clock is triggered based on logical clocks rather than the simulation time, thus providing a dynamic trigger pattern for a simulation. Clock defines the (variable) rate at which a stimulus will be fired. This rate follows a certain pattern defined by the subclasses: ClockFunction and ClockStepList.

#### ClockFunction

A clock function defines the clock period change via a continuous function. There are two functions available: Sine and Triangle. They can be chosen by setting the curveType property.

In the sine clock function the clock period increases and decreases smoothly following a sine wave pattern. The figure below depicts the attributes used to define the sine wave. Note that the sine wave always lies above the x-axis. Adding a positive or negative x-Offset will shift the wave horizontally. The clock fires a stimulus whenever the area under the sine curve is a multiple of one (an integral value). If used in a Scenario this factor can be defined via the samplingRecurrence attribute. As can be seen, the size of the area can be influenced by the yOffset and peakToPeak attributes. In the example shown in the figure the first stimulus is fired at 1.3s, second at 2.06s and so on.

The triangle clock function increases and decreases at a constant rate. The shape of this clock function is governed by the same attributes as the sine wave, only the underlying mathematical definition is different. In the example figure below, the first activation occurs at 0.828s, the second at 1.464s and so on.

#### ClockStepList

The list of clock steps defines the clock period change via a step function. Each ClockStep of that function is defined by a frequency and a time stamp. The optional period attribute of the clock step list can be used to repeat the pattern (exactly like the recurrence in the PeriodicSynthetic stimulus). If the period is not set, the clock rate will remain the same after the last clock step change. Considering the clock steps: <1Hz, 1s>, <3Hz, 3s>, <2Hz, 5s>, <0Hz, 6s>, <2Hz, 7s>, a sampling recurrence of 2, and a period of 9s, the clock step function will result in the plot depicted in the following figure.

#### Example

The engine crankshaft is a good example in which Clocks can be used to model the behavior. Let’s suppose a scenario in which a stimulus is triggered each time the rotating crankshaft reaches a specific angle.

In this example, the engine speed steeply increases from 3000rpm to 6000rpm in 5s, then the speed again decreases to 3000rpm in 5s. An stimulus shall be triggered when the engine crankshaft reaches 30 degrees. Triggering should repeat every two rotations.

Steeply increasing and decreasing pattern fits to the triangle clock function. The equations below show the calculations for the triangle clock function. xOffset is added to make the triangle wave begin at the desired engine speed of 3000rpm:

- yOffset = min.ticks = 3000rpm = 50rps = 50Hz
- peakToPeak = max.ticks – min.ticks = 6000rpm – 3000rpm = 50Hz
- period = 2 * risingSteepTime = 2 * 5s = 10s
- xOffset = risingSteepTime / 2 = 2.5s

Task shall be triggered when the engine crankshaft reaches 30 degrees. Triggering should repeat for every two rotations. The scenario configuration for this example can then be derived as follows:

- samplingOffset = firstTriggerAngle = 30 o / 360 o = 0.0833
- samplingRecurrence = everySecondRotation = 2

The engine crankshaft reaches 30 degrees at 1.66ms. From then on, the crankshaft completes 2 rotations at 41.49ms and 4 rotations at 81ms.

### Mode Value List and Execution Condition

It is possible to change mode label values when a stimulus is executed. The mode labels and their new values are stored in the set-mode-value-list. Via an execution-condition modes also determine if a stimulus is executed.

- ModeValue: The value string must be a valid element of the corresponding Mode!

The set-mode-value-list indicates: Each time the stimulus is executed all mode labels in this list are set to the corresponding value.

The execution-condition is used to determine if a stimulus is executed.