Marine systems simulation
|
The most fundamental elements for developing new models in FhSim are the SimObject interface, its building blocks, common computations and initial conditions.
A simulation is usually comprised of multiple sub-models which are connected through input and output ports. These sub-models are a fundamental part of FhSim and is referred to as SimObjects
. A SimObject has the following properties:
In some cases, it is beneficial to have access to perform identical calculations, coordinated tasks across SimObjects or calculations not fitting within the usual time integration paradigm. A typical example would be when one wants to calculate the environmental forces on multiple structures operating in the same sea, and especially if these interact. In FhSim, this is typically solved by defining an environment object, and giving all relevant SimObjects access to this. FhSim includes a mechanism to share any kind of C++ object between simObjects. Typically, in the simObject constructor one sets the shared resource using the supplied instance of the creator. Considering a resource of type resource_class
one wants to associate with the name resource_name
and that resource_pointer
is a permanent pointer to the resource. Registering this resource can be done like this (creator points to an object of type ISimObjectCreator
):
When another simObject wants to use the shared resource, it must know the name and type of the object. It can then retrieve it like this:
To ensure that all shared resources are registered before they are retrieved, it is advisable to register them in the simObject constructor and retrieve them in the simObject function FinalSetup
. Both takes creator
as one of their arguments.
Computations that are shared between different functions (OdeFcn, PortFunctions, different SimObjects) may be registered as a CommonComputation. The system will ensure it is called only once per time step. The typical use case is if several output ports depends on the same calculation. Imagine a spring which outputs force in each end in two separate output ports. Each port function could then start by calling the same CommonComputation, calculating the tension and orientation of the spring only once per time step.
The time integration must have a starting point in the form of an initial state vector. This starting point can be defined in multiple ways:
InitialConditionSetup
of the individual SimObjects.The latter allows for example SimObjects to calculate their initial state based on parameters and input ports. In some cases multiple SimObjects use input ports for determining their states, and output ports depend on input ports and/or states. This can lead to mutual dependencies. FhSim tries to solve this by iteration. If this doesn't succeed within a predefined number of iterations, the simulation will be aborted with an error message.