# sayakdas10/mfit architecture

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

- Interactive diagram: https://gitdiagram.com/sayakdas10/mfit
- Repository: https://github.com/sayakdas10/mfit

## Overview

#### Purpose and entry points
This is a Python thermal simulator for 2.5D/3D multi-chiplet packages. It builds a lumped thermal RC network from layered geometry/material/power inputs, solves transient or steady temperatures using a SuperLU-backed Backward Euler path, and can export discrete state-space (DSS) matrices. Primary CLI: `thermal_RC.py`. Liquid-cooled wafer-scale flow is separately driven by `wafer_liquid/thermal_RC_liquid.py` and `wafer_liquid/run_wafer_16x16.sh`.

#### Input model and configuration boundary
The simulator consumes four user-owned inputs: material YAML, geometry YAML, power-layout YAML, and time-indexed power CSV. `material_prop.yml` provides anisotropic layer properties; geometry supports uniform or explicit nonuniform x/y node placement; power configuration maps sources/blocks to the mesh; traces supply source power over time. Format contract: `INPUT_FORMAT.md`. Representative inputs are under `example_1_uniform_nodes_homogeneous_chiplets/chiplet_geometry_4_chiplets_uniform_nodes.yml` and `example_3_heterogeneous_chiplets/power_dist_config_heterogeneous.yml`.

#### Package and mesh construction
`package_class.py` is the likely top-level physical-package builder, composing layer and node representations from the geometry and material specifications. `layer_class.py` models layer-level discretization/material regions, including chiplet-underlying layers and heterogeneous blocks. `node_class.py` represents thermal nodes and their spatial/physical properties. This stage establishes the node index space used consistently by conductance/capacitance assembly, power mapping, temperature output, and DSS matrices.

#### Power distribution pipeline
`power_class.py` translates configured chiplet/block power sources into per-node thermal inputs, reconciling source layout with layer mesh granularity. `common.py` likely contains shared geometry, mapping, and output utilities. The boundary is explicit: source-level power columns in CSV become a nodal power vector for each simulation interval; heterogeneous configurations can override block materials and define chiplet-specific layouts.

#### RC-system assembly and numerical solve
`thermal_RC.py` orchestrates parsing, package construction, power mapping, simulation mode selection, and outputs. It assembles the thermal ODE/RC model across in-plane and vertical connections, supporting anisotropic conductivity and optionally tuned capacitance. For transient simulation, it advances with Backward Euler; the Python layer depends on a bundled/native C solver interface in `c_files` and the dynamically installed SuperLU library. Steady state follows the same physical system with a steady solve.

#### DSS export and results
When enabled, `thermal_RC.py` derives and writes DSS matrices implementing `T(k+1) = A*T(k) + B*P(k)`, alongside mapped nodal power. Normal simulation emits node temperatures, chiplet averages where valid, floorplans, and optional heatmaps beneath the requested output directory. Example launch wrappers are `example_1_uniform_nodes_homogeneous_chiplets/run1.sh` and `example_2_non_uniform_nodes_homogeneous_chiplets/run2.sh`.

#### Wafer-scale liquid-cooling variant
`wafer_liquid/thermal_RC_liquid.py` and `wafer_liquid/liquid_cooling.py` extend the RC flow with liquid-cooling behavior for wafer-scale systems. `wafer_liquid/generate_wafer_inputs.py` generates scalable geometry, power config, and trace inputs, exemplified by `wafer_liquid/generated/wafer_16x16/`. `wafer_liquid/postprocess_wafer.py` reduces solver outputs into chiplet/module summaries, with committed example results in `wafer_liquid/results/wafer_16x16_steady/wafer_summary/`.

#### External validation and runtime dependencies
Runtime is Python plus native SuperLU shared libraries; Python dependencies are declared in `requirements.txt`. FEM validation/reference artifacts are separated in `FEM_models`, with ANSYS Fluent identified as the external reference simulator rather than a runtime dependency.

Main entry points: [`power_class.py`](https://github.com/sayakdas10/mfit/blob/main/power_class.py) (Nodal power mapping), [`thermal_RC.py`](https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py) (Backward Euler solver), [`wafer_liquid/thermal_RC_liquid.py`](https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/thermal_RC_liquid.py) (Liquid RC entry point), [`package_class.py`](https://github.com/sayakdas10/mfit/blob/main/package_class.py) (Physical package builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Input contract"]
  node_format["Input format<br/>format contract<br/>[INPUT_FORMAT.md]"]
  node_material["Material YAML<br/>user input<br/>[material_prop.yml]"]
  node_geometry["Geometry YAML<br/>user input"]
  node_power_layout["Power layout YAML<br/>user input"]
  node_power_trace["Power trace CSV<br/>user input"]
end

subgraph group_core["Core RC simulator"]
  node_cli["Thermal RC CLI<br/>Python entry point<br/>[thermal_RC.py]"]
  node_package["Physical package builder<br/>package model<br/>[package_class.py]"]
  node_layer["Layer discretization<br/>physical model<br/>[layer_class.py]"]
  node_node["Thermal nodes<br/>physical model<br/>[node_class.py]"]
  node_power_mapper["Nodal power mapping<br/>power pipeline<br/>[power_class.py]"]
  node_rc_assembly["RC system assembly<br/>thermal ODE model<br/>[thermal_RC.py]"]
  node_solver["Backward Euler solver<br/>transient and steady solver<br/>[thermal_RC.py]"]
  node_outputs["Results and DSS export<br/>output pipeline<br/>[thermal_RC.py]"]
end

subgraph group_native["Numerical backend"]
  node_native_solver{{"Native SuperLU interface<br/>C solver backend"}}
end

subgraph group_liquid["Wafer liquid variant"]
  node_liquid_entry["Liquid RC entry point<br/>Python entry point"]
  node_liquid_model["Liquid cooling model<br/>cooling extension<br/>[liquid_cooling.py]"]
  node_wafer_generator["Wafer input generator"]
  node_wafer_postprocess["Wafer postprocessor<br/>result reduction"]
end

subgraph group_validation["Validation"]
  node_fem["FEM reference artifacts<br/>external validation"]
end

node_format -.->|"specifies"| node_material
node_format -.->|"specifies"| node_geometry
node_format -.->|"specifies"| node_power_layout
node_material -->|"material properties"| node_package
node_geometry -->|"geometry and mesh"| node_package
node_package -->|"composes"| node_layer
node_layer -->|"discretizes into"| node_node
node_node -->|"node index space"| node_rc_assembly
node_power_layout -->|"source layout"| node_power_mapper
node_power_trace -->|"source power by interval"| node_power_mapper
node_node -->|"mesh granularity"| node_power_mapper
node_cli -->|"builds"| node_package
node_cli -->|"maps power"| node_power_mapper
node_cli -->|"assembles"| node_rc_assembly
node_power_mapper -->|"nodal P&#40;k&#41;"| node_solver
node_rc_assembly -->|"RC system"| node_solver
node_solver -->|"factorization and solve"| node_native_solver
node_solver -->|"temperatures"| node_outputs
node_power_mapper -->|"mapped nodal power"| node_outputs
node_rc_assembly -->|"optional DSS A/B"| node_outputs
node_wafer_generator -->|"generated wafer inputs"| node_liquid_entry
node_liquid_entry -->|"uses"| node_liquid_model
node_liquid_entry -->|"extends RC solve"| node_solver
node_liquid_entry -->|"wafer outputs"| node_wafer_postprocess
node_fem -.->|"reference comparison"| node_outputs

click node_format "https://github.com/sayakdas10/mfit/blob/main/INPUT_FORMAT.md"
click node_material "https://github.com/sayakdas10/mfit/blob/main/material_prop.yml"
click node_geometry "https://github.com/sayakdas10/mfit/blob/main/example_1_uniform_nodes_homogeneous_chiplets/chiplet_geometry_4_chiplets_uniform_nodes.yml"
click node_power_layout "https://github.com/sayakdas10/mfit/blob/main/example_3_heterogeneous_chiplets/power_dist_config_heterogeneous.yml"
click node_cli "https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py"
click node_package "https://github.com/sayakdas10/mfit/blob/main/package_class.py"
click node_layer "https://github.com/sayakdas10/mfit/blob/main/layer_class.py"
click node_node "https://github.com/sayakdas10/mfit/blob/main/node_class.py"
click node_power_mapper "https://github.com/sayakdas10/mfit/blob/main/power_class.py"
click node_rc_assembly "https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py"
click node_solver "https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py"
click node_outputs "https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py"
click node_native_solver "https://github.com/sayakdas10/mfit/tree/main/c_files"
click node_liquid_entry "https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/thermal_RC_liquid.py"
click node_liquid_model "https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/liquid_cooling.py"
click node_wafer_generator "https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/generate_wafer_inputs.py"
click node_wafer_postprocess "https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/postprocess_wafer.py"
click node_fem "https://github.com/sayakdas10/mfit/tree/main/FEM_models"

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_format,node_material,node_geometry,node_power_layout,node_power_trace toneBlue
class node_cli,node_package,node_layer,node_node,node_power_mapper,node_rc_assembly,node_solver,node_outputs toneAmber
class node_native_solver toneMint
class node_liquid_entry,node_liquid_model,node_wafer_generator,node_wafer_postprocess toneRose
class node_fem toneIndigo
```

## Components

### Input contract

- [Input format](https://github.com/sayakdas10/mfit/blob/main/INPUT_FORMAT.md): format contract · Defines material, geometry, power-layout, and trace inputs. · `INPUT_FORMAT.md`
- [Material YAML](https://github.com/sayakdas10/mfit/blob/main/material_prop.yml): user input · Anisotropic layer properties. · `material_prop.yml`
- [Geometry YAML](https://github.com/sayakdas10/mfit/blob/main/example_1_uniform_nodes_homogeneous_chiplets/chiplet_geometry_4_chiplets_uniform_nodes.yml): user input · Layer geometry and uniform or nonuniform mesh placement. · `example_1_uniform_nodes_homogeneous_chiplets/chiplet_geometry_4_chiplets_uniform_nodes.yml`
- [Power layout YAML](https://github.com/sayakdas10/mfit/blob/main/example_3_heterogeneous_chiplets/power_dist_config_heterogeneous.yml): user input · Maps sources and blocks onto the mesh. · `example_3_heterogeneous_chiplets/power_dist_config_heterogeneous.yml`
- **Power trace CSV**: user input · Time-indexed source power.

### Core RC simulator

- [Thermal RC CLI](https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py): Python entry point · Orchestrates parsing, assembly, solve mode, and output. · `thermal_RC.py`
- [Physical package builder](https://github.com/sayakdas10/mfit/blob/main/package_class.py): package model · Builds the package and shared node index space. · `package_class.py`
- [Layer discretization](https://github.com/sayakdas10/mfit/blob/main/layer_class.py): physical model · Models material regions, underlying layers, and heterogeneous blocks. · `layer_class.py`
- [Thermal nodes](https://github.com/sayakdas10/mfit/blob/main/node_class.py): physical model · Spatial and physical node representation. · `node_class.py`
- [Nodal power mapping](https://github.com/sayakdas10/mfit/blob/main/power_class.py): power pipeline · Converts source-level traces into per-node thermal inputs. · `power_class.py`
- [RC system assembly](https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py): thermal ODE model · Assembles in-plane and vertical conductance and capacitance. · `thermal_RC.py`
- [Backward Euler solver](https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py): transient and steady solver · Advances transient temperatures or solves the steady physical system. · `thermal_RC.py`
- [Results and DSS export](https://github.com/sayakdas10/mfit/blob/main/thermal_RC.py): output pipeline · Writes temperatures, summaries, floorplans, heatmaps, and optional A/B matrices. · `thermal_RC.py`

### Numerical backend

- [Native SuperLU interface](https://github.com/sayakdas10/mfit/tree/main/c_files): C solver backend · Bundled interface backed by installed SuperLU shared libraries. · `c_files`

### Wafer liquid variant

- [Liquid RC entry point](https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/thermal_RC_liquid.py): Python entry point · Runs wafer-scale liquid-cooled thermal flow. · `wafer_liquid/thermal_RC_liquid.py`
- [Liquid cooling model](https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/liquid_cooling.py): cooling extension · Adds liquid-cooling behavior to the RC flow. · `wafer_liquid/liquid_cooling.py`
- [Wafer input generator](https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/generate_wafer_inputs.py): input generator · Generates scalable wafer geometry, power configuration, and traces. · `wafer_liquid/generate_wafer_inputs.py`
- [Wafer postprocessor](https://github.com/sayakdas10/mfit/blob/main/wafer_liquid/postprocess_wafer.py): result reduction · Reduces solver output to chiplet and module summaries. · `wafer_liquid/postprocess_wafer.py`

### Validation

- [FEM reference artifacts](https://github.com/sayakdas10/mfit/tree/main/FEM_models): external validation · ANSYS Fluent reference models, not a runtime dependency. · `FEM_models`

## Connections

- Input format → Material YAML: specifies
- Input format → Geometry YAML: specifies
- Input format → Power layout YAML: specifies
- Material YAML → Physical package builder: material properties
- Geometry YAML → Physical package builder: geometry and mesh
- Physical package builder → Layer discretization: composes
- Layer discretization → Thermal nodes: discretizes into
- Thermal nodes → RC system assembly: node index space
- Power layout YAML → Nodal power mapping: source layout
- Power trace CSV → Nodal power mapping: source power by interval
- Thermal nodes → Nodal power mapping: mesh granularity
- Thermal RC CLI → Physical package builder: builds
- Thermal RC CLI → Nodal power mapping: maps power
- Thermal RC CLI → RC system assembly: assembles
- Nodal power mapping → Backward Euler solver: nodal P(k)
- RC system assembly → Backward Euler solver: RC system
- Backward Euler solver → Native SuperLU interface: factorization and solve
- Backward Euler solver → Results and DSS export: temperatures
- Nodal power mapping → Results and DSS export: mapped nodal power
- RC system assembly → Results and DSS export: optional DSS A/B
- Wafer input generator → Liquid RC entry point: generated wafer inputs
- Liquid RC entry point → Liquid cooling model: uses
- Liquid RC entry point → Backward Euler solver: extends RC solve
- Liquid RC entry point → Wafer postprocessor: wafer outputs
- FEM reference artifacts → Results and DSS export: reference comparison
