# wisdem/raft architecture

> Architecture diagram of the GitHub repository wisdem/raft, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wisdem/raft
- Repository: https://github.com/wisdem/raft

## Overview

##### Project type and purpose
- RAFT is a domain-specific Python library/tool for frequency-domain analysis of floating wind turbines.
- It exposes both a CLI (`runRAFT.py`, example scripts) and a programmatic API (`raft/` package).
- It integrates aerodynamic (CCBlade), hydrodynamic (pyHAMS), and mooring (MoorPy) sub-models to compute system response amplitudes.

##### File structure
Top-level directories and roles:
- raft/              → core Python modules (models, solvers, helpers)
- examples/          → usage scripts and sample YAML inputs
- designs/           → canonical YAML design files for different floating platforms
- tests/             → unit and integration tests
- docs/              → Sphinx documentation source
- .github/workflows/ → CI (testing, publishing)
- environment*.yml   → Conda environments for development
- setup.py / pyproject.toml → package metadata & build

##### Extract architecture hints from README
- Core components: aerodynamics (CCBlade), mooring (MoorPy), optional hydrodynamics (pyHAMS).
- Input: YAML design files → parsed into Python objects.
- Workflow: user runs `runRAFT.py` or imports `omdao_raft.py` → assemble buildings blocks → solve frequency-domain equations → generate outputs.

##### Main components & interactions (to include
a. Entry Points
– CLI / Scripts: example-*.py, runRAFT.py
– Library API: omdao_raft.py, raft_fowt.py
b. I/O Layer
– YAML Parser (reads designs/, examples/) → Python configuration objects
– Results Writer (WAMIT_format directories, pickle, plots)
c. Core Computation
– raft_model.py: assembles system matrices
– raft_member.py & raft_rotor.py: platform and rotor definitions
– parametersweep.py: batch analysis over parameter sets
– helpers.py & member2pnl.py: geometry & mesh conversion
d. External Sub-models
– Aerodynamics: CCBlade (imported modules)
– Mooring: MoorPy API
– Hydrodynamics: pyHAMS wrapper (optional)
e. Solver
– Frequency-domain solver (inside raft_model or runRAFT)
– GitHub Actions: CI_RAFT.yml, Publish_RAFT.yml
– tests/: pytest suite
– docs/: Sphinx build

##### Relationships and data flow
– User (CLI or API) → I/O Layer parses YAML → Core Computation sets up model → External Sub-models are invoked → Solver computes responses → I/O Layer writes outputs → User inspects results
– Tests and CI trigger on code changes but are orthogonal to runtime flow

##### Architectural patterns & design principles
– Modular design: each physical domain (aero, hydro, mooring) lives in its own component
– Plugin-style external integration: optional imports (pyHAMS) guarded by availability
– Data-driven configuration: YAML at the heart of extensibility
– Clear separation of concerns: I/O, model assembly, solution, visualization

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user

    subgraph "Entry Points"
        RunRAFT["runRAFT.py"]:::entry
        Example1["example-RAFT_QTF.py"]:::entry
        Example2["example-WAMIT_Coefs.py"]:::entry
        Example3["example_from_yaml.py"]:::entry
        Omdao["omdao_raft.py"]:::entry
        Fowt["raft_fowt.py"]:::entry
    end

    subgraph "I/O Layer"
        YAMLParser["YAML Parser"]:::io
        ResultsWriter["Results Writer"]:::io
    end

    subgraph "Core Computation"
        ModelAssembler["RAFT Model Assembler"]:::core
        PlatformDef["RAFT Member Definition"]:::core
        RotorDef["RAFT Rotor Definition"]:::core
        ParamSweep["Parameter Sweep"]:::core
        GeometryHelpers["Geometry Helpers"]:::core
        MeshConversion["Mesh Conversion"]:::core
    end

    subgraph "External Sub-models"
        Aero["Aerodynamics (CCBlade)"]:::ext
        Mooring["Mooring (MoorPy)"]:::ext
        Hydro["Hydrodynamics (pyHAMS) [Optional]"]:::ext
    end

    Solver["Frequency-domain Solver"]:::core

    subgraph "Development & CI"
        CI["CI_RAFT.yml"]:::dev
        Publish["Publish_RAFT.yml"]:::dev
        Tests["tests/ (pytest)"]:::dev
        Docs["docs/"]:::dev
    end

    %% Runtime Flow
    User --> RunRAFT
    User --> Example1
    User --> Example2
    User --> Example3
    User --> Omdao
    User --> Fowt

    RunRAFT --> YAMLParser
    Example1 --> YAMLParser
    Example2 --> YAMLParser
    Example3 --> YAMLParser
    Omdao --> YAMLParser
    Fowt --> YAMLParser

    YAMLParser --> ModelAssembler
    YAMLParser --> PlatformDef
    YAMLParser --> RotorDef

    GeometryHelpers --> PlatformDef
    MeshConversion --> RotorDef

    PlatformDef --> ModelAssembler
    RotorDef --> ModelAssembler

    ModelAssembler --> ParamSweep
    ParamSweep --> Solver

    Aero --> ModelAssembler
    Mooring --> PlatformDef
    Hydro --> ModelAssembler

    Solver --> ResultsWriter
    ResultsWriter --> User

    %% Dev & CI Flow (orthogonal)
    CI --> Tests
    CI --> Docs
    Publish --> Docs

    %% Click Events
    click RunRAFT "https://github.com/wisdem/raft/blob/master/raft/runRAFT.py"
    click Example1 "https://github.com/wisdem/raft/blob/master/examples/example-RAFT_QTF.py"
    click Example2 "https://github.com/wisdem/raft/blob/master/examples/example-WAMIT_Coefs.py"
    click Example3 "https://github.com/wisdem/raft/blob/master/examples/example_from_yaml.py"
    click Omdao "https://github.com/wisdem/raft/blob/master/raft/omdao_raft.py"
    click Fowt "https://github.com/wisdem/raft/blob/master/raft/raft_fowt.py"
    click YAMLParser "https://github.com/wisdem/raft/tree/master/designs/"
    click ResultsWriter "https://github.com/wisdem/raft/tree/master/raft/data/cylinder/Output/Wamit_format/"
    click ModelAssembler "https://github.com/wisdem/raft/blob/master/raft/raft_model.py"
    click PlatformDef "https://github.com/wisdem/raft/blob/master/raft/raft_member.py"
    click RotorDef "https://github.com/wisdem/raft/blob/master/raft/raft_rotor.py"
    click ParamSweep "https://github.com/wisdem/raft/blob/master/raft/parametersweep.py"
    click GeometryHelpers "https://github.com/wisdem/raft/blob/master/raft/helpers.py"
    click MeshConversion "https://github.com/wisdem/raft/blob/master/raft/member2pnl.py"
    click Aero "https://github.com/wisdem/raft/blob/master/raft/pyIECWind.py"
    click CI "https://github.com/wisdem/raft/blob/master/.github/workflows/CI_RAFT.yml"
    click Publish "https://github.com/wisdem/raft/blob/master/.github/workflows/Publish_RAFT.yml"
    click Tests "https://github.com/wisdem/raft/tree/master/tests/"
    click Docs "https://github.com/wisdem/raft/tree/master/docs/"

    %% Styles
    classDef entry fill:#D6EAF8,stroke:#AED6F1
    classDef io fill:#FCF3CF,stroke:#F7DC6F
    classDef core fill:#D4E6F1,stroke:#5DADE2
    classDef ext fill:#D5F5E3,stroke:#52BE80
    classDef dev fill:#E5E7E9,stroke:#BFC9CA
    classDef user fill:#FADBD8,stroke:#EC7063
```
