Load Case Information

Results in a batch can be linked to information about the load case. Sometimes this is data that is contained in the model e.g. RefCurrentSpeed. And sometimes it is information that represents many data items e.g. “Far condition”, “100yr Wave”.

You can add either of these types of information to each job in a batch:

from qalx_orcaflex import data_models as dm

current_speed = dm.ModelInfo(
         object_name = "Environment",
         data_name = "RefCurrentSpeed",
         alias = "Current Speed"
         )
ret_period = dm.RawInfo(
         key = "Wave return period",
         value = "100yr"
         )
offset = dm.RawInfo(
         key = "Vessel offset",
         value = "Far"
         )
load_case_info = dm.LoadCaseInfo(
                     model_info=[current_speed],
                     raw_info=[ret_period, offset])

Information that is attached as ModelInfo when the batch is built will be extracted from each simulation that it is attached to.

The example below shows how you might add this to a batch.

from qalx_orcaflex.core import ModelSource, OrcaFlexBatch, QalxOrcaFlex
import qalx_orcaflex.data_models as dm
import OrcFxAPI as ofx

qfx = QalxOrcaFlex()
batch_options = dm.BatchOptions(
    batch_queue="batch bot",
    sim_queue="sim bot",
)
met_ocean = {
    "100yr": {"H": 14.2, "T": 19.8},
    "50yr": {"H": 12.1, "T": 17.6},
}

with OrcaFlexBatch(name="My Batch", session=qfx,
                   batch_options=batch_options) as batch:
    m = ofx.Model("MY BASE MODEL.dat")
    for rp, wave in met_ocean.items():
        m.environment.WaveHeight = wave['H']
        m.environment.WavePeriod = wave['T']
        ret_period = dm.RawInfo(
            key="Wave return period",
            value = rp
        )
        current_speed = dm.ModelInfo(
            object_name="Environment",
            data_name="RefCurrentSpeed",
            alias="Current Speed"
        )
        load_case_info = dm.LoadCaseInfo(
            model_info=[current_speed],
            raw_info=[ret_period])
        batch.add(
            ModelSource(m, f"RP={rp}"),
            load_case_info=load_case_info
        )

This information is also included with Extracted results to give a vs_info field. This is a view of the result data against the various load case information that has been specified. This should make building plots for sensitivity studies very easy.

This vs_info item is a mapping with the following structure:

{"Raw model load case info name":
    {"index": [ x values (these are the values of the load case info in each case)],
     "columns": ['max', 'min'],
     "data": [ [max_0, min_0], [max_1, min_1], ... the max and min values for the result]
    }

The structure of the above results is deliberately designed to comply with building pandas dataframes.

Further examples of using this data can be found in Custom Bots