# saadatkhan03/spectra-pka architecture

> Architecture diagram of the GitHub repository saadatkhan03/spectra-pka, 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/saadatkhan03/spectra-pka
- Repository: https://github.com/saadatkhan03/spectra-pka

## Overview

SPECTRA-PKA is a command-line Fortran application that computes primary knock-on atom (PKA) spectra from recoil matrices and an irradiation spectrum, then produces channel-specific and summed distributions. Its documented workflow also includes damage-rate evaluation, user-defined output energy grids, stochastic atomistic PKA events, and an optional SDTrimSP BCA interface. Relationships below are based on the README; source excerpts were not available to verify internal call ownership.

Main entry points: [`spectra-pka.f90`](https://github.com/saadatkhan03/spectra-pka/blob/master/spectra-pka.f90) (Program entry), [`tdam.f90`](https://github.com/saadatkhan03/spectra-pka/blob/master/tdam.f90) (Atomistic PKA events), [`collapse_xs2.f90`](https://github.com/saadatkhan03/spectra-pka/blob/master/collapse_xs2.f90) (Cross-section collapse), [`sum_pkas.f90`](https://github.com/saadatkhan03/spectra-pka/blob/master/sum_pkas.f90) (Nuclide and element sums)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and Configuration"]
  node_main["Program entry<br/>[spectra-pka.f90]"]
  node_config["Input configuration<br/>[read_input.f90]"]
  node_io_config["Input/output settings"]
  node_pka_data["Recoil matrices<br/>[read_pka.f90]"]
  node_flux["Irradiation spectrum<br/>[read_flux.f90]"]
  node_fispact_flux["FISPACT flux reader"]
  node_state["Shared run state<br/>[globals.f90]"]
end

subgraph group_spectra["Spectrum Processing"]
  node_collapse["Cross-section collapse<br/>[collapse_xs2.f90]"]
  node_flux_collapse["Flux collapse"]
  node_damage["Damage rates<br/>[accuracy.f90]"]
  node_ngamma["Capture estimate<br/>[ng_estimate.f90]"]
end

subgraph group_results["Results and Aggregation"]
  node_channel_output["Channel distributions"]
  node_global_sums["Global distributions<br/>[global_sums.f90]"]
  node_sums["Nuclide and element sums<br/>[sum_pkas.f90]"]
  node_daughter["Daughter nuclides"]
  node_energy_grid["Output energy grid<br/>[create_configs.f90]"]
end

subgraph group_atomistic["Atomistic and BCA"]
  node_atomistic_events["Atomistic PKA events<br/>[tdam.f90]"]
  node_bcc["BCC lattice<br/>[create_bcc.f90]"]
  node_fcc["FCC lattice<br/>[create_fcc.f90]"]
  node_hcp["HCP lattice<br/>[create_hcp.f90]"]
  node_bca["BCA simulation<br/>[bca.f90]"]
end

node_user(("Command-line user"))
node_sdtrimsp["SDTrimSP"]
node_nuclear_data[("NJOY recoil data")]

node_user -->|"runs"| node_main
node_main -->|"reads settings"| node_config
node_config -.->|"sets I/O options"| node_io_config
node_main -->|"reads recoil data"| node_pka_data
node_nuclear_data -->|"provides matrices"| node_pka_data
node_main -->|"reads spectrum"| node_flux
node_main -.->|"supports flux input"| node_fispact_flux
node_main -->|"collapses channels"| node_collapse
node_flux -->|"weights reactions"| node_collapse
node_collapse -->|"produces distributions"| node_channel_output
node_collapse -->|"evaluates damage"| node_damage
node_main -.->|"estimates capture"| node_ngamma
node_main -->|"accepts custom grid"| node_energy_grid
node_channel_output -->|"aggregates recoils"| node_sums
node_sums -->|"forms global averages"| node_global_sums
node_sums -.->|"accounts for products"| node_daughter
node_main -->|"defines PKA events"| node_atomistic_events
node_atomistic_events -.->|"supports BCC cells"| node_bcc
node_atomistic_events -.->|"supports FCC cells"| node_fcc
node_atomistic_events -->|"supports HCP cells"| node_hcp
node_atomistic_events -->|"simulates cascades"| node_bca
node_bca -->|"interfaces with"| node_sdtrimsp

click node_main "https://github.com/saadatkhan03/spectra-pka/blob/master/spectra-pka.f90"
click node_config "https://github.com/saadatkhan03/spectra-pka/blob/master/read_input.f90"
click node_io_config "https://github.com/saadatkhan03/spectra-pka/blob/master/config_input_output.f90"
click node_pka_data "https://github.com/saadatkhan03/spectra-pka/blob/master/read_pka.f90"
click node_flux "https://github.com/saadatkhan03/spectra-pka/blob/master/read_flux.f90"
click node_fispact_flux "https://github.com/saadatkhan03/spectra-pka/blob/master/read_flux_fispact.f90"
click node_state "https://github.com/saadatkhan03/spectra-pka/blob/master/globals.f90"
click node_collapse "https://github.com/saadatkhan03/spectra-pka/blob/master/collapse_xs2.f90"
click node_flux_collapse "https://github.com/saadatkhan03/spectra-pka/blob/master/collapse_fluxes.f90"
click node_damage "https://github.com/saadatkhan03/spectra-pka/blob/master/accuracy.f90"
click node_ngamma "https://github.com/saadatkhan03/spectra-pka/blob/master/ng_estimate.f90"
click node_channel_output "https://github.com/saadatkhan03/spectra-pka/blob/master/output_sum_pkas.f90"
click node_global_sums "https://github.com/saadatkhan03/spectra-pka/blob/master/global_sums.f90"
click node_sums "https://github.com/saadatkhan03/spectra-pka/blob/master/sum_pkas.f90"
click node_daughter "https://github.com/saadatkhan03/spectra-pka/blob/master/define_daughter.f90"
click node_energy_grid "https://github.com/saadatkhan03/spectra-pka/blob/master/create_configs.f90"
click node_atomistic_events "https://github.com/saadatkhan03/spectra-pka/blob/master/tdam.f90"
click node_bcc "https://github.com/saadatkhan03/spectra-pka/blob/master/create_bcc.f90"
click node_fcc "https://github.com/saadatkhan03/spectra-pka/blob/master/create_fcc.f90"
click node_hcp "https://github.com/saadatkhan03/spectra-pka/blob/master/create_hcp.f90"
click node_bca "https://github.com/saadatkhan03/spectra-pka/blob/master/bca.f90"

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_main,node_config,node_io_config,node_pka_data,node_flux,node_fispact_flux,node_state,node_user toneBlue
class node_collapse,node_flux_collapse,node_damage,node_ngamma,node_nuclear_data toneAmber
class node_channel_output,node_global_sums,node_sums,node_daughter,node_energy_grid toneMint
class node_atomistic_events,node_bcc,node_fcc,node_hcp,node_bca toneRose
class node_sdtrimsp toneIndigo
```

## Components

### Inputs and Configuration

- [Program entry](https://github.com/saadatkhan03/spectra-pka/blob/master/spectra-pka.f90): `spectra-pka.f90`
- [Input configuration](https://github.com/saadatkhan03/spectra-pka/blob/master/read_input.f90): `read_input.f90`
- [Input/output settings](https://github.com/saadatkhan03/spectra-pka/blob/master/config_input_output.f90): `config_input_output.f90`
- [Recoil matrices](https://github.com/saadatkhan03/spectra-pka/blob/master/read_pka.f90): `read_pka.f90`
- [Irradiation spectrum](https://github.com/saadatkhan03/spectra-pka/blob/master/read_flux.f90): `read_flux.f90`
- [FISPACT flux reader](https://github.com/saadatkhan03/spectra-pka/blob/master/read_flux_fispact.f90): `read_flux_fispact.f90`
- [Shared run state](https://github.com/saadatkhan03/spectra-pka/blob/master/globals.f90): `globals.f90`

### Spectrum Processing

- [Cross-section collapse](https://github.com/saadatkhan03/spectra-pka/blob/master/collapse_xs2.f90): `collapse_xs2.f90`
- [Flux collapse](https://github.com/saadatkhan03/spectra-pka/blob/master/collapse_fluxes.f90): `collapse_fluxes.f90`
- [Damage rates](https://github.com/saadatkhan03/spectra-pka/blob/master/accuracy.f90): `accuracy.f90`
- [Capture estimate](https://github.com/saadatkhan03/spectra-pka/blob/master/ng_estimate.f90): `ng_estimate.f90`

### Results and Aggregation

- [Channel distributions](https://github.com/saadatkhan03/spectra-pka/blob/master/output_sum_pkas.f90): `output_sum_pkas.f90`
- [Global distributions](https://github.com/saadatkhan03/spectra-pka/blob/master/global_sums.f90): `global_sums.f90`
- [Nuclide and element sums](https://github.com/saadatkhan03/spectra-pka/blob/master/sum_pkas.f90): `sum_pkas.f90`
- [Daughter nuclides](https://github.com/saadatkhan03/spectra-pka/blob/master/define_daughter.f90): `define_daughter.f90`
- [Output energy grid](https://github.com/saadatkhan03/spectra-pka/blob/master/create_configs.f90): `create_configs.f90`

### Atomistic and BCA

- [Atomistic PKA events](https://github.com/saadatkhan03/spectra-pka/blob/master/tdam.f90): `tdam.f90`
- [BCC lattice](https://github.com/saadatkhan03/spectra-pka/blob/master/create_bcc.f90): `create_bcc.f90`
- [FCC lattice](https://github.com/saadatkhan03/spectra-pka/blob/master/create_fcc.f90): `create_fcc.f90`
- [HCP lattice](https://github.com/saadatkhan03/spectra-pka/blob/master/create_hcp.f90): `create_hcp.f90`
- [BCA simulation](https://github.com/saadatkhan03/spectra-pka/blob/master/bca.f90): `bca.f90`

### Other components

- **Command-line user**
- **SDTrimSP**
- **NJOY recoil data**

## Connections

- Command-line user → Program entry: runs (evidence: `README.md`)
- Program entry → Input configuration: reads settings (evidence: `README.md`)
- Input configuration → Input/output settings: sets I/O options
- Program entry → Recoil matrices: reads recoil data (evidence: `README.md`)
- NJOY recoil data → Recoil matrices: provides matrices (evidence: `README.md`)
- Program entry → Irradiation spectrum: reads spectrum (evidence: `README.md`)
- Program entry → FISPACT flux reader: supports flux input
- Program entry → Cross-section collapse: collapses channels (evidence: `README.md`)
- Irradiation spectrum → Cross-section collapse: weights reactions (evidence: `README.md`)
- Cross-section collapse → Channel distributions: produces distributions (evidence: `README.md`)
- Cross-section collapse → Damage rates: evaluates damage (evidence: `README.md`)
- Program entry → Capture estimate: estimates capture
- Program entry → Output energy grid: accepts custom grid (evidence: `README.md`)
- Channel distributions → Nuclide and element sums: aggregates recoils (evidence: `README.md`)
- Nuclide and element sums → Global distributions: forms global averages (evidence: `README.md`)
- Nuclide and element sums → Daughter nuclides: accounts for products
- Program entry → Atomistic PKA events: defines PKA events (evidence: `README.md`)
- Atomistic PKA events → BCC lattice: supports BCC cells
- Atomistic PKA events → FCC lattice: supports FCC cells
- Atomistic PKA events → HCP lattice: supports HCP cells (evidence: `README.md`)
- Atomistic PKA events → BCA simulation: simulates cascades (evidence: `README.md`)
- BCA simulation → SDTrimSP: interfaces with (evidence: `README.md`)
