Python external function examples: Dynamic positioning system

This topic is intended to be read in conjunction with the main external function documentation, and the example source code.

This ZIP file contains all of the Python external function examples, with each example contained in the appropriately named sub-folder.

This is an example of a very basic vessel dynamic positioning (DP) system, implemented by an externally calculated applied load that models the DP thrusters. This example comprises Python script DynamicPositioningSystem.py and OrcaFlex data file DynamicPositioningSystem.dat.

The external function tries to keep the vessel on station by making the global applied force and moment proportional to the difference between the actual and target position and heading of the vessel. This has the same effect as applying simple linear springs in the global X and Y directions, and a torsional spring about the vertical. A real DP system would be much more sophisticated than this simple example, and typically would use multiple thrusters and a more complex controlling algorithm.

Open the model DynamicPositioningSystem.dat in OrcaFlex. In this model there are three vessels, which are initially all on top of each other. The DP Vessel (yellow) is the vessel to which the externally calculated DP loads are applied. The Target Position vessel (red) is simply a fixed vessel whose purpose is to mark the target position and heading that has been specified for the DP Vessel. The No DP Vessel (green) is identical to the DP Vessel but with no DP system acting, so it shows where the vessel drifts due to wave, current and wind effects if DP is not used.

When you run the simulation the Target Position vessel stays in the target position, since it is fixed. But you can see the No DP Vessel drift away a lot, and it yaws significantly too. The DP Vessel drifts a bit from the target position, but the control system keeps it quite close to the target position and heading.

The model data settings that achieve this are as follows. On the applied loads page of the DP Vessel data form, a global applied load is specified. This load uses the external function variable data item called Thruster to calculate the components of applied force in the global X and Y directions, and the applied moment about the global Z direction (vertically upwards). On the variable data form, the Python module and class is specified for this Thruster variable data source.

Notice that the same external function (Thruster) is specified for both the X and Y applied force components, and also for the Z component of applied moment. The external function calculates all 3 components when the X component is requested, since that component is called first, as noted in external function calling order. The script returns each load component separately, one component for each call to its Calculate() method.

The target position and heading of the vessel, and two control parameters (kf and km), are specified in the object tags of the DP Vessel. This allows the same external function class to be used for different applications, and allows these model-specific parameters to be specified in the OrcaFlex model.