# tuhh-tvt/opencosmo-rs_cpp architecture

> Architecture diagram of the GitHub repository tuhh-tvt/opencosmo-rs_cpp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tuhh-tvt/opencosmo-rs_cpp
- Repository: https://github.com/tuhh-tvt/opencosmo-rs_cpp

## Overview

openCOSMO-RS is a C++ implementation of the COSMO-RS thermodynamic model exposed through a dictionary-based Python extension and a standalone JSON CLI. The main workflow loads parameters and COSMO molecule files, prepares segment data, registers compositions and reference states, computes model interactions and thermodynamic results, then returns them through the selected interface. The README documents the Python lifecycle and CLI capabilities; sampled excerpts and the SOURCE INDEX support the principal module relationships, but do not expose every internal calculation call.

Main entry points: [`code/bindings_forPython.cpp`](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forPython.cpp) (Python API), [`code/bindings_forCLI.cpp`](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forCLI.cpp) (JSON CLI), [`code/core_functions.hpp`](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/core_functions.hpp) (Thermodynamic solver), [`code/COSMOfile_functions.hpp`](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/COSMOfile_functions.hpp) (COSMO reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_python_api["Python API"]
  node_cli_api["JSON CLI"]
  node_json_codec["JSON codec<br/>[json.hpp]"]
  node_result_output["Result output"]
end

subgraph group_inputs["Input preparation"]
  node_cosmo_reader["COSMO reader"]
  node_parameters["Model parameters<br/>[types.hpp]"]
  node_molecule_segments["Molecule segments<br/>[core_functions.hpp]"]
  node_calculation_setup["Calculation setup"]
end

subgraph group_model["COSMO-RS model"]
  node_interaction_matrix["Interaction matrix"]
  node_thermodynamic_solver["Thermodynamic solver<br/>[core_functions.hpp]"]
  node_contact_properties["Contact properties"]
end

subgraph group_support["Runtime support"]
  node_simd_backend["SIMD backend<br/>[simd.hpp]"]
  node_shared_state["Shared state<br/>[general.hpp]"]
  node_helpers["Parsing helpers"]
end

node_python_user(("Python caller"))
node_cli_user(("CLI user"))

node_python_user -->|"calls lifecycle"| node_python_api
node_python_api -->|"uses state"| node_shared_state
node_python_api -->|"loads parameters"| node_parameters
node_python_api -->|"loads molecules"| node_cosmo_reader
node_python_api -->|"registers calculations"| node_calculation_setup
node_python_api -->|"runs calculations"| node_thermodynamic_solver
node_cli_user -->|"provides JSON"| node_cli_api
node_cli_api -->|"parses JSON"| node_json_codec
node_cli_api -->|"uses state"| node_shared_state
node_cli_api -->|"loads molecules"| node_cosmo_reader
node_cli_api -->|"runs calculations"| node_thermodynamic_solver
node_cli_api -->|"writes results"| node_result_output
node_cosmo_reader -->|"uses parsing"| node_helpers
node_thermodynamic_solver -->|"prepares segments"| node_molecule_segments
node_thermodynamic_solver -->|"uses interactions"| node_interaction_matrix
node_thermodynamic_solver -->|"computes properties"| node_contact_properties
node_thermodynamic_solver -->|"uses vectorization"| node_simd_backend
node_interaction_matrix -->|"uses helpers"| node_helpers
node_shared_state -->|"defines state"| node_parameters

click node_python_api "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forPython.cpp"
click node_cli_api "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forCLI.cpp"
click node_json_codec "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/nlohmann/json.hpp"
click node_cosmo_reader "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/COSMOfile_functions.hpp"
click node_parameters "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/types.hpp"
click node_molecule_segments "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/core_functions.hpp"
click node_calculation_setup "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forPython.cpp"
click node_interaction_matrix "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/interaction_matrix.hpp"
click node_thermodynamic_solver "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/core_functions.hpp"
click node_contact_properties "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/contact_statistics.hpp"
click node_result_output "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forCLI.cpp"
click node_simd_backend "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/simd.hpp"
click node_shared_state "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/general.hpp"
click node_helpers "https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/helper_functions.hpp"

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_python_api,node_cli_api,node_json_codec,node_result_output,node_cli_user toneBlue
class node_cosmo_reader,node_parameters,node_molecule_segments,node_calculation_setup toneAmber
class node_interaction_matrix,node_thermodynamic_solver,node_contact_properties toneMint
class node_simd_backend,node_shared_state,node_helpers toneRose
class node_python_user toneIndigo
```

## Components

### User interfaces

- [Python API](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forPython.cpp): `code/bindings_forPython.cpp`
- [JSON CLI](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forCLI.cpp): `code/bindings_forCLI.cpp`
- [JSON codec](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/nlohmann/json.hpp): `nlohmann/json.hpp`
- [Result output](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forCLI.cpp): `code/bindings_forCLI.cpp`

### Input preparation

- [COSMO reader](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/COSMOfile_functions.hpp): `code/COSMOfile_functions.hpp`
- [Model parameters](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/types.hpp): `code/types.hpp`
- [Molecule segments](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/core_functions.hpp): `code/core_functions.hpp`
- [Calculation setup](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/bindings_forPython.cpp): `code/bindings_forPython.cpp`

### COSMO-RS model

- [Interaction matrix](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/interaction_matrix.hpp): `code/interaction_matrix.hpp`
- [Thermodynamic solver](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/core_functions.hpp): `code/core_functions.hpp`
- [Contact properties](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/contact_statistics.hpp): `code/contact_statistics.hpp`

### Runtime support

- [SIMD backend](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/simd.hpp): `code/simd.hpp`
- [Shared state](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/general.hpp): `code/general.hpp`
- [Parsing helpers](https://github.com/tuhh-tvt/opencosmo-rs_cpp/blob/main/code/helper_functions.hpp): `code/helper_functions.hpp`

### Other components

- **Python caller**
- **CLI user**

## Connections

- Python caller → Python API: calls lifecycle (evidence: `README.md`)
- Python API → Shared state: uses state (evidence: `code/bindings_forPython.cpp`)
- Python API → Model parameters: loads parameters (evidence: `code/bindings_forPython.cpp`)
- Python API → COSMO reader: loads molecules (evidence: `README.md`)
- Python API → Calculation setup: registers calculations (evidence: `README.md`)
- Python API → Thermodynamic solver: runs calculations (evidence: `README.md`)
- CLI user → JSON CLI: provides JSON (evidence: `README.md`)
- JSON CLI → JSON codec: parses JSON (evidence: `code/bindings_forCLI.cpp`)
- JSON CLI → Shared state: uses state (evidence: `code/bindings_forCLI.cpp`)
- JSON CLI → COSMO reader: loads molecules (evidence: `code/bindings_forCLI.cpp`)
- JSON CLI → Thermodynamic solver: runs calculations (evidence: `code/bindings_forCLI.cpp`)
- JSON CLI → Result output: writes results (evidence: `README.md`)
- COSMO reader → Parsing helpers: uses parsing (evidence: `code/COSMOfile_functions.hpp`)
- Thermodynamic solver → Molecule segments: prepares segments (evidence: `code/core_functions.hpp`)
- Thermodynamic solver → Interaction matrix: uses interactions (evidence: `code/core_functions.hpp`)
- Thermodynamic solver → Contact properties: computes properties (evidence: `code/core_functions.hpp`)
- Thermodynamic solver → SIMD backend: uses vectorization (evidence: `code/core_functions.hpp`)
- Interaction matrix → Parsing helpers: uses helpers (evidence: `code/interaction_matrix.hpp`)
- Shared state → Model parameters: defines state (evidence: `code/general.hpp`)
