# Algorithm Development

An algorithm is a logical procedure for solving a model's mathematical equations. It takes input data and transforms it into output predicted by the model. We use logic and data flow diagrams to illustrate and define the logical sequence of events. Algorithms serve as a bridge between the model and the code, where the program code follows the sequence of activities required by the algorithm. Over the last 20 years we have established well tested, efficient and tried algorithms for commonly needed tasks. Where possible these algorithms have been encapsulated. An example of a common task when solving mathematical models is the need for a solution to an explicit equation. Explicit equations cannot be solved directly but require an iterative solution. Specifically, we might consider the calculation of friction factor via the Colebrook-White equation. By using an encapsulated, validated, generic algorithm such as Newton-Raphson, Successive Approximation or Secant we eliminate the need to write specific code for the solution of the Colebrook-White equation. Algorithm analysis is carried out to ensure that the criteria of accuracy, timing, stability and size requirements are met. Consistency checks are made where appropriate. For example, consider the adiabatic flow of a compressible fluid in a pipe. To be consistent we should be able to take any of the Fanno flow property relationships and ensure that these conditions are consistent from low flows right up to the speed of sound.