Error Messages
This section provides detailed information about common error messages in PLECS and their solutions.
Could not solve the algebraic loop
This error occurs when the algebraic loop solver cannot find a solution that is consistent with all the blocks involved in an algebraic loop. An algebraic loop is a group of one or more blocks that are connected in a circular manner, so that the output of one block is connected to a direct feedthrough input of the next block.
Solution 1: Avoid algebraic loop
If possible, the best solution is to avoid the algebraic loop altogether by reformulating the model.
Using the following equation as an example \(y = xy/5 - x\), the algebraic loop is avoided if the equation is rewritten as \(y = x/(x/5-1)\).
Example Model
See the example model “Could not solve the algebraic loop - Example 2”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
When to use algebraic loops as a modeling tool
Algebraic loops are a helpful tool for modeling fast interactions between physical quantities with small time constants. A model using such a loop will make the describing differential equations numerically less stiff and so easier to solve.
Take a variable resistor as an example: Since every real resistor will show some, albeit small, inductive behavior, the model of the resistor could be built using a Variable Resistor with Constant Inductor component. In this model, the current through the resistor is not directly affected by a change in the resistance value and thus, there is no algebraic loop. As the additional small inductor will create transients with a very small time constant, this can lead to issues with numerical integration. In this case, a pure Variable Resistor component will add an algebraic loop to the model and solve these issues.
Solution 2: Break the algebraic loop
If the model cannot be reformulated then the loop can be broken by introducing a low-pass filter. The bandwidth of the low-pass filter needs do be within certain boundaries for this to work: It needs to be high enough so its dynamics do not interfere with the system response and low enough to avoid numerical stiffness of the system. Please note that algebraic loops should not be broken with a Memory block in simulations with a variable time-step solver.
Example Model
See the example model “Could not solve the algebraic loop - Example 2”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Solution 3: Restrict the operation range
Some algebraic loops can only be solved in a certain operation range of the circuit.
Why the error occurs: An example is a constant power load. If the load voltage or current is zero, the load power cannot be held constant with finite currents or voltages. In this case, a lower limit for the load condition has to be specified.
Example Model
See the example model “Could not solve the algebraic loop - Example 1”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Solution 4: Provide an initial value for the solver
The solver sometimes needs the right initial value at simulation start to find the solution of an algebraic loop. This can be done with an initial condition block.
Example Model
See the example model “Could not solve the algebraic loop - Example 3”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Encountered 1001 consecutive zero-crossings
The error message indicates that a particular signal is toggling back and forth during consecutive solver steps. The message highlights the component that causes the zero-crossing issue.
Solution 1: Limiting the switching frequency
This solution relies on limiting the switching frequency of the Compare to Constant block. There are two possibilities to do that:
Set the switching frequency explicitly by inserting a zero order hold with appropriate sample time in front of the Compare to Constant block.
Fig. 47 Solution 1a: Zero-Order Hold
Add a hysteresis band by replacing the Compare to Constant block with a Relay block with suitable upper and lower thresholds (e.g. \(1 \times 10^{-6}\) and \(-1 \times 10^{-6}\)).
Fig. 48 Solution 1b: Hysteresis Band
Why the error message occurs: Whenever the input signal of the Compare to Constant block crosses zero, the change of the output signal immediately causes the input signal to change its direction. This leads to a zero-crossing again in the next simulation step. This repeats until the solver reaches the maximum of configured consecutive zero crossings (1000 by default).
Fig. 49 Model causing consecutive zero-crossings
This behavior will bring the simulation to a virtual standstill. To solve the problem, the switching frequency of the Compare to Constant block must be limited.
Solution 2: Adjusting the electrical machine parameter
The problem can be solved by changing the machine configuration parameter to Voltage behind reactance which is based on a variable inductor and phase current measurements. These always provide a continuous machine model input during a simulation.
Why the error message occurs: Taking, for example, a model featuring an electrical machine in “Rotor reference frame” configuration which is implemented with voltage controlled current sources.
Example Model
See the example model “Encountered 1001 consecutive zero-crossings - Example 2”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Here, the problem occurs when the zero-crossing of a phase current happens during an interval where both high-side and low-side switch have zero-input gate signals. A first diode is conducting, when the current is negative and a second one, when the current is positive. Thus, the small change around zero in current causes a voltage jump from zero to the DC voltage, which in turn results in the sign of the current injection to flip. The process then repeats. The behavior will bring the simulation to a virtual standstill and PLECS issues the error message.
State discontinuity after switching
The error occurs, when there is an instantaneous change in a model state after a switching event. Examples include interrupting an inductive current or changing a capacitive voltage instantaneously. The error message will explicitly state which type of phenomena causes the error and at what time during the simulation.
Solution 1: Provide an alternative current path or interrupt inductive currents
For DC systems: Please ensure that an alternative current path is provided by free-wheeling diodes or snubber components. Be cautious when using snubber components: Excessively large or small values scan lead to large voltage and current transients, high losses, or numerically stiff systems.
For AC systems: Replace the Switch component with a Breaker. The Breaker component opens when both the input signal and the breaker current are zero. Therefore, this circuit breaker can be used to interrupt inductive AC currents.
Why the error occurs: The error indicates a likely systematic problem of the circuit topology and/or the modulation scheme used. In a real system, chopping inductive currents will result in voltage spikes across the inductors, which likely will damage the circuit. So, when instantaneous change in inductive current happens and the current cannot find a new path in the circuit (e.g. through a free-wheeling diode or resistance), PLECS will report this error.
Occasionally the error is due to insufficient solver accuracy which is set with the Relative tolerance parameter in the solver panel.
For example, consider the following AC circuit with an RL load:
Fig. 50 Inductive system with state discontinuity
Example Model
See the example model “State discontinuity after switching - Example 2”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
With “S1” initially closed, current will flow in the circuit.”S1” is an ideal device. When opened, it will instantaneously chop any currents flowing through the switch. The voltage across the inductor can be described with \(v=L\frac{di}{dt}\). If the current changes instantaneously, then there will be an infinite voltage spike across the component. PLECS raises an error under this condition.
In this simple inductive circuit example, the issue is topological since there is no path for the current to flow. This is also possible with more advanced converter circuits.
Solution 2: Ensure a correct Modulator implementation
You debug your modulator implementation. For debugging a model, it may be useful to add series or parallel snubber elements to temporarily silence the error, allowing you to study the modulation sequence in more depth. Remove the snubber elements once the issue is resolved.
Why the error occurs: Fundamental errors in modulator implementation can lead to unexpected interruption of inductive currents or shorts across capacitors.
For example, the error may be shown due to a simple error where the gate drive signals are incorrectly assigned.
Example Model
See the example model “State discontinuity after switching - Example 5”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Adding a resistance in series with the DC link capacitances allows you to debug the model and observe that the conductivity of the device does not follow the gate input.
Solution 3: Topological considerations
Make sure that no switching element short-circuits an energy-storing element.
Why the error occurs: In certain cases, the circuit’s operation will depend on rapidly charging and discharging energy stored in a component, which could lead to this error message.
One example is the “Resonant Full-Bridge SLR Converter”. It analyses zero-voltage turn-off of the SLR circuit by modeling an external capacitance in parallel with the switching devices.
Example Model
See the example model “State discontinuity after switching - Example 1”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Note
The switching devices must have a non-zero resistance, otherwise there is an error when the switch closes across the parallel capacitor. In this case, the switch resistance represents the actual resistance of the IGBT device.
Solution 4: Adjust solver accuracy
One common solution is to decrease the Relative tolerance in the Simulation parameters + Solver tab by one or two orders of magnitude. If the state values before-and-after switching are close to zero, then changing the Absolute tolerance value from the default of Auto to a small value may resolve the error message as well.
Why the error occurs: Normal changes in model states may be incorrectly detected as a state-discontinuity when there is insufficient solver accuracy. One indicator that this condition is occurring is the relatively small difference between the state value before and after switching, with neither state being exactly equal to zero.
Using the referenced example of a three-phase voltage-source converter, the default case reports a State Discontinuity in the inductor current. However, the current path is continuous due to the anti-parallel diodes in the IGBT converter. Setting the Relative tolerance to 1e-4 or the Absolute tolerance to 1e-3 resolves the error.
Example Model
See the example model “State discontinuity after switching - Example 4”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Solution 5: Adjust Diode turn-on threshold
Lastly, adjusting the Diode turn-on threshold parameter can be beneficial in some instances.
Derivatives are infinite or NaN
This error occurs due to numerically ill conditioned systems. It can also occur, when an input into the state derivative calculation or the calculated derivative term state derivative \(\dot{\mathbf{x}}\) is either \(\pm\infty\) (inf, -inf) or “not a number” (NaN).
As described in Physical Model Equations, PLECS models physical systems using a piece-wise linear state-space representation. The state derivative \(\dot{\mathbf{x}}\) is calculated as:
The state derivative can be infinite or “not a number” in all physical domains and the control domain.
Solution 1: Make the system physically and numerically stable
Check that the controller and the plant are stable.
Why the error occurs: In unstable physical or control systems or state-space systems with a near-singular state matrix, state values can arise that approach infinity.
Consider the following instable system:
Fig. 51 Instable system example
Example Model
See the example model “Derivative is infinite or NaN - Example 3”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
In state space the format of the system is \(\dot{x}=1000x\) with an initial condition of \(x(0)=1\). As the simulation proceeds the derivative and state value of \(x\) increase exponentially until the state derivative reaches the maximum representable double precision floating point value. At this point, the simulation terminates.
Solution 2: Debug thermal runaway
The solution is to find and correct the underlying flaw in the system causing thermal runaway.
First check the error message to see which model states approach infinity. Then, you can base the debugging process on these states.
Why the error occurs: Typically, the error is due to an underlying flaw in how the system is modeled that results in unstable feedback. The underlying flaw may concern: Excessive current through the device, poor device selection for the given load, excessively high thermal impedances, an unrealistic electrical simulation with large component stresses, and incorrect units in the thermal description file.
Thermal models exhibiting thermal runaway may result in this error message. This is the case, for example, in this modified version of the “Buck Converter with Thermal Model” demo model that has the load resistance reduced by a factor of 10.
Example Model
See the example model “Thermal state derivatives are infinite or NaN”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
The resulting current through the device is no longer appropriate for the device’s rating. As the temperature increases, the thermal model’s extrapolation algorithm predicts higher losses, resulting in even higher temperatures. The device’s temperature exceeds the point where the device would be physically damaged and proceeds towards infinity, eventually resulting in the simulation terminating. The simulation error message points towards the thermal capacitance of the diode being the first state to reach infinity. So, in this example model, the root-cause is the excessive current through the device and poor device selection for the given load.
Solution 3: Ensure that division by zero is impossible
Restrict the inputs to any divisor such that it cannot be equal to zero.
Why the error occurs: A simulation block’s output may be inf, -inf, or NaN under certain conditions. One common source is division by zero or near-zero, which will return inf, -inf, or NaN depending on the dividend. If the division result influences a system state then PLECS will report this error message.
Solution 4: Adjust the Division by zero option
Set the Division by zero diagnostic option in the Simulation parameters + Diagnostics tab to Error.
When this option is set to Warning, it is recommended to carefully review the simulation diagnostics window. Division operations are possible when using the Divide block or Function block.
Why the error occurs: In some cases dividing by a near-zero value will result in the error message but not a divide by zero warning. See the example below where eps(0) is a very small non-zero value. The result of this division is inf which in turn influences the capacitor voltage state.
Fig. 52 Division by a near-zero value
Example Model
See the example model “Derivative is infinite or NaN - Example 1”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Solution 5: Ensure that the C-Script return usable values
Debug the C-Script such that no calculation returns a inf, -inf, or NaN result.
Example Model
See the example model “Derivative is infinite or NaN - Example 2”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Why the error occurs: The error message will occur when a inf -inf and NaN value is assigned to an Output signal that is in-turn used elsewhere in the simulation, such that results eventually influence a model state. Assigning an inf or NaN value to a continuous or discrete state derivative within the C-Script will also result in this error.
C-Scripts can return inf, -inf, or NaN values. Common examples include division by zero, inverse trigonometric functions, square roots of negative numbers, and numerical overflow. The C-Script compiler will issue no warning when an operation will return inf or NaN values, as these are valid return values.
Negative losses
This error message occurs when PLECS calculates negative losses of a device based on the thermal description and state of the circuit at the switching instant. Even if the data in the thermal description is consistent and only shows positive values, an extrapolation of the given data may lead to a negative loss value. This is typically the problem when the temperature of the device is very large or very small and the extrapolation of loss data based on the temperature value becomes negative.
Example Model
See the example model “Negative loss values for component”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Solution 1: Set zero loss values at the origin
Ensure that the thermal descriptions should have zero loss values at the origin, i. e. where the voltage or the current is zero.
Why the error occurs: If there are positive loss values at the origin, the extrapolation for negative voltage or current will lead to negative losses.
Solution 2: Use assertions for very large and very small temperatures
Use assertions inside the thermal descriptions to avoid negative losses when extrapolating for very large and very small temperatures.
Why the error occurs: The simulation will continue when the device is operating out of the safe operating area where normal loss data is meaningless.
Solution 3: Ignore error message or convert error message into a warning
If the thermal loss data is specified correctly or if the thermal characteristics is not of interest in a particular simulation scenario, the error message can be ignored or converted into a warning. This option is available under the PLECS Parameters… (PLECS Blockset) or Simulation Parameters… (PLECS Standalone) menu.
State-source dependency of components
This error occurs due to inconsistent definitions of states.
PLECS models physical systems using state-space equations of the form
where \(\mathbf{x}\) is a vector of state variables (i.e. inductor currents and capacitor voltages for electrical systems) and u is a vector of input variables (i.e. voltage and current sources for electrical systems).
A state/source dependency is created when there is a direct relation between a state and source quantity. For example, a capacitor that is connected directly in parallel with a voltage source is described by the equation:
At the same time the capacitor voltage should be integrated from the equation:
This creates an inconsistent definition of \(v_{\mathrm{c}}\) and leads to an error. The following figure shows the possible state/source dependencies for each physical domain:
Fig. 53 State/source dependencies in physical simulation domains in PLECS
Example Model
See the example model “State/source dependence in components - Example 2”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Once the state/source dependency has been created, for instance in the electrical domain, the solution to this problem can be:
Solution 1: Eliminate the state component
Eliminating the state component will eliminate the inconsistency.
For example, you can eliminate a capacitance in parallel if a voltage source has been introduced in the circuit to fix or control the voltage. The same can be applied in current/inductance cases.
Similar strategies can be applied for all other physical domains.
Solution 2: Break the dependency
Decouple the source and the state component when you cannot eliminate the state component.
For instance, a small resistance can be introduced in series with the voltage source. This allows to eliminate the state/source dependency and at the same time model a voltage source with a limited maximum power delivery. A similar approach can be followed by introducing a relatively large parallel resistance with the current source in order to break the inductance/current source dependency.
Similar strategies can be applied for all other physical domains.
Example Model
See the example model “State/source dependence in components - Example 3”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
Note
The resistance must be chosen carefully so that it does not influence the system dynamics too much or create numerical problems like stiffness.
Solution 3: Setting Inertia and Thermal capacitance to 0
Simply set the “Inertia” and “Thermal capacitance” parameters to 0.
Why the error occurs: There are few, but very common, component arrangements where state/source dependencies can be created. For example, such a dependency is created when the shaft’s speed of an electrical machine needs to be fixed by an external speed source, or the temperature of a heat sink needs to be fixed by using a temperature source.
Example Model
See the example model “State/source dependence in components - Example 1”.
Find it in PLECS under Help > PLECS Documentation > List of Example Models.
The problem here is that the machine models have an internal inertia connected to the shaft’s mechanical ports, and the heat sink component contains an internal thermal capacitance. Therefore, state/source dependencies are created (like the ones shown above).
Out of memory
This error occurs when there is not enough memory to run the entire PLECS simulation. Unfortunately, there is no way to get the simulation data out of any scopes prior to the simulation stopping.
Solution 1: Reduce number of scopes
The best way to avoid this error is to reduce the number of scopes. PLECS can allow for large models and long simulation times, but multiple scopes used in a model is the main memory sink.
Solution 2: Use the 64-bit version
You can use a 64-bit version of Matlab and PLECS. The 32-bit version of PLECS is limited to 3 GB of virtual memory by the operating system, while a 64-bit machine can allocate several terabytes of virtual address space.
Solution 3: Decrease the cache size limit
You can decrease the cache size limit in the PLECS preferences.
Solution 4: Use the correct solver settings
You can use a stiff solver when solving stiff systems. Also, set the Max step size parameter as large as possible.
Why the error occurs: The wrong solver settings force the use of unnecessarily small steps and thus increases the memory needed.
Solution 5: Limit the maximum number of samples stored per scope
You can limit the maximum number of samples stored per scope in the scope’s preferences to the last N samples. Remember, though, that you cannot decimate the samples in the scope that are stored (i.e. store only 1 of N samples).
Solution 6: Set a large and fixed sample time in the scopes
You can set a large, fixed sample time in the Scope Parameter menu.
Solution 7: Exchange scope
You can use a To-File block instead of a scope.