Solution Algorithms

Simgua contains three differential equation solvers built into it. The three methods have different levels of accuracy. Unfortunately, the accuracy of the algorithms is directly proportional to their complexity and time required to carry out computations. The three algorithms are described below:

·         1st Order — Euler: The simplest of the algorithms, the Euler algorithm works by computing the differentials (the flow rates) at a place in time and then multiplying these by the time step and applying them to obtain the values for the stocks at the next time period.

·         2nd Order – Heun: More complex than the Euler algorithm, this algorithm works by first using the Euler algorithm to move the simulation forward to the next time period. The derivatives are then calculated for that new period. Instead of moving forward however, the simulation is then reversed and moved back to the first time period. The average of the derivatives from the two time periods is used to predict a more accurate combined derivative. The Heun method is a 2nd order Runge Kutta algorithm.

·         4th Order: The fourth order Runge Kutta Algorithm implemented in Simgua evaluates your system at three places for each time step: once at the start, once one time step into the future, and twice in the middle. It is the most accurate of the methods implemented in Simgua.

We therefore encounter a difficult question. It should be clear that we can achieve more accurate results by either using a more complex algorithm or a smaller time step. You are probably asking whether it is better to use a smaller time step or a more accurate algorithm when both accuracy and speed are a concern. It appears that the best results are achieved by using a more accurate algorithm rather than a smaller time step. In certain models, however, this rule of thumb might not hold and you should develop your settings to best suit your specific simulation. The following chart illustrates the rough relationship between accuracy and computation time using the 1st order and 2nd order methods.

Accuracy versus effort for the algorithms (Lower Values are Better)

One other consideration is that when you are using a complex set of components or Visual Basic algorithms you might want to use the Euler algorithm even given its inferior accuracy. This is because it can sometimes be difficult to make sure that VB methods function correctly with higher order Runge Kutta solution algorithms. If the writer of the components was not paying close attention to this issue, they could have potentially made small temporal logic errors. Additionally using input and output functions with higher order solution algorithms is difficult. These issues will not affect the Euler algorithm.