How Bobolink Works

This page contains a very brief summary of the math involved in Bobolink. I am making no effort at a comprehensive description here - this page probably will be incomprehensible to anyone who isn't already familiar with the techniques involved.

Block Diagrams

Bobolink runs simulations of block diagrams and physical systems that can be represented as collections of linked blocks. Block diagrams are a tool used in control theory to model physical systems. The blocks are mostly self-explanatory, and complete explanations can be found in the user documentation. The only block of mathematical interest is the transfer function.

Transfer Functions

Transfer functions represent physical processes. They are written as Laplace transforms of operators that relate the block input to the block output. Right now, the only allowed operators are those whose Laplace transforms are "rational polynomials", meaning ratios of two polynomial functions. This means that a transfer function relates a linear combination of time derivatives of the input to a linear combination of time derivatives of the output.

Equations and Variables

Each block contributes zero or more equations, and each link between blocks contributes one or more variables. It is easier to deal with systems of first-order differential equations than higher-order ones, so Bobolink includes additional equations of the form "y = dx/dt" which eliminate all the derivatives of order higher than first.

The Modelable interface, which all block classes must implement, requires functions that fill in a matrix with the coefficients of the variables. Also, it requires a function that evaluates the Crank-Nicholson or fully implicit right-hand side. These, plus some simple accounting functions, are all that is needed to have a model.

Links carry one or several variables. In pure block diagrams, there is no need to specify exactly what the variable is, it's just "the signal". For models of physical systems, the links carry several variables, which are divided into potentials and fluxes. A potential variable (like voltage) has the same value everywhere in a given link. A flux variable (like current) is conserved throughout a given link, and has distinct values at each connection between that link and a block. The sign convention is that positive values of flux variables indicate flow in the direction of the arrow at that connection point.

Crank-Nicholson and fully implicit methods

Bobolink uses a combination of Crank-Nicholson and fully implicity discretizations of its equations, which I learned about in Numerical Recipes in C. The Crank-Nicholson technique discretizes time-derivatives as dy/dt = ( y_new - y_old ) / dt and evaluates other properties as the step-center average y = ( y_new + y_old ) / 2. The fully implicit formulation instead evaluates all non-derivative functions at the forward time, y = y_new. Then, everything except the y_new terms are moved over to the right-hand side of the equations. The resulting system of equations is solved with LU decomposition. The Crank-Nicholson method has good stability properties and second-order accuracy in time. Fully implicit solutions are only first order in time, and don't formally have any better stability properties than Crank-Nicholson, but can more robustly deal with some types on nonlinearities that come up in electric circuits.

Nonlinear Blocks

Bobolink handles nonlinear links by performing an iteration around the evaluate-matrix-solve-matrix code until self-consistency. This is reliable for well-behaved nonlinear blocks. Blocks with non-smooth nonlinear functions (like Zener diodes) are handled by adjusting the error tolerance.

Home | Bobolink Home