# jonnymaserati/welleng architecture

> Architecture diagram of the GitHub repository jonnymaserati/welleng, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jonnymaserati/welleng
- Repository: https://github.com/jonnymaserati/welleng

## Overview

welleng is a Python toolkit for well and drilling engineers, centered on constructing and analyzing well trajectories. A typical workflow creates or imports a survey, optionally computes positional uncertainty, then uses it for path planning, clearance analysis, or drilling calculations. The graph also preserves documented exchange, visualization, torque-and-drag, geomagnetic, and interpretation capabilities. Relationships are grounded in excerpts, SOURCE INDEX references, or README statements; links to unsampled subsystems rely on README documentation rather than inspected implementation.

Main entry points: [`welleng/survey.py`](https://github.com/jonnymaserati/welleng/blob/main/welleng/survey.py) (Survey model), [`welleng/kick_tolerance/__init__.py`](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/__init__.py) (Kick tolerance API), [`welleng/kick_tolerance/migration.py`](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/migration.py) (Gas migration), [`welleng/connector.py`](https://github.com/jonnymaserati/welleng/blob/main/welleng/connector.py) (Path connector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trajectory["Survey and trajectory"]
  node_survey["Survey model<br/>[survey.py]"]
  node_geometry["Curve geometry<br/>[utils.py]"]
  node_connector["Path connector<br/>[connector.py]"]
  node_analytical_solver["CLC solver"]
end

subgraph group_analysis["Well analysis"]
  node_error_models["Error models<br/>[error.py]"]
  node_tool_errors["Tool error engine<br/>[tool_errors.py]"]
  node_geomag["Geomagnetic lookup<br/>[geomag.py]"]
  node_clearance["Well clearance<br/>[clearance.py]"]
  node_mesh["Collision meshes<br/>[mesh.py]"]
end

subgraph group_drilling["Drilling calculations"]
  node_kick_api["Kick tolerance API<br/>[__init__.py]"]
  node_kick_solver["Analytical kick solver<br/>[analytical.py]"]
  node_migration["Gas migration<br/>[migration.py]"]
  node_gas_z["Real-gas Z factor<br/>[gas_z.py]"]
  node_gas_z_coolprop["CoolProp EOS<br/>[gas_z_coolprop.py]"]
  node_torque_drag["Torque and drag<br/>[torque_drag.py]"]
end

subgraph group_exchange["Data exchange"]
  node_exchange["Survey data exchange<br/>[edm_stream.py]"]
  node_wbp["Well plan files<br/>[wbp.py]"]
  node_witsml["WITSML logs<br/>[witsml.py]"]
end

subgraph group_presentation["Interpretation and display"]
  node_interpretation["Survey interpretation<br/>[forward.py]"]
  node_visual["3D visualization<br/>[visual.py]"]
end

node_engineer(("Engineer"))

node_engineer -->|"creates"| node_survey
node_survey -->|"computes geometry"| node_geometry
node_engineer -->|"designs path"| node_connector
node_connector -->|"solves CLC"| node_analytical_solver
node_survey -->|"computes uncertainty"| node_error_models
node_error_models -->|"dispatches models"| node_tool_errors
node_survey -->|"looks up field"| node_geomag
node_survey -->|"supplies trajectories"| node_clearance
node_clearance -->|"uses mesh methods"| node_mesh
node_engineer -->|"calculates kick tolerance"| node_kick_api
node_kick_api -->|"exposes solver"| node_kick_solver
node_kick_api -->|"exposes migration check"| node_migration
node_kick_solver -->|"uses migration"| node_migration
node_migration -->|"uses gas properties"| node_gas_z
node_gas_z -.->|"offers optional backend"| node_gas_z_coolprop
node_survey -->|"provides trajectory"| node_torque_drag
node_engineer -->|"imports EDM data"| node_exchange
node_engineer -->|"loads well plans"| node_wbp
node_engineer -->|"reads log data"| node_witsml
node_survey -.->|"supports interpretation"| node_interpretation
node_engineer -->|"visualizes results"| node_visual
node_survey -->|"renders trajectory"| node_visual

click node_survey "https://github.com/jonnymaserati/welleng/blob/main/welleng/survey.py"
click node_geometry "https://github.com/jonnymaserati/welleng/blob/main/welleng/utils.py"
click node_connector "https://github.com/jonnymaserati/welleng/blob/main/welleng/connector.py"
click node_analytical_solver "https://github.com/jonnymaserati/welleng/blob/main/welleng/sawaryn_analytical.py"
click node_error_models "https://github.com/jonnymaserati/welleng/blob/main/welleng/error.py"
click node_tool_errors "https://github.com/jonnymaserati/welleng/blob/main/welleng/errors/tool_errors.py"
click node_geomag "https://github.com/jonnymaserati/welleng/blob/main/welleng/geomag.py"
click node_clearance "https://github.com/jonnymaserati/welleng/blob/main/welleng/clearance.py"
click node_mesh "https://github.com/jonnymaserati/welleng/blob/main/welleng/mesh.py"
click node_kick_api "https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/__init__.py"
click node_kick_solver "https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/analytical.py"
click node_migration "https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/migration.py"
click node_gas_z "https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/gas_z.py"
click node_gas_z_coolprop "https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/gas_z_coolprop.py"
click node_torque_drag "https://github.com/jonnymaserati/welleng/blob/main/welleng/torque_drag.py"
click node_exchange "https://github.com/jonnymaserati/welleng/blob/main/welleng/exchange/edm_stream.py"
click node_wbp "https://github.com/jonnymaserati/welleng/blob/main/welleng/exchange/wbp.py"
click node_witsml "https://github.com/jonnymaserati/welleng/blob/main/welleng/exchange/witsml.py"
click node_interpretation "https://github.com/jonnymaserati/welleng/blob/main/welleng/interpretation/forward.py"
click node_visual "https://github.com/jonnymaserati/welleng/blob/main/welleng/visual.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_survey,node_geometry,node_connector,node_analytical_solver toneBlue
class node_error_models,node_tool_errors,node_geomag,node_clearance,node_mesh toneAmber
class node_kick_api,node_kick_solver,node_migration,node_gas_z,node_gas_z_coolprop,node_torque_drag toneMint
class node_exchange,node_wbp,node_witsml toneRose
class node_interpretation,node_visual,node_engineer toneIndigo
```

## Components

### Survey and trajectory

- [Survey model](https://github.com/jonnymaserati/welleng/blob/main/welleng/survey.py): `welleng/survey.py`
- [Curve geometry](https://github.com/jonnymaserati/welleng/blob/main/welleng/utils.py): `welleng/utils.py`
- [Path connector](https://github.com/jonnymaserati/welleng/blob/main/welleng/connector.py): `welleng/connector.py`
- [CLC solver](https://github.com/jonnymaserati/welleng/blob/main/welleng/sawaryn_analytical.py): `welleng/sawaryn_analytical.py`

### Well analysis

- [Error models](https://github.com/jonnymaserati/welleng/blob/main/welleng/error.py): `welleng/error.py`
- [Tool error engine](https://github.com/jonnymaserati/welleng/blob/main/welleng/errors/tool_errors.py): `welleng/errors/tool_errors.py`
- [Geomagnetic lookup](https://github.com/jonnymaserati/welleng/blob/main/welleng/geomag.py): `welleng/geomag.py`
- [Well clearance](https://github.com/jonnymaserati/welleng/blob/main/welleng/clearance.py): `welleng/clearance.py`
- [Collision meshes](https://github.com/jonnymaserati/welleng/blob/main/welleng/mesh.py): `welleng/mesh.py`

### Drilling calculations

- [Kick tolerance API](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/__init__.py): `welleng/kick_tolerance/__init__.py`
- [Analytical kick solver](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/analytical.py): `welleng/kick_tolerance/analytical.py`
- [Gas migration](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/migration.py): `welleng/kick_tolerance/migration.py`
- [Real-gas Z factor](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/gas_z.py): `welleng/kick_tolerance/gas_z.py`
- [CoolProp EOS](https://github.com/jonnymaserati/welleng/blob/main/welleng/kick_tolerance/gas_z_coolprop.py): `welleng/kick_tolerance/gas_z_coolprop.py`
- [Torque and drag](https://github.com/jonnymaserati/welleng/blob/main/welleng/torque_drag.py): `welleng/torque_drag.py`

### Data exchange

- [Survey data exchange](https://github.com/jonnymaserati/welleng/blob/main/welleng/exchange/edm_stream.py): `welleng/exchange/edm_stream.py`
- [Well plan files](https://github.com/jonnymaserati/welleng/blob/main/welleng/exchange/wbp.py): `welleng/exchange/wbp.py`
- [WITSML logs](https://github.com/jonnymaserati/welleng/blob/main/welleng/exchange/witsml.py): `welleng/exchange/witsml.py`

### Interpretation and display

- [Survey interpretation](https://github.com/jonnymaserati/welleng/blob/main/welleng/interpretation/forward.py): `welleng/interpretation/forward.py`
- [3D visualization](https://github.com/jonnymaserati/welleng/blob/main/welleng/visual.py): `welleng/visual.py`

### Other components

- **Engineer**

## Connections

- Engineer → Survey model: creates
- Survey model → Curve geometry: computes geometry (evidence: `welleng/survey.py`)
- Engineer → Path connector: designs path
- Path connector → CLC solver: solves CLC (evidence: `welleng/connector.py`)
- Survey model → Error models: computes uncertainty (evidence: `welleng/survey.py`)
- Error models → Tool error engine: dispatches models (evidence: `welleng/error.py`)
- Survey model → Geomagnetic lookup: looks up field (evidence: `welleng/survey.py`)
- Survey model → Well clearance: supplies trajectories (evidence: `welleng/clearance.py`)
- Well clearance → Collision meshes: uses mesh methods (evidence: `welleng/clearance.py`)
- Engineer → Kick tolerance API: calculates kick tolerance
- Kick tolerance API → Analytical kick solver: exposes solver (evidence: `welleng/kick_tolerance/__init__.py`)
- Kick tolerance API → Gas migration: exposes migration check (evidence: `welleng/kick_tolerance/__init__.py`)
- Analytical kick solver → Gas migration: uses migration (evidence: `welleng/kick_tolerance/analytical.py`)
- Gas migration → Real-gas Z factor: uses gas properties (evidence: `welleng/kick_tolerance/migration.py`)
- Real-gas Z factor → CoolProp EOS: offers optional backend (evidence: `welleng/kick_tolerance/gas_z.py`)
- Survey model → Torque and drag: provides trajectory (evidence: `welleng/torque_drag.py`)
- Engineer → Survey data exchange: imports EDM data
- Engineer → Well plan files: loads well plans
- Engineer → WITSML logs: reads log data
- Survey model → Survey interpretation: supports interpretation
- Engineer → 3D visualization: visualizes results
- Survey model → 3D visualization: renders trajectory (evidence: `welleng/visual.py`)
