Stop Condition
The Stop Condition node () stops the solver when any of the specified conditions are fulfilled. It is an optional attribute subnode to the Parametric, Time-Dependent Solver, and Time-Explicit Solver nodes.
StopCondition in the COMSOL Multiphysics Programming Reference Manual.
Stop Expressions
Use the table to specify expressions for the conditions that define when the solver should stop. The solver evaluates the active expressions after each time step or parameter step. The setting in the Stop if column of each expression determines how it is evaluated. For True (>=1) (the default), the stepping stops if the real part is greater or equal to one, which is useful when entering logic expressions that evaluate to a Boolean true or false (comp1.EndTerminal(comp1.phis)<2.4, for example). For Negative (<0), the stepping stops if the real part of the expression becomes negative (comp1.intop1(comp1.T)-360, for example). Another example of a stop condition is timestep<0.04, which makes the solver stop when the internal time step drops below 0.04 s (when the time-dependent solver hits a sharp transient, for example). To use such logical expressions, use the True (>=1) setting. Use the Active column to control which stop conditions that are active by selecting or clearing the corresponding check box. The solver stops when any of the active conditions is fulfilled. Optionally, you can enter a suitable Description for the stop condition. The description is included in the message that appears in a Warning node when the stop condition is fulfilled.
Stop Events
This section is available when the Stop Condition node is an attribute of the Time-Dependent Solver operation node. This is because events are only supported for time-dependent solvers. Events are then useful for stopping a simulation at the point where the event occurs, which is usually more exact than using a stop condition.
Use the Implicit event table to specify at which events the solver should stop. All implicit events defined in the model automatically appear in the table. The stepping stops when any event marked as active is triggered.
Output at Stop
Select an option from the Add solution list to make the solver additionally store the corresponding solutions before and after the stop condition was fulfilled. Select:
No (the default) to not store any additional solutions. The last solution stored is the one normally stored by the solver before the stop condition was fulfilled.
Step before stop to store the last step taken by the solver before the stop condition was fulfilled. No solutions are stored after this point even if they normally would be.
Step after stop to store the solver step at which the stop condition was fulfilled. Any solutions up to this point are also stored as they normally would be.
Steps before and after stop to store all solutions that would be stored by Step before stop and Step after stop.
Which solutions are normally stored by the solver depends on the Times to store setting for the Time-Dependent Solver node and on the Parameters to store setting for the Parametric node.
An example of using Step before stop would be to make sure to capture the last state of a simulation before a certain condition has been fulfilled, without having to store all of the solver steps up until this point. The setting Step after stop would similarly be used to capture the first state fulfilling a certain condition. When both the state before and after the condition are of interest, use the setting Step before and after stop to capture the transition. If the stop condition was fulfilled by the reinitialization effect of an implicit event, Step before stop stores the solution before reinitialization and Step after stop stores the solution after reinitialization.
Select the Add warning check box to specify that the solver adds a warning when the solver has stopped due to a stop condition.