Running_Without_Trick - nasa/gunns GitHub Wiki

{{>toc}}

Running Without Trick

Although GUNNS was developed and optimized for the NASA Trick simulation environment, the GUNNS code can be compiled and run without Trick. We partially do so in our unit tests.

Non-Trick Environments

Boeing’s Common Simulation Framework (CSF)

GUNNS has been successfully run in Boeing’s CSF environment for their CST-100 training simulation. This required a custom wrapper to interface GUNNS with the CSF environment and replace the functions that Trick normally supplies. Contact Boeing for more info about this implementation.

JPL’s Dshell

JPL’s Dshell is a real-time simulation framework in the same vein as Trick. To our knowledge, no one has run GUNNS in Dshell yet, but in theory it should be possible. Dshell already supports interfacing Python to SWIG-wrapped C++, which should make porting GUNNS to it relatively simple. Dshell is already being used in projects at JSC (notably the COMPASS project), so we hope that someday we’ll find an opportunity to run GUNNS in it.

GUNNS Standalone Environment

We call this the “standalone” or “environment-less” environment, in which GUNNS is not interfaced to any outside simulation environment. By default, you’re in this environment when you source the gunns/bin/cshrc script. The lib/test and lib/no_trick compiled libraries have no dependencies on any software external to the gunns/ folder. Starting with release v17.0, the unit tests now truly have no Trick dependencies, and make use of the lib/test compiled library.

This environment is mainly used for testing. GUNNS provides no real-time sim scheduling or other functions that ones uses Trick for, so the capabilities in this environment are limited.

Compile Dependencies

GUNNS code only has dependencies on Trick code indirectly through the Trick memory manager macros defined in ms-utils/software/SimCompatibility/TsSimCompatibility.hh. These macro’s all have a non-Trick version, which we can select at compile time via a Makefile definition. To compile with no Trick dependencies, include this line in your Makefile:

no_TRICK_ENV = 1

Our unit tests include this so that they don’t depend on Trick’s memory manager. In Trick sims, GUNNS code will typically allocate & destroy dynamic memory through Trick’s Memory Manager. Thus it integrates the memory with the Trick environment, providing many useful services such as checkpointing, user visibility into the memory, etc. In the unit tests, however, we don’t want Trick dependencies, so we opt out of Trick’s Memory Manager by including the above line in the unit test makefile. This switches to regular C++ new & delete keywords for handling dynamic memory.

If your simulation environment has its own memory manager, it might be useful to extend the TsSimCompatibility.hh with a compile option and unique macro versions to take advantage of your environment.

The Trick-less Compiled Library

Beginning with release 14.3, we have a way to easily build a compiled object library in your environment with no Trick dependencies. This library includes all of gunns/core, gunns/aspects, gunns/gunns-ts-models, and the most relevant classes in gunns/ms-utils. Therefore you must have the gunns-ts-models and ms-utils submodules in your gunns/ repository for this library to build.

See the gunns/lib_no_trick/Makefile. Its comments at the top detail how to use it. You can override your compiler (defaults to g++) and optimization options (defaults to -O2). It makes Trick-free objects by setting the no_TRICK_ENV flag described above.

The Makefile will output a message indicating successful conclusion of the build.

To use this library in your application, you’ll typically include it in your Makefile. See gunns/sims/SIM_test_trickless/Makefile for an example of how to include it. This sim is identical to the SIM_test Trick sim except that it is implemented in its own Trick-less main executable.

Link Dependencies

GUNNS classes and networks typically have many dependencies on other compiled objects that have to be resolved in the linker. Trick makes this easy by providing a place to define every file’s dependencies in a LIBRARY_DEPENDENCY comment area at the top of the file. All GUNNS class header .hh files list their own .o. For instance at the top of Gunns.hh:


/*
...
LIBRARY DEPENDENCY:
- ((core/Gunns.o))
...
*/

Likewise, all GUNNS class body .cpp files list the compiled objects they depend on. For instance at the top of Gunns.cpp:


/*
...
LIBRARY DEPENDENCY:
   (
    (core/GunnsBasicLink.o)
    (core/GunnsFluidNode.o)
    (core/GunnsMinorStepLog.o)
    (math/linear_algebra/Sor.o)
    (math/linear_algebra/CholeskyLdu.o)
    (software/exceptions/TsInitializationException.o)
    (software/exceptions/TsOutOfBoundsException.o)
    (software/exceptions/TsNumericalException.o)
   )
...
*/

All GUNNS #include and LIBRARY_DEPENDENCY paths assume that the gunns/core and ms-utils folders are already included in the compiler Include directive.

Our unit tests rely on Trick’s dependency automation in their makefiles.

This syntax is Trick-unique, but you can extract this information to build the dependencies into your own linker process as needed.

TODO script or fancy makefile stuff to automate this?

Run-Time

Run-time calls are made to each network from a simulation sequencer. See here for the network methods that need to be called.

⚠️ **GitHub.com Fallback** ⚠️