Stepping control is a powerful feature for influencing the step increments/decrements while the simulation is already running:
Basically, all stepping variables are subject to default stepping control schemes. These default schemes do literally nothing, so the deltas and boundaries remain constant. If one wants to apply non-trivial algorithms, the SteppingControl section has to be redefined. In the subsection Scheme, a section with the same name as the stepping variable must be added by inheriting the stepping algorithm:
SteppingControl { Scheme { +time : SimpleTimestep; } }
In this example, the stepping variable time (obviously of a transient simulation) is assigned to the SimpleTimestep stepping control algorithm.
The default files not only provide the default algorithms (ConstantStep and StepCondDefault), but also the following non-trivial ones:
If the default algorithms do not serve the purpose, one is encouraged to define individual schemes. For delta steppings, the respective section consists of two independent subsections with predefined names: Failure and Converged. The former is addressed if the simulation of the current stepping configuration failed, the latter is addressed if the solution could be successfully calculated.
The author of the scheme is almost completely free in drawing the right conclusion for the respective simulation. The only constraint is that the characteristic of the stepping function must not be changed. Due to the unmodifiable start and stop boundaries, an increasing stepping function must always be increasing, a decreasing function must always be decreasing.
In order to calculate a new stepping delta, MINIMOS-NT provides the following input to the Failure and Converged section:
MINIMOS-NT reads/expects two variables from the respective stepping control section:
The termination of the stepping is indicated by specific values for deltaNew: one for the logarithmic and zero for the linear case. The author of the stepping algorithm is responsible to adhere to the boundaries deltaMin and deltaMax of the respective stepping function. These boundaries are not enforced by MINIMOS-NT.
A good starting point for writing a new stepping algorithm is to create a new section which is inherited from SchemeDefaults.ConstantStep. This section will look something like this:
NewStepping : SchemeDefaults.ConstantStep { Failure // => reduce the delta { aux d = delta / 1.9; deltaNew = if(abs(d) < abs(deltaMin), if(deltaLog, 1.0, 0.0), d); aux printText = "Decrementing delta: " + delta + " -> " + deltaNew; print = if(deltaNew == delta, "", printText); } Converged // => increase the delta { aux d = if (value == start, delta, delta * 2); deltaNew = if(abs(d) > abs(deltaMax), deltaMax, d); aux printText = "Increasing delta: " + delta + " -> " + deltaNew; print = if(deltaNew == delta, "", printText); } }
For the control of conditional steppings, a different kind of algorithm can be applied. MINIMOS-NT provides values for the following variables:
MINIMOS-NT reads/expects three variables from the respective stepping control section:
The stepping algorithm is always addressed in case valueLow and valueHigh have the same sign since then no zero point can be calculated in-between. This has different consequences for directly and indirectly proportional variables.
Thus, a typical algorithm looks like this:
StepCondDirect : StepCondDefault { +checkSign = 1; valueLowNew = if (sign(condLow) == checkSign, valueLow / 1.5, valueHigh); valueHighNew = if (sign(condLow) == checkSign, valueLow, valueHigh * 1.5); print = if (sign(condLow) == checkSign, "Adaptation: bounds are too high => must be lower", "Adaptation: bounds are too low => must be higher"); }
This algorithm is derived from the default one, inheriting all definitions of the input variables above. Depending on checkSign, the boundaries are either shifted up or down. Due to multiplication and division in this algorithm the sign of the boundaries is not changed. By using inheritance again, the indirect variant is very simple:
StepCondIndirect : StepCondDirect { checkSign = -1; }