Friday, July 10, 2009

Automatic Step Size Control

The trapezoidal rule we used to derive the companion models involves some degree of approximation. The error due to this approximation depends on, among other uncontrollable things, the step size (Δt). Reducing the step size will generally enhance the accuracy, but will cause the simulation to take longer because a larger number of solutions will be needed to get to the user specified final time. We want the largest step size that still gives an acceptable accuracy. The problem now becomes: how to estimate the error for a certain step size?

Before answering this question, we need to distinguish between local error and global error (or cumulative error).
The local error includes only the error incurred in the present time step, unlike global error which includes the error due to the starting point of the present time step being inexact. The global error contains the cumulative effect of local errors in all previous steps.
The global error is of high interest but unfortunately only the local error can be estimated.

I will now present the local error estimation method. I will start by rewriting the differential form of the trapezoidal rule using a slightly different notation.

TrapezoidalRule 
'n' is the step index and Δtn is the difference between the time of step n+1 and the time of step n.
The local error incurred due to the approximation of the trapezoidal rule while moving from solution n to solution n+1 is approximately given by

Error
where 
Range

The third derivative of x can be approximated by the third divided difference of x on the nodes tn+1, tn, tn-1, tn-2. And here is how to get the divided difference.

DividedDifference

This means that you need the solution at the time points tn-2, tn-1, tn, tn+1 to estimate the local error incurred while moving from tn to tn+1. If the error is not acceptable, you will have to discard the solution at tn+1 and try again with a smaller step size.

The variable x used in the previous equations represents the voltage across capacitors, the current through inductors and, for transformers, x represents the expressions shown below.

TransformerEquations 
The local error should be calculated independently for each energy storage element in the circuit after each solution and if the error at one energy storage element is not acceptable, the solution is discarded and the step size is reduced.

It remains to say that the local error due to the approximation of the trapezoidal rule is called the Local Truncation Error and abbreviated LTE.

1 comment:

JCoulston said...

So have you done any more on this project? I have been working on some stuff myself. I was able to get transient analysis to work with capacitors but not inductors. This has to do with the basic nature of inductors. The companion models are easy to derive and come up with but I can't get them to work. If you have feel free to email me back. I desire some more corroboration on this type of project.