Claude
Skills
Sign in
Back

orcaflex-specialist

Included with Lifetime
$97 forever

# OrcaFlex Specialist Skill

General

What this skill does

# OrcaFlex Specialist Skill

```yaml
name: orcaflex-specialist
version: 1.0.0
category: sme
tags: [orcaflex, offshore, simulation, python-api, automation, marine-dynamics, mooring, riser]
created: 2026-01-06
updated: 2026-01-06
author: Claude
description: |
  Expert OrcaFlex workflows, Python API automation, model validation, and best
  practices for offshore marine simulations. Covers mooring analysis, riser
  dynamics, installation simulations, and advanced post-processing.
```

## When to Use This Skill

Use this skill when you need to:
- Automate OrcaFlex model creation and analysis
- Build parametric OrcaFlex models via Python API
- Perform batch simulations with varying parameters
- Extract and process time series results
- Validate OrcaFlex models against design criteria
- Integrate OrcaFlex with external tools and workflows
- Optimize mooring and riser configurations
- Conduct sensitivity studies and Monte Carlo simulations

## Core Knowledge Areas

### 1. OrcaFlex Python API Basics

Connecting to OrcaFlex and basic model operations:

```python
import OrcFxAPI
import numpy as np
from pathlib import Path
from typing import List, Dict, Optional

def create_new_model(
    general_data: dict,
    save_path: Path = None
) -> OrcFxAPI.Model:
    """
    Create a new OrcaFlex model with general settings.

    Args:
        general_data: Dictionary with general data parameters
        save_path: Optional path to save the model

    Returns:
        OrcaFlex model object

    Example:
        >>> general_data = {
        ...     'ImplicitUseVariableTimeStep': 'Yes',
        ...     'TargetLogSampleInterval': 0.1,
        ...     'InnerTimeStep': 0.01,
        ...     'StageCount': 2,
        ...     'StageDuration': [100, 3600]
        ... }
        >>> model = create_new_model(general_data)
    """
    # Create new model
    model = OrcFxAPI.Model()

    # Set general data
    general = model.general

    for key, value in general_data.items():
        setattr(general, key, value)

    # Save if path provided
    if save_path:
        model.SaveData(str(save_path))

    return model

def load_model(
    file_path: Path,
    validate: bool = True
) -> OrcFxAPI.Model:
    """
    Load existing OrcaFlex model with optional validation.

    Args:
        file_path: Path to .dat or .sim file
        validate: Whether to validate model after loading

    Returns:
        Loaded OrcaFlex model

    Example:
        >>> model = load_model(Path('mooring_analysis.dat'))
        >>> print(f"Model stages: {model.general.StageCount}")
    """
    model = OrcFxAPI.Model(str(file_path))

    if validate:
        # Run basic validation
        state = model.State()
        if state != OrcFxAPI.ModelState.Reset:
            print(f"Warning: Model state is {state}")

        # Check for invalid objects
        invalid_objects = []
        for obj in model.objects:
            try:
                obj_type = obj.type
            except:
                invalid_objects.append(obj.name)

        if invalid_objects:
            print(f"Warning: Invalid objects found: {invalid_objects}")

    return model

def run_static_analysis(
    model: OrcFxAPI.Model,
    thread_count: int = None
) -> None:
    """
    Run static analysis (statics to whole simulation).

    Args:
        model: OrcaFlex model
        thread_count: Number of threads (None = auto)

    Example:
        >>> model = load_model('mooring.dat')
        >>> run_static_analysis(model, thread_count=4)
        >>> print("Static analysis complete")
    """
    # Configure calculation
    if thread_count:
        model.general.ThreadCount = thread_count

    # Run statics to whole simulation
    model.CalculateStatics()
    model.RunSimulation()

    print(f"Simulation complete. State: {model.State()}")

def run_dynamic_analysis(
    model: OrcFxAPI.Model,
    save_sim: bool = True,
    sim_path: Path = None
) -> Path:
    """
    Run dynamic analysis and save results.

    Args:
        model: OrcaFlex model
        save_sim: Whether to save simulation results
        sim_path: Path to save .sim file

    Returns:
        Path to saved simulation file

    Example:
        >>> model = load_model('mooring.dat')
        >>> sim_file = run_dynamic_analysis(model, sim_path=Path('results.sim'))
        >>> print(f"Results saved: {sim_file}")
    """
    # Run simulation
    model.RunSimulation()

    # Save results
    if save_sim:
        if sim_path is None:
            # Generate default path
            sim_path = Path(model.DataFileName()).with_suffix('.sim')

        model.SaveSimulation(str(sim_path))
        return sim_path

    return None
```

### 2. Building Models Programmatically

Create complex models via Python API:

```python
def create_vessel_model(
    vessel_params: dict,
    mooring_config: dict,
    environment: dict
) -> OrcFxAPI.Model:
    """
    Create complete vessel model with moorings and environment.

    Args:
        vessel_params: Vessel properties
        mooring_config: Mooring line configuration
        environment: Environmental conditions

    Returns:
        Complete OrcaFlex model

    Example:
        >>> vessel_params = {
        ...     'name': 'FPSO',
        ...     'mass': 150000,  # tonnes
        ...     'length': 300,  # m
        ...     'draft': 20,
        ...     'draft_fore': 20,
        ...     'draft_aft': 20
        ... }
        >>> mooring_config = {
        ...     'pattern': 'spread',
        ...     'line_count': 8,
        ...     'line_length': 1500,
        ...     'line_type': 'chain_wire_chain'
        ... }
        >>> environment = {
        ...     'water_depth': 1200,
        ...     'current_speed': 1.0,
        ...     'wave_height': 5.0,
        ...     'wave_period': 12.0
        ... }
        >>> model = create_vessel_model(vessel_params, mooring_config, environment)
    """
    # Create new model
    model = OrcFxAPI.Model()

    # Set environment
    env = model.environment

    # Water depth
    env.WaterDepth = environment['water_depth']

    # Current profile
    env.RefCurrentSpeed = environment['current_speed']
    env.CurrentDepths = [0, -environment['water_depth']]
    env.CurrentSpeeds = [environment['current_speed'], 0.5 * environment['current_speed']]

    # Waves (JONSWAP spectrum)
    env.WaveType = 'JONSWAP'
    env.WaveHs = environment['wave_height']
    env.WaveTp = environment['wave_period']
    env.WaveGamma = 3.3

    # Create vessel
    vessel = model.CreateObject(OrcFxAPI.otVessel, vessel_params['name'])

    # Set vessel properties
    vessel.Length = vessel_params['length']
    vessel.Draft = vessel_params['draft']
    vessel.DraftAtRest = vessel_params['draft']
    vessel.Mass = vessel_params['mass']

    # Displacement check
    rho_sw = 1025  # kg/m³
    g = 9.81
    displacement = vessel_params['mass'] * 1000 * g  # N
    print(f"Vessel displacement: {displacement/1e6:.1f} MN")

    # Create mooring lines
    create_mooring_system(
        model=model,
        vessel=vessel,
        config=mooring_config,
        water_depth=environment['water_depth']
    )

    return model

def create_mooring_system(
    model: OrcFxAPI.Model,
    vessel: OrcFxAPI.OrcaFlexObject,
    config: dict,
    water_depth: float
) -> List[OrcFxAPI.OrcaFlexObject]:
    """
    Create mooring system attached to vessel.

    Args:
        model: OrcaFlex model
        vessel: Vessel object
        config: Mooring configuration
        water_depth: Water depth [m]

    Returns:
        List of mooring line objects

    Example:
        >>> config = {
        ...     'pattern': 'spread',
        ...     'line_count': 8,
        ...     'line_length': 1500,
        ...     'fairlead_radius': 40,
        ...     'anchor_radius': 1400,
        ...     'line_sections': [
        ...         {'type': 'R4 Studless Chain', 'length': 300},
        ...         {'type': '76mm Wire', 'length': 900},
        ...         {'type': 'R4 Studless Chain', 'le

Related in General