# rdemaria/lhcoptics architecture

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

- Interactive diagram: https://gitdiagram.com/rdemaria/lhcoptics
- Repository: https://github.com/rdemaria/lhcoptics

## Overview

- JSON/MADX file input → LHCOptics
- LHCOptics → Model interfaces
- Section configurations → Model updates

- LHCSection → LHCIRs
- LHCSection → LHCArcs

- Utility components to main components
- Model interface interactions

##### Specific Features to Highlight

- IR1 through IR8 modules
- Their relationship to LHCIRs class

b) Data Processing Pipeline:
- Input methods (from_json, from_madx, from_dict)
- Processing (strength/knob updates)
- Output methods (to_json, to_madx)

- Model initialization flow
- Optics calculation pipeline
- Data update mechanisms

##### Notes for
- Version dependencies
- Required external packages
- Key configuration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Components
    LHCOptics["LHCOptics (Main Class)"]:::core
    LHCSection["LHCSection (Base Class)"]:::core
    LHCIRs["LHCIRs (Interaction Regions)"]:::core
    LHCArcs["LHCArcs (Arc Sections)"]:::core

    %% Model Integration Layer
    subgraph ModelLayer["Model Integration"]
        MADX["MAD-X Interface"]:::model
        XSuite["XSuite Interface"]:::model
    end

    %% Data Management
    subgraph DataMgmt["Data Management"]
        RepoHandler[("Repository Handler")]:::data
        JsonIO[("JSON I/O")]:::data
        MadxIO[("MADX I/O")]:::data
    end

    %% Utility Components
    subgraph Utils["Utilities"]
        LSAUtil["LSA Utilities"]:::util
        NXCALSUtil["NXCALS Utilities"]:::util
        GenUtil["General Utilities"]:::util
    end

    %% IR Sections
    subgraph IRModules["Interaction Region Modules"]
        IR1["IR1"]:::ir
        IR2["IR2"]:::ir
        IR3["IR3"]:::ir
        IR4["IR4"]:::ir
        IR5["IR5"]:::ir
        IR6["IR6"]:::ir
        IR7["IR7"]:::ir
        IR8["IR8"]:::ir
    end

    %% External Systems
    AccModels["acc-models-lhc"]:::external
    MADXExt["MAD-X System"]:::external
    XSuiteExt["XSuite System"]:::external

    %% Relationships
    LHCSection --> LHCIRs
    LHCSection --> LHCArcs
    LHCOptics --> MADX
    LHCOptics --> XSuite
    LHCOptics --> RepoHandler
    RepoHandler --> JsonIO
    RepoHandler --> MadxIO
    LHCIRs --> IRModules
    MADX --> MADXExt
    XSuite --> XSuiteExt
    RepoHandler --> AccModels

    %% Utility Connections
    LSAUtil --> LHCOptics
    NXCALSUtil --> LHCOptics
    GenUtil --> LHCOptics

    %% Click Events
    click LHCOptics "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/optics.py"
    click LHCSection "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/section.py"
    click LHCIRs "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/irs.py"
    click LHCArcs "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/arcs.py"
    click MADX "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/model_madx.py"
    click XSuite "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/model_xsuite.py"
    click RepoHandler "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/repo.py"
    click LSAUtil "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/lsa_util.py"
    click NXCALSUtil "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/nxcals_util.py"
    click GenUtil "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/utils.py"
    click IR1 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir1.py"
    click IR2 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir2.py"
    click IR3 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir3.py"
    click IR4 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir4.py"
    click IR5 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir5.py"
    click IR6 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir6.py"
    click IR7 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir7.py"
    click IR8 "https://github.com/rdemaria/lhcoptics/blob/main/src/lhcoptics/ir8.py"

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef model fill:#57a773,stroke:#57a773,color:#fff
    classDef data fill:#ff8c42,stroke:#ff8c42,color:#fff
    classDef util fill:#808080,stroke:#808080,color:#fff
    classDef external fill:#845ec2,stroke:#845ec2,color:#fff
    classDef ir fill:#4a90e2,stroke:#4a90e2,color:#fff
```
