# biocharmodeling/biocharatomisticmodels architecture

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

- Interactive diagram: https://gitdiagram.com/biocharmodeling/biocharatomisticmodels
- Repository: https://github.com/biocharmodeling/biocharatomisticmodels

## Overview

##### Project Overview and Main Purpose
- The project is centered on constructing atomistic representations of biochar using multiple data sources (e.g., 13C NMR, ultimate analysis, helium density, BPCA yields) and incorporating these into a cross-linked, large-scale molecular simulation.
- It is built mainly using Jupyter notebooks, Python scripts, and visualization via PyMOL – with auxiliary conversion to LAMMPS data files for molecular dynamics simulations.

##### Main Components (Building Blocks)
a. Data Input & Characterization:
– Inputs include experimental characterization data (e.g., ultimate analysis data, 13C NMR) as suggested in the README, and possibly BPCA yields.
– There’s also a BPCA directory containing an Excel file (BPCA_PAH.xlsx) which likely stores data related to the BPCA analysis.
b. Molecular Templates:
– Directories contain numerous molecule files in .mol2 format (aromatic hydrocarbons, ring defects, functional groups). They act as the fundamental building blocks of the biochar model.
– The “functional_groups” directories store various functional group molecules (aldehyde, aniline, hydroxyl groups, etc.).
c. Processing & Modification Modules:
– Several Python scripts (e.g., Get_Atom_Index.py, Get_Atom_Info.py, Get_Atom_Names.py, Get_Object_Names.py, Examine_CNMR.py) are used to extract chemical information, process molecular data, and implement modifications to the base structures.
– Jupyter Notebooks (BPCA.ipynb, Biochar.ipynb) serve as high-level orchestrators, controlling the workflow and visualization.
– Versioned subdirectories (v2, v3) indicate iterations or enhancements in the implementation.
d. Visualization & Conversion Tools:
– PyMOL modules (pymol_module.py, pymol_rpc.py) support the visualization of molecular structures.
– There is conversion from generated PDB files to LAMMPS data files, indicating interaction with the LAMMPS simulation engine.
e. Simulation & Post Processing:
– The README describes a workflow which includes grid-based molecule placement, cross-linking, and molecular dynamics simulation under LAMMPS using a force field for C/H/O/N.
– OVITO is mentioned as the tool for file conversion, so that data transformation is an integral step in the pipeline.
f. Supporting Material:
– Additional directories such as “Cellulose Database,” “Spectral Database,” “XYZ models…” provide extra datasets and models that might be used for validation or alternative structural modeling.

##### Relationships and Data Flow
- The characterization data (experimental inputs) is ingested and then used by the Jupyter Notebooks to select and modify molecular templates.
- Python modules process the libraries of molecules and functional groups by extracting atom indices, names, and other chemical properties.
- The notebooks then combine these building blocks in a stepwise fashion – first placing molecules on a dispersed grid, then cross-linking them, and finally repositioning them closer to mimic actual biochar structures.
- The intermediate results (likely in PDB format) are then fed into LAMMPS (after conversion via OVITO) for relaxation and simulation under controlled conditions (NVT at 298 K).
- PyMOL modules provide a visualization interface for checking intermediate results.

##### Architectural Patterns and Design Principles
– Modular Design: Different directories and scripts handle distinct parts of the process (data parsing, molecule assembly, visualization, simulation input generation).
– Versioning: The v2 and v3 directories indicate an iterative development process where improvements or changes are tracked as separate versions.
– Workflow Orchestration: Jupyter notebooks serve as the orchestration layer connecting data input, processing modules, and simulation workflows.
– Pipeline Strategy: The system is designed as a sequential pipeline from data input, molecule selection/modification, molecular cross-linking, conversion, simulation, and finally visualization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input & Characterization
    subgraph "Data Input & Characterization"
        D1["Characterization Data (Ultimate Analysis, etc.)"]:::data
        D2["BPCA Excel Data"]:::data
        D3a["BPCA README"]:::data
        D3b["BiocharAtomisticBuilder README"]:::data
    end

    %% Molecular Template Library
    subgraph "Molecular Template Library"
        M1["Base Molecules (.mol2)"]:::molecule
        M2["Version-Specific Libraries (v2/v3)"]:::molecule
        M3["Functional Groups (.mol2)"]:::molecule
    end

    %% Processing & Orchestration
    subgraph "Processing & Orchestration"
        %% Python Processing Scripts
        subgraph "Python Scripts"
            P1a["Get_Atom_Index.py"]:::processing
            P1b["Get_Atom_Info.py"]:::processing
            P1c["Get_Atom_Names.py"]:::processing
            P1d["Get_Object_Names.py"]:::processing
            P1e["Examine_CNMR.py"]:::processing
        end
        %% Jupyter Notebooks
        subgraph "Jupyter Notebooks"
            P2a["BPCA.ipynb"]:::processing
            P2b["Biochar.ipynb"]:::processing
        end
    end

    %% Visualization & Conversion Tools
    subgraph "Visualization & Conversion"
        V1["PyMOL Module"]:::visual
        V1b["PyMOL RPC"]:::visual
        V2["Final Molecule PDB (Conversion Input)"]:::visual
    end

    %% Simulation & Post Processing
    subgraph "Simulation & Post Processing"
        S1["LAMMPS Simulation (biochar.pse)"]:::simulation
        S2["Post-Processing (cleanup_failed.sdf)"]:::simulation
    end

    %% Supporting Material
    subgraph "Supporting Material"
        X1["Cellulose Database"]:::support
        X2["Spectral Database"]:::support
        X3["XYZ Models for Char"]:::support
    end

    %% Connections: Data Input and Templates feed into Processing Orchestration
    D1 --- P2a
    D1 --- P2b
    D2 --- P2a
    D2 --- P2b
    D3a --- P2a
    D3a --- P2b
    D3b --- P2a
    D3b --- P2b

    M1 --- P2a
    M1 --- P2b
    M2 --- P2a
    M2 --- P2b
    M3 --- P2a
    M3 --- P2b

    X1 --- P2a
    X2 --- P2a
    X3 --- P2a

    %% Notebooks invoke processing scripts
    P2a --- P1a
    P2a --- P1b
    P2a --- P1c
    P2a --- P1d
    P2a --- P1e
    P2b --- P1a
    P2b --- P1b
    P2b --- P1c
    P2b --- P1d
    P2b --- P1e

    %% Workflow to Visualization and Conversion
    P2a --- V1
    P2b --- V1
    P2a --- V2
    P2b --- V2

    %% Conversion output goes to Simulation then Post Processing
    V2 --- S1
    S1 --- S2

    %% Click Events for Data Input & Characterization
    click D2 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BPCA/BPCA_PAH.xlsx"
    click D3a "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BPCA/README.md"
    click D3b "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/README.md"

    %% Click Events for Molecular Template Library
    click M1 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/benzene.mol2"
    click M2 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder.v2/benzene.mol2"
    click M3 "https://github.com/biocharmodeling/biocharatomisticmodels/tree/main/BiocharAtomisticBuilder/functional_groups"

    %% Click Events for Processing & Orchestration (Python Scripts)
    click P1a "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/Get_Atom_Index.py"
    click P1b "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/Get_Atom_Info.py"
    click P1c "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/Get_Atom_Names.py"
    click P1d "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/Get_Object_Names.py"
    click P1e "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/Examine_CNMR.py"

    %% Click Events for Processing & Orchestration (Jupyter Notebooks)
    click P2a "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/BPCA.ipynb"
    click P2b "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/Biochar.ipynb"

    %% Click Events for Visualization & Conversion Tools
    click V1 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/pymol_module.py"
    click V1b "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/pymol_rpc.py"
    click V2 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/final_molecule.pdb"

    %% Click Events for Simulation & Post Processing
    click S1 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/biochar.pse"
    click S2 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/BiocharAtomisticBuilder/cleanup_failed.sdf"

    %% Click Events for Supporting Material
    click X1 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/Cellulose Database/Database.xlsx"
    click X2 "https://github.com/biocharmodeling/biocharatomisticmodels/blob/main/Spectral Database/README.md"
    click X3 "https://github.com/biocharmodeling/biocharatomisticmodels/tree/main/XYZ_models"

    %% Styles
    classDef data fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef molecule fill:#99FF99,stroke:#333,stroke-width:2px;
    classDef processing fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef visual fill:#FF9999,stroke:#333,stroke-width:2px;
    classDef simulation fill:#CCCCFF,stroke:#333,stroke-width:2px;
    classDef support fill:#FFCCFF,stroke:#333,stroke-width:2px;
```
