Notes for Simulation Developers
This section contains notes for simulation developers who would like to gain more insights on how the Mixer simulator is created and maintained using the SansGUI Development Environment. If you do not have a proper license key to activate the SansGUI Development Environment, you can register for a 30-day evaluation license key on our web site: http://protodesign-inc.com/register.htm. Because there are only nine classes defined, excluding the simulation control classes, the SansGUI Student Edition is capable enough for all the features described here.
To look into the definitions of the Mixer simulator, load the Schema Definition file Mixer.sgs into the SansGUI Environment with SGpro or SGstu license options.
The necessary unit objects are copied from the Unit Conversion for SansGUI project.
The quantity attributes in the components are single precision floating point values while those in the matrices (Matrix.Calculation) and tables (Table.Reactor) are double precision floating point values. The reason for having double precision values in the calculation process is mainly because the MATLAB engine requires double precision matrices.
Class Matrix.Calculation defines the use of column-major order for multi-dimensional data storage. We take advantage of this SansGUI feature to utilize multi-dimensional array accessing facilities in Fortran and MATLAB. For the C/C++ implementation, a simple MIX_INDEX(R, C, N) macro is used in the solver to map the row and column indices to the linear array indices.
Connectivity restrictions of class Source and Sink are defined by their port definitions. Only one unique output or input link is allowed for these two component types, respectively.
There are two hidden attributes in class Table.Reactor: Vector Buffer 1 for Temporaries (dScratch1) and Vector Buffer 2 for Temporaries (dScratch2). These two vectors are used during the calculation process and are hidden from the user. In order to view the contents of the hidden attributes, you need to type in a password to enter a service session. See below for details.
The Object Library generated directly from the Schema Definition is not the one we installed in the default lib subdirectory of the SansGUI installation directory. We actually added some default objects into the Object Library and save it as Mixer_1_0def.sgo for distribution. If you modify the Schema Definition and generate a new version of the Object Library file, simply perform File>Update Version on the Mixer_1_0def.sgo file and add default values to the existing objects, if needed. This is what we do to prepare for the Mixer 1.0.1 release. Creating it from scratch is not necessary.
Both C/C++ and Fortran projects with the full Mixer source code are included in the distribution. You will need either Microsoft Visual C++ (MSVC) or Compaq Visual Fortran (CVF) to load the corresponding project into the IDE. The project for MSVC is located in the Mixer_1_0 subdirectory of the samples/Mixer directory. The project for CVF is located in the Mixer_1_0F subdirectory of the samples/Mixer directory. Both of them can be used to create the Mixer simulator DLL.
There are four project configurations defined in each of the C/C++ and Fortran projects. Two of the build configurations are ended with _MATLAB in their names. They contain definitions to incorporate the MATLAB engine: 1) The configurations have MIX_WITH_MATLAB defined in the Preprocessor Definitions (MSVC) or Predefined Preprocessor Symbols (CVF) in the Project>Settings... dialog; 2) They are linked with the libeng.lib and libmx.lib MATLAB libraries under the Link tab in the same dialog.
The skeleton code of the classes are generated by the SansGUI Source Code Framework in the source files with the names corresponding to class names. You can open the source files in the IDE to examine the details.
When loading the constant matrix, we need to know the class type of each component. Although we can fetch the class name string from the SG_OBJ data structure, it is much faster to identify the classes using integers. For run-time type identification, we register component classes as integers and store them in the iUserData element of the SG_OBJ data structure. In C/C++, we use macros, MIX_SET_USER_TYPE and MIX_GET_USER_TYPE, implemented in Mixer_1_0.h. In Fortran, they are implemented as functions in Mixer_T.f.
Hidden attributes in classes Base.Container.Reactor and Table.Reactor can be accessed by persons, normally the developers, who know the password set in the Schema Definition. For the Mixer simulator, we set the password to Mixer. You can enter a service session in any Object Library or Project Model by:
Selecting Tools>Service Session... from the pull-down menu.
Entering the password Mixer.
Opening the Object Properties of a reactor or the reactor table to see the hidden values.
To exit the Service Session, simply select Tools>Service Session... to uncheck it.
Please go back to the end of the Transient example for a few programming exercises.
[Cha98] Chapra, Steven C. & Canale, Raymond P. 1998. Numerical Methods for Engineers: with Programming and Software Applications, 3rd Ed., WCB/McGraw-Hill, Boston, Massachusetts.
[Mat98] The Mathworks, Inc. 1998. MATLAB Application Programming Interface Guide, Version 5.0, Natick, Massachusetts.
[Pro01] ProtoDesign, Inc. 2001. SansGUI Version 1.0 Document Set, Bolingbrook, Illinois.
This example is developed by the SansGUI Development Team at ProtoDesign, Inc.
The Great Lakes example is adopted from Problem 12.7 of Chapra & Canale.
The Fortran and C implementations of Naive Gauss Elimination and LU Decomposition use the algorithms introduced in Chapra & Canale's text.
MATLAB is a registered trademark of The Mathworks, Inc.
Mixer Example for SansGUI Version 1.0
Copyright © 2001-2003 ProtoDesign, Inc. All rights reserved.