Workflows and automation Examples showing how to automate work in SIMA: control flow in workflows, running sets of conditions, error handling, doing calculations as part of a workflow, and driving a full analysis from a custom editor. 1. Control flow Case Description Tags Tool If else statement Make an if else statement if else - Do while example Example of a do-while loop. Example 1: using JavaScript Example 2: using constraints do while java script constraints - Iterate to a target frequency with a do-while loop A do-while loop used to solve for a design value: the top tension of a VIVANA drilling riser is adjusted until the first eigenfrequency reaches a target. The workflow app_Iterate_to_target_frequency runs an eigenvalue analysis, compares the frequency with the target and feeds the corrected tension back into the next iteration, until the loop condition continue_loop is false. The tensions and frequencies from every iteration are kept, so the convergence can be inspected afterwards. do while iteration eigenfrequency top tension VIVANA Riflex 2. Workflow sets and error handling Case Description Tags Tool How to use error log in a workflow set Log of the failed cases stored to file. workflow set error log - Condition and workflow as input An example showing condition and workflow as input workflow input - 3. Calculations in workflows Case Description Tags Tool Calculate relative distance between points This example shows how to use a workflow to calculate the relative distance between two points. This approach can be extended to find the relative distance between two bodies. workflow transform point relative position bodies - Coordinate transform with input The transform workflow takes a position and a coordinate system as input and returns the position expressed in the other system. A reference position and a relative position are set up as separate branches, so the two directions of the transform can be compared. A documentation task and a workflow test are included in the model. workflow coordinate transform input workflow test - Import a CSV file with units Read tabular data from a CSV file into a workflow with the importCSV operator, where the units are given in the file itself. The imported data is shown in a table. The source file test.csv sits in the storage task, so the example can be run as it is. workflow CSV import units - 4. Python, batch and command line Running Python from inside a workflow, and running SIMA itself without the graphical user interface. Case Description Tags Tool Run Python from a workflow Two ways of calling a Python script as a step in a workflow, both using the Run operation in python operator: exampleSimaPy exchanges signals as JSON through the simapy package. The workflow passes the parameters scale, offset and message to the script, which scales and offsets the signal and writes it back for plotting. exampleH5 exchanges data as HDF5 using h5py and numpy. The script reads a harmonic signal, stores its maximum as a single result value and generates a new time series. The scripts are kept in the storage task PythonScripts, so they can be edited directly in SIMA. workflow Python simapy h5py HDF5 JSON - Run SIMA headless from a Python script How to drive SIMA in batch mode from Python. The script runSima.py starts SIMA headless with a command file, commands.txt, which imports the model and runs the workflow runWorkflow with input values supplied on the command line, for example run task=myTask workflow=runWorkflow input=myInput=2.0;mySecondInput=20. The workflow writes its result to a storage task as HDF5, which the Python script then reads back and prints. The set-up is described step by step in ST_readme_run_from_batch/readme.txt in the model. Note that runSima.py depends on h5py, and that the paths to the SIMA executable, the workspace and the command file must be updated before running. batch headless Python command file HDF5 - Run a simulation from the command line A complete SIMO model of a semi-submersible (SEMI) driven from outside SIMA. Four workflows cover the full loop: single_simulation exposes Hs, Tp, WindSpeed and seed as inputs and writes the results to a given output_dir, so one simulation can be started from the command line with the sea state as arguments process_results post-processes what a run produced, including the maximum offset process_seed_variation collects results across a set of seeds from a base_directory and result_filename load_file reads results back in command line batch workflow input sea state seed variation max offset SIMO 5. Automated analysis and reporting Case Description Tags Tool Condition set in a workflow set, with custom editor and report A top tensioned riser with marine growth, where the growth is modelled both from a marine growth profile and as external wrapping on the cross section. The example shows a full automated set-up: workflows running the cases in a loop (workflow set) a custom editor for running the analysis and showing results a report generator driven from the custom editor A variant of this model is also used under Slender structures. workflow set condition set custom editor report marine growth Riflex Custom editor driving a workflow A minimal custom editor wired to a workflow. The editor task CustomTask exposes an input value and runs the workflow innerScale in WorkflowExamples, with the resulting table and plot shown back in the same editor. Useful as a starting point before building a larger custom editor. custom editor workflow table plot - Run a set of hindcast sea states from script Run a model through a series of hindcast sea states, where each sea state is a scripted environment generated from hindcast data. The workflow Run_Hindcast loops over a file list in the storage task Location1_Hindcast, runs the model for each scripted environment and collects the statistics of the response; Run_selected_Spectra does the same for a subset. Results are written to Location1_Results as all_spectra.txt and selected_spectra.txt. The storage task Python_input holds the raw hindcast files for two locations together with a Jupyter notebook, SIMA_Spectrum_example.ipynb, showing how the wave spectra were converted into scripted environments. hindcast scripted environment wave spectrum Jupyter statistics SIMO Post-processing SIMAPy