DA Digital Analytics


DMSolver --Overview

DMSolver 6.04 (Dynamic Modular Solver) provides a programming language and algorithm for solving large (or small!) sparse systems of nonlinear simultaneous equations. As such, it provides a "solver engine" for the simulation of complex (or simple!) systems, generally of the continuous type. Some example problems are included with the package: One of the really, really tiny ones is Edward Lorenz's 3 variables + 3 derivatives original "Attractor" nonlinear "chaos" problem from 1963. See this for a very simple example of a DMSolver user program.

DMSolver operates in the Windows 32-bit environment and guides the user in preparing input. It allows for large or complex mathematical models. The package analyses the source code input and figures out how many simultaneous variables and equations are present. For simple problems a new-since-V5.3 coding language may let the user avoid programming in DMSolver's native language, Pascal, whereas for more complex problems the user has to fill in the programming framework provided.

You can now try a downloaded DMSolver package free for 30 days.

I am retired from my previous teaching job and am available for assisting users of DMSolver on a consulting basis if they need help to develop complex simulations.

"Modular" refers to the ability of the user to predefine a "module", a block of equations and variables (and perhaps other nested modules). Each call of a module procedure creates an instance of the module linked into the model with a single line of code. For some applications a user may link a vector of modules into the problem with a single statement. There must always be a module procedure at the end of the source code named "SYSTEM" which defines the entire problem and is called by the Solver software code.

Steady state ("static") problems are modelled by sets of simultaneous algebraic equations, although an "equation" can either be a single formula or optionally be a whole procedure (i.e. subroutine in Fortran or BASIC nomenclature) with few limits to its complexity. Dynamic problem code is that which contains calls to the DMSolver integrator procedure, and so dynamic models contain one or more ODE's as well as possibly algebraic equations.

"Add-ins" are available to extend the use of DMSolver for least-squares estimation of model parameters and constrained optimization of some objective function which the user defines. Within some limitations the user can program his/her own "add-in".

For v6.0 a new user interface for creating parameter estimation problems has been added.

At various times trial investigations have been made for:

** "Plug flow" (or equivalently, batch) chemical reactors --- multiple components, multiple reactions, dynamics over reaction time, estimation of parameters (see my report on kinetic parameter estimation discussed again below).

** Systems of stirred-tank chemical reactors --- multiple components and reactions --- including heat transfer and product separation, steady state or dynamic with attached feedback control, estimation of parameters.

** Biologist's models for intracellular reaction and mass transport, leading to an oscillatory result resembling circadian rhythm. (see ...Circadian Rythm Models...)

** Distillation modelled as a series of many equilibrium (or non-equilibrium) stages -- Steady state.

** Compression, expansion, and separation of light hydrocarbons.

** The steady-state process plant model for dealkylation of toluene to produce benzene, as described in a number of chemical engineering books and papers.

** Models of economic behavior where production and consumption of various commodities and growth of production capacities are assumed to depend on current and past commodity prices and states of the economy.

** The BOAT3D equations for planing boat motion --- 3-degrees-of-freedom rigid-body 2-dimensional motion with added mass analysis over 40 boat segments in series (see my technical paper on BOAT3D)

** 6-degrees-of-freedom motion of a rigid body in 3-dimensional space with driving forces expressed in body coordinates

** A model of a vibrating guitar string represented by a chain of elastic segments.

** Interacting electronic components connected in circuits.

Only a few of these types of problems have actually been refined and received practical use, but we hope this gives the reader some idea of what DMSolver can do.

By "large" we mean that DMSolver can routinely handle problems with several thousand variables, and arrays within it are dimensioned to hold up to 10,000 variables.

To test modifications of the least-squares estimation add-ins, the four test cases in chemical kinetics analysis from the EUROKIN Consortium were used. These show the utility of DMSolver in chemical kinetics and reactor design modelling. Case 1 includes batch reactors and CSTR with the same reactions. Case 2 has a plug flow fixed bed reactor and uses a mass-transfer-limited, heterogeneous catalytic liquid-phase reaction model. In Case 3, 20 rate equations are being screened to see which one is most appropriate. Case 4 concerns a tubular reactor with axial heat and mass dispersion. In Case 1 the DMSolver simultaneous problem has 8 (batch) or 6 (CSTR) simultaneous variables, in Case 2 there are 10, in Case 3 there is only 1 and in Case 4 there are 794.

If you download my technical report on this work as well as the EUROKIN paper, you can see the test cases as they were posed as well as the DMSolver source code and portions of the DMSolver output.

DMSolver Steady-State Flowsheet Toolkit (FT) was a set of tools working with DMSolver (previously PMSolver) to simulate steady-state chemical engineering systems. Modules for flash, distillation, heat exchange, and other operations were provided, along with physical property routines. FT automatically generated source code for a system containing these standard modules after the user had used appropriate specification menus. The user could write special-purpose modules, such as reactor modules, for the system. Part of the physical properties package for FT lives on in Flash Calculator. Due to lack of interest FT is not currently supported, but there is a possibility of reviving it.

DMSolver, V.6 ---Technical

Form of Equations:

The normal form of Solver equations is

Xi = fi(Xj1, Xj2, ....)

i.e. Variable Xi is a function of a set of other simultaneous variables (and not itself). The function fi is implemented in a procedure (Pascal nomenclature) -- subroutine (Fortran or BASIC nomenclature) which computes Xi from Xj1, Xj2, etc. Any set of computational steps can be used as long as the result Xi is continuous and continuous in first derivatives with respect to the Xj1, Xj2, etc., so we are actually not talking about an "equation" in the narrow sense of something that can be written down in one line. (Actually brief instances of non-continuity occur e.g. in certain BOAT3D cases and the DMSolver algorithm has some tolerance for this.)

In some cases it is awkward to put all equations in the above form, so a usable alternate form which involves some extra overhead is

Ci = fi(Xj1, Xj2, ....)

where Ci is a user-specified constant.

For static problems all the functions fi are defined in the problem source code, but dynamic problems can make use of several built into the system, including an integrator with respect to time. Solutions of a set of ordinary differential equations can be integrated with respect to time from an initial state by using calls to these built-in procedures and other time-related features of DMSolver.

Solver Source Code

Pascal has a different (and better) way of linking files to make large programs. The DMSolver user normally does not have to deal with this since the user runs a program called DMSolver Guide which as you click on a sequence of buttons, prepares your source code, inserts it in the correct place, links and compiles to get the .EXE, and runs it.

DMSolver provides a convenient text editor window for the source code. If the user starts out to define a completely new problem, a "skeleton" source code file is supplied to which the user needs to add details. Our original software for static problems only was called PMSolver --- Pascal-based Modular Solver. When PMSolver and DMSolver were designed Pascal was the best computer language to use. This is still true even though there are more options now. We feel that anyone who has worked with BASIC, Fortran, or C can easily learn the subset of Pascal features used in basic DMSolver language, which is plain Pascal except for certain special keywords indicating simultaneous system structure. There is a mix of features in Pascal which variously have parallels in BASIC, Fortran, and C.

Using the Solver:

When the user clicks on the appropriate buttons the source code for the problem is preprocessed, compiled, linked, and executed. This creates the Solver program .EXE file and what we call a "problem" (.PRB) file. A PRB file contains a list of variable names with the current value of each variable and other information. There is a standard-style "Display/edit" window with numerous menu commands to select categories of variables or constant problem parameters and view and change their values. If variables are expected to have widely differing magnitudes, the user should enter scale factors for the variables and these are saved in the PRB file. There is a "SaveAs" menu command to save multiple copies of PRB files containing various changes you might make or various solutions at stopping points in the solution process.

The Solver uses a Newton-type algorithm, so most nonlinear static problems require some type of initial estimate of variable values. For dynamic problems initial conditions are specified at this time, and the user can do a save of a PRB file containing the initial conditions chosen.

When the Newton's algorithm is activated it attempts to reduce the equation errors right-hand side vs left-hand side (which also appear in the Display/edit window) to zero.

For dynamic problems the initial solution obtained by the first application of Newton's algorithm becomes the initial condition point for integration with respect to time. As integration proceeds, DMSolver writes solution variables as functions of time to a file (with extension TTR). These can be examined and plotted on the screen as functions of time using a utility program, TTRView. (With Windows multitasking, you can be examining a section of solution while DMSolver is continuing to add to the file.) When a dynamic solution is complete, selected portions of it can be converted to EDTECH database (DSF) format for presentation-grade plotting with EDTECH.

Topics seldom mentioned in discussions of simulation are that it is very easy to accidently devise a problem which has no solution, and that, even if the problem formulation is correct, on the way to a solution the current estimate of the solution point X may wander into forbidden territory, e.g. where the calculations include taking the logarithm of a negative number, dividing by a value too close to zero, etc.

In the ~20+ year development history of the Solvers strategies have been developed for coping with these problems. Basically, the approach is to avoid total collapse of the program by special ways of avoiding taking the log of a negative, etc., and also letting the user have the ability to fully examine the unconverged problem values in an attempt to diagnose difficulties.

DMSolver has an automatic adaptive method for coping with "stiff" dynamic problems.

Additional Solver Information:

Maximum Problem Size:

Up to 10,000 simultaneous variables with up to 150,000 non-zero elements in the problem's Jacobian matrix.

Additional Software Requirements:

In contrast to previous versions, you do not have to purchase any additional software since a Free Pascal compiler can be downloaded along with the Lazarus-ide which provides interfacing with Windows (see lazarus-ide.org). Lazarus-ide is the integrated development environment for Free Pascal which includes a debugger, and it has the required interfacing files for Windows. Unless you want to use the debugger, you do not have to start and directly use the Lazarus-ide, which has a large menu system (there is a learning curve for this).

System & RAM, etc.

A 32- or 64-bit Microsoft Windows system is required (2000/XP/Win7, 8, or 10) to run the 32-bit code. In ancient history we had to worry about having at least 16Mb RAM, but now everyone has many times this much. Hard disk excess capacity should be large to store DMSolver dynamic solutions (several hundred Mb free is a minimum) but again, now everyone has a large amount. A cpu with at least 2 "cores" is required since V 6.04 sometimes runs 2 "threads" simultaneously, but again, everyone has this now.

Add-in Features (extras not in the basic package):

These have been adapted to Versions 6.0. Also, users can create their own add-ins through the add-in "User Batch Procedure" which lets you proceed through a complex sequence of steps automatically.

*** Static nonlinear least-squares add-in allows the estimation of system parameters by fitting static Solver solution output to data.

*** Dynamic nonlinear least-squares does the same for dynamic solutions.

*** The static constrained optimization add-in adjusts several problem parameters, searching for a minimum or maximum value of an objective function which you specify. The values of the adjustable (i.e. decision) parameters are constrainable between lower and upper bounds, and optionally, you may specify several other functions which are constrained to be either less than or greater than specified constants.

Documentation:

The user has DMSdoc.html which has a list of content - topics with links, and the topics cover using the various menus and formulating problems. There is also a Programmers' Manual pdf which lists user-callable procedures in both the basic DMSolver and the add-ons.