# abhijitvshinde/electromagnet architecture

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

- Interactive diagram: https://gitdiagram.com/abhijitvshinde/electromagnet
- Repository: https://github.com/abhijitvshinde/electromagnet

## Overview

This is a Windows desktop control application for electromagnet and VNA experiments. The main workflow is: configure and connect instruments, set the mandatory current limit, optionally load or perform a user-confirmed field calibration, define a field sweep, then ramp and measure each point while plotting and saving results. Safety validation gates current commands; experiment data is saved point-by-point and can also produce combined data and plot exports. The README documents these capabilities; some GUI and driver wiring is represented only where explicitly described.

Main entry points: [`src/gui/app_context.py`](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/app_context.py) (Shared context), [`src/measurement/measurement_controller.py`](https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/measurement_controller.py) (Measurement sequence), [`src/drivers/power_supply.py`](https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/power_supply.py) (Power supply driver), [`src/calibration/calibration_controller.py`](https://github.com/abhijitvshinde/electromagnet/blob/main/src/calibration/calibration_controller.py) (Calibration sequence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["Desktop interface"]
  node_entry["Application entry<br/>[main.py]"]
  node_window["Main window<br/>[main_window.py]"]
  node_context["Shared context<br/>[app_context.py]"]
  node_connection["Connection tab<br/>[connection_tab.py]"]
  node_safety_tab["Safety tab<br/>[safety_tab.py]"]
  node_cal_tab["Calibration tab<br/>[calibration_tab.py]"]
  node_sweep_tab["Sweep tab<br/>[sweep_tab.py]"]
  node_live_tab["Live measurement tab"]
  node_config["Application configuration<br/>[app_config.py]"]
end

subgraph group_experiment["Experiment workflow"]
  node_cal_controller["Calibration sequence"]
  node_cal_manager["Calibration data"]
  node_sweep["Field sweep planning<br/>[sweep.py]"]
  node_measurement["Measurement sequence"]
  node_ramping["Current ramping<br/>[ramping.py]"]
end

subgraph group_instruments["Instrument control"]
  node_supply["Power supply driver<br/>[power_supply.py]"]
  node_vna["VNA driver<br/>[vna.py]"]
  node_base["Instrument transport<br/>[base_instrument.py]"]
  node_simulation["Simulation transports<br/>[simulation.py]"]
end

subgraph group_results["Results and records"]
  node_data["Experiment data manager<br/>[data_manager.py]"]
  node_storage[("Experiment files")]
  node_plotting["Live and export plots<br/>[plot_manager.py]"]
  node_logging["Experiment logging"]
end

subgraph group_safety["Safety controls"]
  node_safety["Current safety manager<br/>[safety_manager.py]"]
  node_voltage["Voltage monitoring<br/>[voltage_monitor.py]"]
end

node_user(("Operator"))
node_hardware(("GPIB instruments"))

node_entry -->|"launches"| node_window
node_window -->|"creates shared state"| node_context
node_context -->|"loads settings"| node_config
node_context -->|"creates"| node_safety
node_context -->|"creates"| node_cal_manager
node_context -->|"creates"| node_data
node_context -->|"creates"| node_plotting
node_context -->|"creates"| node_logging
node_user -->|"selects instruments"| node_connection
node_connection -->|"connects"| node_supply
node_connection -->|"connects"| node_vna
node_supply -->|"uses transport"| node_base
node_vna -->|"uses transport"| node_base
node_base -->|"communicates via GPIB"| node_hardware
node_supply -.->|"uses in simulation"| node_simulation
node_vna -.->|"uses in simulation"| node_simulation
node_user -->|"sets current limit"| node_safety_tab
node_safety_tab -->|"configures"| node_safety
node_safety_tab -->|"starts monitoring"| node_voltage
node_user -->|"loads or enters calibration"| node_cal_tab
node_cal_tab -->|"runs sequence"| node_cal_controller
node_cal_tab -->|"loads and saves points"| node_cal_manager
node_cal_controller -->|"ramps current"| node_ramping
node_cal_controller -->|"commands and reads current"| node_supply
node_cal_controller -->|"records confirmed points"| node_cal_manager
node_user -->|"configures sweep"| node_sweep_tab
node_sweep_tab -->|"generates sequence"| node_sweep
node_sweep_tab -->|"starts measurement"| node_measurement
node_measurement -->|"checks currents"| node_safety
node_measurement -->|"ramps per point"| node_ramping
node_measurement -->|"sets current and reads status"| node_supply
node_measurement -->|"triggers and fetches traces"| node_vna
node_measurement -->|"saves each point"| node_data
node_measurement -->|"updates traces"| node_plotting
node_supply -->|"validates before command"| node_safety
node_data -->|"writes CSV HDF5 metadata"| node_storage
node_data -->|"exports figures and color maps"| node_plotting
node_user -->|"views live traces"| node_live_tab

click node_entry "https://github.com/abhijitvshinde/electromagnet/blob/main/src/main.py"
click node_window "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/main_window.py"
click node_context "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/app_context.py"
click node_connection "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/connection_tab.py"
click node_safety_tab "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/safety_tab.py"
click node_cal_tab "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/calibration_tab.py"
click node_sweep_tab "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/sweep_tab.py"
click node_live_tab "https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/live_measurement_tab.py"
click node_config "https://github.com/abhijitvshinde/electromagnet/blob/main/src/config/app_config.py"
click node_cal_controller "https://github.com/abhijitvshinde/electromagnet/blob/main/src/calibration/calibration_controller.py"
click node_cal_manager "https://github.com/abhijitvshinde/electromagnet/blob/main/src/calibration/calibration_manager.py"
click node_sweep "https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/sweep.py"
click node_measurement "https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/measurement_controller.py"
click node_ramping "https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/ramping.py"
click node_safety "https://github.com/abhijitvshinde/electromagnet/blob/main/src/safety/safety_manager.py"
click node_voltage "https://github.com/abhijitvshinde/electromagnet/blob/main/src/safety/voltage_monitor.py"
click node_supply "https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/power_supply.py"
click node_vna "https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/vna.py"
click node_base "https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/base_instrument.py"
click node_simulation "https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/simulation.py"
click node_data "https://github.com/abhijitvshinde/electromagnet/blob/main/src/data/data_manager.py"
click node_plotting "https://github.com/abhijitvshinde/electromagnet/blob/main/src/plotting/plot_manager.py"
click node_logging "https://github.com/abhijitvshinde/electromagnet/blob/main/src/logging_/experiment_logger.py"

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_entry,node_window,node_context,node_connection,node_safety_tab,node_cal_tab,node_sweep_tab,node_live_tab,node_config toneBlue
class node_cal_controller,node_cal_manager,node_sweep,node_measurement,node_ramping toneAmber
class node_supply,node_vna,node_base,node_simulation toneMint
class node_data,node_storage,node_plotting,node_logging toneRose
class node_safety,node_voltage,node_user,node_hardware toneIndigo
```

## Components

### Desktop interface

- [Application entry](https://github.com/abhijitvshinde/electromagnet/blob/main/src/main.py): `src/main.py`
- [Main window](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/main_window.py): `src/gui/main_window.py`
- [Shared context](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/app_context.py): `src/gui/app_context.py`
- [Connection tab](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/connection_tab.py): `src/gui/tabs/connection_tab.py`
- [Safety tab](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/safety_tab.py): `src/gui/tabs/safety_tab.py`
- [Calibration tab](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/calibration_tab.py): `src/gui/tabs/calibration_tab.py`
- [Sweep tab](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/sweep_tab.py): `src/gui/tabs/sweep_tab.py`
- [Live measurement tab](https://github.com/abhijitvshinde/electromagnet/blob/main/src/gui/tabs/live_measurement_tab.py): `src/gui/tabs/live_measurement_tab.py`
- [Application configuration](https://github.com/abhijitvshinde/electromagnet/blob/main/src/config/app_config.py): `src/config/app_config.py`

### Experiment workflow

- [Calibration sequence](https://github.com/abhijitvshinde/electromagnet/blob/main/src/calibration/calibration_controller.py): `src/calibration/calibration_controller.py`
- [Calibration data](https://github.com/abhijitvshinde/electromagnet/blob/main/src/calibration/calibration_manager.py): `src/calibration/calibration_manager.py`
- [Field sweep planning](https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/sweep.py): `src/measurement/sweep.py`
- [Measurement sequence](https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/measurement_controller.py): `src/measurement/measurement_controller.py`
- [Current ramping](https://github.com/abhijitvshinde/electromagnet/blob/main/src/measurement/ramping.py): `src/measurement/ramping.py`

### Instrument control

- [Power supply driver](https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/power_supply.py): `src/drivers/power_supply.py`
- [VNA driver](https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/vna.py): `src/drivers/vna.py`
- [Instrument transport](https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/base_instrument.py): `src/drivers/base_instrument.py`
- [Simulation transports](https://github.com/abhijitvshinde/electromagnet/blob/main/src/drivers/simulation.py): `src/drivers/simulation.py`

### Results and records

- [Experiment data manager](https://github.com/abhijitvshinde/electromagnet/blob/main/src/data/data_manager.py): `src/data/data_manager.py`
- **Experiment files**
- [Live and export plots](https://github.com/abhijitvshinde/electromagnet/blob/main/src/plotting/plot_manager.py): `src/plotting/plot_manager.py`
- [Experiment logging](https://github.com/abhijitvshinde/electromagnet/blob/main/src/logging_/experiment_logger.py): `src/logging_/experiment_logger.py`

### Safety controls

- [Current safety manager](https://github.com/abhijitvshinde/electromagnet/blob/main/src/safety/safety_manager.py): `src/safety/safety_manager.py`
- [Voltage monitoring](https://github.com/abhijitvshinde/electromagnet/blob/main/src/safety/voltage_monitor.py): `src/safety/voltage_monitor.py`

### Other components

- **Operator**
- **GPIB instruments**

## Connections

- Application entry → Main window: launches
- Main window → Shared context: creates shared state
- Shared context → Application configuration: loads settings
- Shared context → Current safety manager: creates
- Shared context → Calibration data: creates
- Shared context → Experiment data manager: creates
- Shared context → Live and export plots: creates
- Shared context → Experiment logging: creates
- Operator → Connection tab: selects instruments
- Connection tab → Power supply driver: connects
- Connection tab → VNA driver: connects
- Power supply driver → Instrument transport: uses transport
- VNA driver → Instrument transport: uses transport
- Instrument transport → GPIB instruments: communicates via GPIB
- Power supply driver → Simulation transports: uses in simulation
- VNA driver → Simulation transports: uses in simulation
- Operator → Safety tab: sets current limit
- Safety tab → Current safety manager: configures
- Safety tab → Voltage monitoring: starts monitoring
- Operator → Calibration tab: loads or enters calibration
- Calibration tab → Calibration sequence: runs sequence
- Calibration tab → Calibration data: loads and saves points
- Calibration sequence → Current ramping: ramps current
- Calibration sequence → Power supply driver: commands and reads current
- Calibration sequence → Calibration data: records confirmed points
- Operator → Sweep tab: configures sweep
- Sweep tab → Field sweep planning: generates sequence
- Sweep tab → Measurement sequence: starts measurement
- Measurement sequence → Current safety manager: checks currents
- Measurement sequence → Current ramping: ramps per point
- Measurement sequence → Power supply driver: sets current and reads status
- Measurement sequence → VNA driver: triggers and fetches traces
- Measurement sequence → Experiment data manager: saves each point
- Measurement sequence → Live and export plots: updates traces
- Power supply driver → Current safety manager: validates before command
- Experiment data manager → Experiment files: writes CSV HDF5 metadata
- Experiment data manager → Live and export plots: exports figures and color maps
- Operator → Live measurement tab: views live traces
