GENESIS: Documentation

Related Documentation:

Create and Add Solver Object to GENESIS 3

This developer guide gives an example of how to add a new simulation object and integrate this new Component with GENESIS. As an example we implement the pulsegen object of GENESIS 2 that, for simplicity, we will embed as a new component in the Experiment package.

Creating Source Files

First we create the following source files for the new object in the correct places in Experiment:

   pulsegen.c  
   experiment/pulsegen.h

These source files will be filled in with the functionality of the GENESIS 2 pulsegen object.

Implementation

Declarations

Data Structure

To keep track of all the data for the new object we define a struct(ure) which contains all of our variables. This structure is set up in the header file experiment/pulsegen.h:

   struct simobj_PulseGen  
   {  
 
      char *pcName;  
 
      double dLevel1;  
      double dWidth1;  
      double dDelay1;  
 
      double dLevel2;  
      double dWidth2;  
      double dDelay2;  
 
      double dBaseLevel;  
 
      double dTriggerTime;  
      int iTriggerMode;  
 
      int iPreviousInput;  
 
      /// An input value referenced via pointer.  
 
      double *pdPulseIn;  
 
      /// solved variables  
 
      double *pdPulseOut;  
   };

Functions

Keeping in mind that the new object is going to be used by a simulation, we need appropriate functions for interaction with the scheduler. The most important functions are: creation and set up of the object’s run-time instance, performing the actions during a single simulation step, and freeing the memory allocated by the object during its lifetime.

Add New Object to Make Targets

Before compiling the new simulation object you must add your source files to targets of the Experiment package Makefile.am.

The new simulation object will be compiled into the Experiment library when a make is performed.