USER-DEFINED SYSTEMS
This section describes how to create a user-defined
system by deriving a class from the abstract
class System .
There are three mandatory steps:
1. Declare a new class
from System . Grant public inheritance access.
class UserSystem : public System
{
...
};
2. Write a constructor for the derived class that
constructs an object of the
class System by means of an initialization list.
Make sure that the constructor
calls InitSS
at the end of the body. The constructor may be used to initialize the
parameters of the
system.
UserSystem :: UserSystem() :
System(step, species, rates, input_species, output_rate)
{
...
InitSS();
}
Remember that the parameters of the constructor
of System are
step
|
Time-increment used for integration
|
species
|
Number of species or concentrations
|
rates
|
Number of velocities, including output fluxes
|
input_species
|
Number of the species that receives the input flux
|
output_species
|
Number of the rate to be considered the response of the system
|
3. Provide the
method EvaluateSystem .
This method should evaluate the velocities and the derivatives of the
concentrations (i.e. the differential equations of the system). Here is
where the system is actually defined
void UserSystem :: EvaluateSystem(void)
{
// Evaluation of the velocities
v[0] = ...;
...
v[numv-1] = ...;
// Differential equations
dc[0] = ...;
...
dc[numc-1] = ...;
}
In addition, the user may want to define additional
data types and methods that support the constructor
and EvaluateSystem , and that provide additional
functionality. For example, methods may be defined that evaluate a rate
equation from a set of parameters and concentrations.
|