# aromanro/hartreefock architecture

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

- Interactive diagram: https://gitdiagram.com/aromanro/hartreefock
- Repository: https://github.com/aromanro/hartreefock

## Overview

##### Project type and purpose
- This is a Windows desktop scientific‐computing application written in C++ using MFC (Document-View).
- It implements the Hartree–Fock/self-consistent field method and related post-HF methods (MP2, DIIS, CCSD, etc.), with a GUI front end for configuring molecules, basis sets and viewing results.

##### File structure
- Top level:
- HartreeFock.sln + .vcxproj files: Visual Studio solution and project (MFC Doc-View).
- HartreeFock/ directory: source code subdivided by function – UI (.cpp/.h for Views, Frames, PropertyPages, Charts); core algorithms (HartreeFockAlgorithm, RestrictedHartreeFock, UnrestrictedHartreeFock, CCSD, etc.); domain model (Atom, Molecule, Basis, Orbitals); data/repositories (DataSets, IntegralsRepository); utilities (MathUtils, ChemUtils, BoysFunctions).
- basis files (.nw, .txt) under HartreeFock/ and resources (.res, bitmaps) – static inputs for basis sets.
- Patterns: MFC Document-View (Doc=HartreeFockDoc, View=HartreeFockView), Repository for integrals, separation into Presentation, Domain, Data layers, and multi-threading (ComputationThread).

##### Key insights from README
- Describes how users instantiate Atom and Molecule objects from the ‘basis’, set coordinates, and invoke RestrictedHartreeFockAlgorithm.
- Mentions support for multiple basis sets in parsed .nw format, and added algorithms (DIIS, MP2, CCSD, CIS, TDHF/RPA).
- Core usage: UI constructs systems::Molecule, calls HartreeFockAlgorithm.Init(&Molecule), then .Calculate().

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        MainFrame["MainFrame"]:::frontend
        View["HartreeFockView"]:::frontend
        Document["HartreeFockDoc"]:::frontend
        Chart["Chart Module"]:::frontend
        subgraph "Property Pages"
            MoleculeProp["MoleculePropertyPage"]:::frontend
            ComputationProp["ComputationPropertyPage"]:::frontend
            PostHFProp["PostHFPropertyPage"]:::frontend
            OptionsSheet["OptionsPropertySheet"]:::frontend
            HFProp["HartreeFockPropertyPage"]:::frontend
        end
    end

    %% Controller / Threading
    subgraph "Controller & Threading"
        ComputationThread["ComputationThread"]:::controller
        HFThread["HartreeFockThread"]:::controller
    end

    %% Core Computation Engine
    subgraph "Core Computation Engine"
        HFAlgorithm["HartreeFockAlgorithm"]:::core
        RestrictedHF["RestrictedHartreeFock"]:::core
        UnrestrictedHF["UnrestrictedHartreeFock"]:::core
        subgraph "Post-HF Methods"
            DIIS["DIIS"]:::core
            CCSD["RestrictedCCSD"]:::core
            CIS["RestrictedConfigurationInteractionSingles"]:::core
        end
    end

    %% Integrals Modules
    subgraph "Integrals Modules"
        GaussianOverlap["GaussianOverlap"]:::core
        GaussianKinetic["GaussianKinetic"]:::core
        GaussianNuclear["GaussianNuclear"]:::core
        GaussianMoment["GaussianMoment"]:::core
        GaussianTwoE["GaussianTwoElectrons"]:::core
        BoysFunction["BoysFunction"]:::core
        BoysFunctions["BoysFunctions"]:::core
    end

    %% Domain Model
    subgraph "Domain Model"
        Atom["Atom"]:::domain
        Molecule["Molecule"]:::domain
        ContractedOrbital["ContractedGaussianOrbital"]:::domain
        PrimitiveShell["PrimitiveShell"]:::domain
        QuantumNumbers["QuantumNumbers"]:::domain
        Tensor["Tensor"]:::domain
        SpinIntRepo["SpinOrbitalsElectronElectronIntegralsRepository"]:::domain
    end

    %% Data Repositories & Resources
    subgraph "Data Repositories & Files"
        DataSets["DataSets"]:::data
        IntegralsRepo["IntegralsRepository"]:::data
        BasisFiles[(Basis Files *.nw, *.txt)]:::data
    end

    %% Utilities
    subgraph "Utilities & Platform"
        MathUtils["MathUtils"]:::util
        ChemUtils["ChemUtils"]:::util
        Constants["Constants"]:::util
        Vector3D["Vector3D"]:::util
        MFC["MFC Runtime"]:::platform
        WinThreads["Win32 Threads"]:::platform
    end

    %% Relationships
    User(["User"]):::external -->|"interacts with"| View
    View -->|"updates"| Document
    Document -->|"requests compute"| ComputationThread
    ComputationThread -->|"spawn"| HFThread
    HFThread -->|"calls"| HFAlgorithm
    HFAlgorithm -->|"uses"| RestrictedHF
    HFAlgorithm -->|"uses"| UnrestrictedHF
    RestrictedHF -->|"post methods"| DIIS
    RestrictedHF -->|"post methods"| CCSD
    RestrictedHF -->|"post methods"| CIS
    HFAlgorithm -->|"loads basis"| DataSets
    HFAlgorithm -->|"caches integrals"| IntegralsRepo
    HFAlgorithm -->|"calls"| GaussianOverlap
    HFAlgorithm -->|"calls"| GaussianKinetic
    HFAlgorithm -->|"calls"| GaussianNuclear
    HFAlgorithm -->|"calls"| GaussianMoment
    HFAlgorithm -->|"calls"| GaussianTwoE
    HFAlgorithm -->|"calls"| BoysFunction
    HFAlgorithm -->|"calls"| BoysFunctions
    HFAlgorithm -->|"manipulates"| Atom
    HFAlgorithm -->|"manipulates"| Molecule
    HFAlgorithm -->|"constructs"| ContractedOrbital
    HFAlgorithm -->|"constructs"| PrimitiveShell
    HFAlgorithm -->|"uses"| QuantumNumbers
    HFAlgorithm -->|"uses"| Tensor
    HFAlgorithm -->|"uses repo"| SpinIntRepo
    HFAlgorithm -->|"uses utils"| MathUtils
    HFAlgorithm -->|"uses utils"| ChemUtils
    HFAlgorithm -->|"uses"| Constants
    HFAlgorithm -->|"uses"| Vector3D
    HFAlgorithm -->|"returns results to"| Document
    Document -->|"renders"| Chart
    Chart -->|"plots"| View
    DataSets -->|"reads files from"| BasisFiles
    ComputationThread -->|"uses"| WinThreads
    HFThread -->|"runs on"| WinThreads
    View -->|"depends on"| MFC
    Document -->|"depends on"| MFC

    %% Click Events
    click MainFrame "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/MainFrm.cpp"
    click View "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/HartreeFockView.cpp"
    click Document "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/HartreeFockDoc.cpp"
    click Chart "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/Chart.cpp"
    click MoleculeProp "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/MoleculePropertyPage.cpp"
    click ComputationProp "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/ComputationPropertyPage.cpp"
    click PostHFProp "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/PostHFProperyPage.cpp"
    click OptionsSheet "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/OptionsPropertySheet.cpp"
    click HFProp "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/HartreeFockPropertyPage.cpp"
    click ComputationThread "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/ComputationThread.cpp"
    click HFThread "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/HartreeFockThread.cpp"
    click HFAlgorithm "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/HartreeFockAlgorithm.cpp"
    click RestrictedHF "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/RestrictedHartreeFock.cpp"
    click UnrestrictedHF "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/UnrestrictedHartreeFock.cpp"
    click DIIS "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/DIIS.h"
    click GaussianOverlap "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/GaussianOverlap.cpp"
    click GaussianKinetic "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/GaussianKinetic.cpp"
    click GaussianNuclear "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/GaussianNuclear.cpp"
    click GaussianMoment "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/GaussianMoment.cpp"
    click GaussianTwoE "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/GaussianTwoElectrons.cpp"
    click BoysFunction "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/BoysFunction.cpp"
    click BoysFunctions "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/BoysFunctions.cpp"
    click Atom "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/Atom.cpp"
    click Molecule "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/Molecule.cpp"
    click ContractedOrbital "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/ContractedGaussianOrbital.cpp"
    click PrimitiveShell "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/PrimitiveShell.cpp"
    click QuantumNumbers "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/QuantumNumbers.cpp"
    click Tensor "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/Tensor.h"
    click SpinIntRepo "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/SpinOrbitalsElectronElectronIntegralsRepository.cpp"
    click DataSets "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/DataSets.cpp"
    click IntegralsRepo "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/IntegralsRepository.cpp"
    click MathUtils "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/MathUtils.cpp"
    click ChemUtils "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/ChemUtils.cpp"
    click Constants "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/Constants.h"
    click Vector3D "https://github.com/aromanro/hartreefock/blob/master/HartreeFock/Vector3D.h"

    %% Styles
    classDef frontend fill:#e0f3ff,stroke:#006bd3,color:#003366
    classDef controller fill:#fff2e0,stroke:#e67300,color:#804000
    classDef core fill:#e0ffe0,stroke:#33aa33,color:#006600
    classDef data fill:#fff9e6,stroke:#e6b800,color:#996600
    classDef util fill:#f2f2f2,stroke:#999999,color:#666666
    classDef platform fill:#dddddd,stroke:#888888,color:#555555
    classDef domain fill:#f9e0ff,stroke:#aa33aa,color:#660066
    classDef external fill:#ffffff,stroke:#000000,color:#000000,stroke-dasharray: 2 2
```
