# santhosh-omlabs/fragmented-mol-simulation architecture

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

- Interactive diagram: https://gitdiagram.com/santhosh-omlabs/fragmented-mol-simulation
- Repository: https://github.com/santhosh-omlabs/fragmented-mol-simulation

## Overview

fragsim is a research tutorial and runtime for fragment-based sample-based quantum diagonalization (SQD) in small-molecule chemistry. The main workflow builds an ammonia reference, forms atom-tagged fragment-and-bath cluster Hamiltonians, proposes electron configurations with a CCSD-informed LUCJ circuit, samples them, and classically diagonalizes the selected subspace to estimate fragment energies. Separate branches study whole-molecule SQD, water-dimer fragmentation, hardware execution and cost, and matched-size classical baselines. Several subsystem links are documented in the README; unsampled implementations are represented only at their supported paths.

Main entry points: [`src/fragsim/matched.py`](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/matched.py) (Matched-size study), [`src/fragsim/sqd_circuit.py`](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd_circuit.py) (LUCJ circuit), [`src/fragsim/embedding.py`](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/embedding.py) (Atom basis and bath), [`src/fragsim/sqd.py`](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd.py) (Subspace diagonalization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chemistry["Molecular chemistry"]
  node_nh3["Ammonia setup<br/>[molecule.py]"]
  node_water["Water systems<br/>[water.py]"]
end

subgraph group_embedding["Fragment embedding"]
  node_basis_bath["Atom basis and bath<br/>[embedding.py]"]
  node_cluster["Cluster Hamiltonian<br/>[solver.py]"]
  node_fragment_energy["Fragment energy<br/>[solver.py]"]
end

subgraph group_sqd["SQD computation"]
  node_lucj["LUCJ circuit<br/>[sqd_circuit.py]"]
  node_sampling["Bitstring sampling<br/>[sampling.py]"]
  node_recovery["Configuration recovery<br/>[sqd.py]"]
  node_diagonalize["Subspace diagonalization<br/>[sqd.py]"]
end

subgraph group_studies["Comparative studies"]
  node_ladder["Fragment-size study<br/>[ladder.py]"]
  node_matched["Matched-size study<br/>[matched.py]"]
  node_whole["Whole-molecule SQD<br/>[whole_molecule.py]"]
  node_water_cut["Water fragment study<br/>[water_cut.py]"]
  node_schedule["Shot scheduling model<br/>[schedule.py]"]
end

subgraph group_hardware["Hardware pathways"]
  node_hwfriendly["Hardware-friendly circuits<br/>[hwfriendly.py]"]
  node_ibm["IBM job workflow<br/>[ibm_run.py]"]
  node_komenco_run["Komenco run workflow<br/>[komenco_run.py]"]
  node_komenco["Komenco gateway client<br/>[komenco.py]"]
end

node_researcher(("Researcher"))
node_ibm_service{{"IBM Quantum Runtime"}}
node_gateway{{"Komenco gateway"}}

node_researcher -->|"sets up"| node_nh3
node_nh3 -->|"provides molecule"| node_basis_bath
node_basis_bath -->|"forms cluster"| node_cluster
node_cluster -->|"supplies integrals"| node_lucj
node_lucj -->|"generates samples"| node_sampling
node_sampling -->|"returns bitstrings"| node_recovery
node_recovery -->|"selects patterns"| node_diagonalize
node_diagonalize -->|"yields cluster state"| node_fragment_energy
node_cluster -->|"defines energy share"| node_fragment_energy
node_fragment_energy -->|"compares fragment sizes"| node_ladder
node_researcher -->|"studies water"| node_water
node_water -->|"defines geometries"| node_water_cut
node_water_cut -->|"uses embedding"| node_basis_bath
node_researcher -->|"compares methods"| node_matched
node_matched -->|"builds fragment basis"| node_basis_bath
node_matched -->|"builds cluster"| node_cluster
node_matched -->|"ranks circuit strings"| node_lucj
node_matched -->|"samples noisy circuit"| node_sampling
node_matched -->|"solves selected strings"| node_diagonalize
node_researcher -->|"runs whole-molecule study"| node_whole
node_whole -->|"submits jobs"| node_ibm_service
node_whole -->|"analyses sampled counts"| node_diagonalize
node_researcher -->|"runs hardware study"| node_ibm
node_ibm -->|"submits circuits"| node_ibm_service
node_ibm -->|"builds circuit"| node_lucj
node_researcher -->|"runs gateway study"| node_komenco_run
node_komenco_run -->|"uses client"| node_komenco
node_komenco -->|"posts circuits"| node_gateway
node_komenco_run -->|"analyses samples"| node_diagonalize
node_researcher -->|"evaluates circuit costs"| node_hwfriendly
node_hwfriendly -->|"routes for backend"| node_ibm_service
node_hwfriendly -->|"compares circuit variants"| node_lucj
node_researcher -->|"models execution cost"| node_schedule
node_schedule -->|"constructs clusters"| node_basis_bath
node_schedule -->|"estimates circuit cost"| node_lucj
node_whole -->|"compares baselines"| node_matched

click node_nh3 "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/molecule.py"
click node_water "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/water.py"
click node_basis_bath "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/embedding.py"
click node_cluster "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/solver.py"
click node_fragment_energy "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/solver.py"
click node_lucj "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd_circuit.py"
click node_sampling "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sampling.py"
click node_recovery "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd.py"
click node_diagonalize "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd.py"
click node_ladder "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/ladder.py"
click node_matched "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/matched.py"
click node_whole "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/whole_molecule.py"
click node_water_cut "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/water_cut.py"
click node_schedule "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/schedule.py"
click node_hwfriendly "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/hwfriendly.py"
click node_ibm "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/ibm_run.py"
click node_komenco_run "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/komenco_run.py"
click node_komenco "https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/backends/komenco.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_nh3,node_water toneBlue
class node_basis_bath,node_cluster,node_fragment_energy toneAmber
class node_lucj,node_sampling,node_recovery,node_diagonalize toneMint
class node_ladder,node_matched,node_whole,node_water_cut,node_schedule toneRose
class node_hwfriendly,node_ibm,node_komenco_run,node_komenco,node_researcher,node_ibm_service,node_gateway toneIndigo
```

## Components

### Molecular chemistry

- [Ammonia setup](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/molecule.py): `src/fragsim/molecule.py`
- [Water systems](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/water.py): `src/fragsim/water.py`

### Fragment embedding

- [Atom basis and bath](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/embedding.py): `src/fragsim/embedding.py`
- [Cluster Hamiltonian](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/solver.py): `src/fragsim/solver.py`
- [Fragment energy](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/solver.py): `src/fragsim/solver.py`

### SQD computation

- [LUCJ circuit](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd_circuit.py): `src/fragsim/sqd_circuit.py`
- [Bitstring sampling](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sampling.py): `src/fragsim/sampling.py`
- [Configuration recovery](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd.py): `src/fragsim/sqd.py`
- [Subspace diagonalization](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/sqd.py): `src/fragsim/sqd.py`

### Comparative studies

- [Fragment-size study](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/ladder.py): `src/fragsim/ladder.py`
- [Matched-size study](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/matched.py): `src/fragsim/matched.py`
- [Whole-molecule SQD](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/whole_molecule.py): `src/fragsim/whole_molecule.py`
- [Water fragment study](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/water_cut.py): `src/fragsim/water_cut.py`
- [Shot scheduling model](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/schedule.py): `src/fragsim/schedule.py`

### Hardware pathways

- [Hardware-friendly circuits](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/hwfriendly.py): `src/fragsim/hwfriendly.py`
- [IBM job workflow](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/ibm_run.py): `src/fragsim/ibm_run.py`
- [Komenco run workflow](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/komenco_run.py): `src/fragsim/komenco_run.py`
- [Komenco gateway client](https://github.com/santhosh-omlabs/fragmented-mol-simulation/blob/main/src/fragsim/backends/komenco.py): `src/fragsim/backends/komenco.py`

### Other components

- **Researcher**
- **IBM Quantum Runtime**
- **Komenco gateway**

## Connections

- Researcher → Ammonia setup: sets up (evidence: `README.md`)
- Ammonia setup → Atom basis and bath: provides molecule (evidence: `README.md`)
- Atom basis and bath → Cluster Hamiltonian: forms cluster (evidence: `README.md`)
- Cluster Hamiltonian → LUCJ circuit: supplies integrals (evidence: `README.md`)
- LUCJ circuit → Bitstring sampling: generates samples (evidence: `README.md`)
- Bitstring sampling → Configuration recovery: returns bitstrings (evidence: `README.md`)
- Configuration recovery → Subspace diagonalization: selects patterns (evidence: `src/fragsim/sqd.py`)
- Subspace diagonalization → Fragment energy: yields cluster state (evidence: `src/fragsim/sqd.py`)
- Cluster Hamiltonian → Fragment energy: defines energy share (evidence: `src/fragsim/solver.py`)
- Fragment energy → Fragment-size study: compares fragment sizes (evidence: `src/fragsim/ladder.py`)
- Researcher → Water systems: studies water (evidence: `README.md`)
- Water systems → Water fragment study: defines geometries (evidence: `src/fragsim/water_cut.py`)
- Water fragment study → Atom basis and bath: uses embedding (evidence: `src/fragsim/water_cut.py`)
- Researcher → Matched-size study: compares methods (evidence: `README.md`)
- Matched-size study → Atom basis and bath: builds fragment basis (evidence: `src/fragsim/matched.py`)
- Matched-size study → Cluster Hamiltonian: builds cluster (evidence: `src/fragsim/matched.py`)
- Matched-size study → LUCJ circuit: ranks circuit strings (evidence: `src/fragsim/matched.py`)
- Matched-size study → Bitstring sampling: samples noisy circuit (evidence: `src/fragsim/matched.py`)
- Matched-size study → Subspace diagonalization: solves selected strings (evidence: `src/fragsim/matched.py`)
- Researcher → Whole-molecule SQD: runs whole-molecule study (evidence: `README.md`)
- Whole-molecule SQD → IBM Quantum Runtime: submits jobs (evidence: `src/fragsim/whole_molecule.py`)
- Whole-molecule SQD → Subspace diagonalization: analyses sampled counts (evidence: `src/fragsim/whole_molecule.py`)
- Researcher → IBM job workflow: runs hardware study (evidence: `README.md`)
- IBM job workflow → IBM Quantum Runtime: submits circuits (evidence: `src/fragsim/ibm_run.py`)
- IBM job workflow → LUCJ circuit: builds circuit (evidence: `src/fragsim/ibm_run.py`)
- Researcher → Komenco run workflow: runs gateway study (evidence: `README.md`)
- Komenco run workflow → Komenco gateway client: uses client (evidence: `src/fragsim/komenco_run.py`)
- Komenco gateway client → Komenco gateway: posts circuits (evidence: `src/fragsim/backends/komenco.py`)
- Komenco run workflow → Subspace diagonalization: analyses samples (evidence: `src/fragsim/komenco_run.py`)
- Researcher → Hardware-friendly circuits: evaluates circuit costs (evidence: `README.md`)
- Hardware-friendly circuits → IBM Quantum Runtime: routes for backend (evidence: `src/fragsim/hwfriendly.py`)
- Hardware-friendly circuits → LUCJ circuit: compares circuit variants (evidence: `src/fragsim/hwfriendly.py`)
- Researcher → Shot scheduling model: models execution cost (evidence: `README.md`)
- Shot scheduling model → Atom basis and bath: constructs clusters (evidence: `src/fragsim/schedule.py`)
- Shot scheduling model → LUCJ circuit: estimates circuit cost (evidence: `src/fragsim/schedule.py`)
- Whole-molecule SQD → Matched-size study: compares baselines (evidence: `src/fragsim/whole_molecule.py`)
