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
A SimObject has the following properties:
The most fundamental methods which a SimObject must implement are:
For efficiency, the port values are never copied, only pointers to the different port values are distributed. This is also the case with the states and the state derivatives.
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.
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:
InitialConditionSetupof 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.