### GeneratedMathematicalModel

After the model has been built we may explore the mathematical model the program generates. However, because the model is generated in a byte form, we must translate it first into the common mathematical form that can be more easily reviewed. We can do it by clicking Equations toolbar button (in form of a pencil), or by choosing command Show Model >Write Equations in Simulation menu. The text box below lists the mathematical model for the problem we deal with. For this relatively simple problem, there are 13 equations expressed in implicit form in which all the terms are moved to the left side of the equations. The Y(i), i = 1,…, 13, are the machine generated system variables. The equations generated by BondSim are typically very simple consisting of on average two to three terms per equation. There can be thousands of such equations.

Box 1. Model equations

To see the meaning of the system variables we may put the mouse cursor over the ports of the elementary components and tooltip windows appear showing the port variables. Thus, e.g. if we open Spring and put cursor over the capacitor port, a tooltip window appears as shown in the figure below. The window shows that Y(2) is the capacitor effort (the spring force), Y(7) is the flow (the spring extending velocity), and Y(8) is the state variable (the spring extension).

The tooltip showing the port variables The model equations consist of a mixture of differential and algebraic equations. They are solved jointly during the simulation as a system of Differential Algebraic Equations (DAEs). In addition to the mathematical model equations, the box lists the differentiated variables, and the indexes of the purely algebraic equations. The next are the initial values of the variables and finally the parameters used by the model.

In addition to equations, the model contains the Jacobian matrices defined also in the symbolic (analytic) form (not shown). Using the matrices in the analytical form (and not as the numerical ones) adds much to robustness of the BondSim solver. The matrices are very sparse, containing on average less then tree elements per row. They are solved using default Sparse 1.4 solver. (It is a similar package as used in well-known the SPICE package in electronics.) There is also another, a more recent solver that can be selected at the start of the simulation (KLU). But in general, the Sparse solver works well.