Python external function examples: Line type axial stiffness

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.

In this example we present a linear axial stiffness, but implemented using an external function, rather than directly specifying an EA value for an OrcaFlex line type. This example comprises only an OrcaFlex data file, LinearEA.dat. The Python code is embedded within the data file. You can access the script from the OrcaFlex variable data item. The OrcaFlex pop out editor presents the code in a separate window, with syntax highlighting, which makes for easier reading.

For an overview of the OrcaFlex line model, and the details of precisely where within OrcaFlex your axial stiffness external function is applied, see the line type stiffnesses section.

Instancing and run time considerations

An instance of the LinearEA class is created for each line segment that is assigned a line type using our variable data for axial stiffness. The number of line segments in a model is often large, and so there can be very many instances of your external function, if your line type is used for a lot of the line in the model. Because of this possibility, implementation of line type stiffness by external functions can be more sensitive to the slower execution speed of Python compared to native code.

Our recommendation for line type stiffness external functions is that initial development of mathematical models and test cases can be done in Python, taking advantage of its readability and short development cycle. When moving from that initial development phase to full analysis workloads using line type stiffness external functions for many load cases with large numbers of line segments, a port of your code to a native external function could offer improved run time.

Code details

The linearEA class has both Calculate and CalculateNominalValue methods, which OrcaFlex calls for different purposes. The call to CalculateNominalValue comes first. For OrcaFlex line objects using a line type that uses our external function for axial stiffness, the nominal value of stiffness is used to draw those lines. Within CalculateNominalValue, we assign a constant EA to info.Value.

Method Calculate should be familiar from other external function examples. For a class that implements an axial stiffness, we assign the wall tension in the line segment to info.Value. For emphasis we repeat that the value given to OrcaFlex in Calculate is a tension, not a stiffness.

Our function is implementing an axial stiffness. In order to calculate the tension in a line segment, we require a strain value as input to the tension calculation. OrcaFlex provides strain values as part of the node instantaneous calculation data. Each instance of the external function presents strain values for the line segment that it represents. Each line segment has a line node at either end. Of those two nodes, it is the line node closer to End A of the OrcaFlex line which hosts the external function for the segment.