# eomys/pyleecan architecture

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

- Interactive diagram: https://gitdiagram.com/eomys/pyleecan
- Repository: https://github.com/eomys/pyleecan

## Overview

PYLEECAN is a multiphysics design and simulation framework for electrical machines and drives. Its main user workflow is to define a machine and materials, run electrical or field simulation, inspect calculated outputs, and optionally optimize or sweep design variables. The graph also preserves documented geometry import, meshing, loss-model, and GUI capabilities. Several subsystem links are documented in the README rather than shown in sampled implementation; those edges cite the README, and unsampled internals are not asserted.

Main entry points: [`pyleecan/Classes/MachineSIPMSM.py`](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/MachineSIPMSM.py) (Machine models), [`pyleecan/Classes/Output.py`](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Output.py) (Simulation outputs), [`pyleecan/Methods/Simulation/MagFEMM/solve_FEMM.py`](https://github.com/eomys/pyleecan/blob/master/pyleecan/Methods/Simulation/MagFEMM/solve_FEMM.py) (FEMM analysis), [`pyleecan/run_GUI.py`](https://github.com/eomys/pyleecan/blob/master/pyleecan/run_GUI.py) (Desktop GUI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_design["Machine design"]
  node_machine["Machine models<br/>[MachineSIPMSM.py]"]
  node_lamination["Lamination geometry<br/>[Lamination.py]"]
  node_geometry["Geometry operations"]
  node_winding["Winding models<br/>[gen_phase_list.py]"]
  node_dxf["DXF import<br/>[DXF_Hole.py]"]
  node_materials["Material models<br/>[Material.py]"]
end

subgraph group_simulation["Simulation"]
  node_femm["FEMM analysis<br/>[solve_FEMM.py]"]
  node_elmer["Elmer analysis<br/>[solve_FEA.py]"]
  node_gmsh["GMSH meshing<br/>[draw_GMSH.py]"]
  node_electrical["Electrical models<br/>[Electrical.py]"]
  node_losses["Loss models<br/>[Loss.py]"]
  node_sweep["Parameter sweep<br/>[VarSimu.py]"]
end

subgraph group_results["Results and analysis"]
  node_outputs["Simulation outputs<br/>[Output.py]"]
  node_plot["Plotting"]
  node_persistence["Save and load<br/>[load.py]"]
end

subgraph group_optimization["Optimization"]
  node_optimization["Design optimization<br/>[OptiProblem.py]"]
end

subgraph group_interface["User interface"]
  node_gui["Desktop GUI<br/>[run_GUI.py]"]
  node_setup["Machine setup<br/>[DMachineSetup.py]"]
  node_material_ui["Material library<br/>[DMatLib.py]"]
end

node_user(("Engineer"))

node_user -->|"launches"| node_gui
node_gui -->|"opens setup"| node_setup
node_gui -->|"opens library"| node_material_ui
node_setup -.->|"configures"| node_machine
node_material_ui -->|"edits materials"| node_materials
node_machine -.->|"comprises"| node_lamination
node_lamination -.->|"builds geometry"| node_geometry
node_dxf -->|"imports shapes"| node_lamination
node_winding -.->|"supports winding"| node_machine
node_machine -.->|"simulates magnetics"| node_femm
node_machine -->|"supplies machine"| node_elmer
node_machine -->|"meshes geometry"| node_gmsh
node_machine -.->|"solves circuits"| node_electrical
node_femm -.->|"feeds loss models"| node_losses
node_machine -.->|"varies parameters"| node_sweep
node_machine -.->|"optimizes design"| node_optimization
node_femm -.->|"produces results"| node_outputs
node_elmer -.->|"produces results"| node_outputs
node_electrical -.->|"produces results"| node_outputs
node_outputs -.->|"visualizes results"| node_plot
node_outputs -.->|"saves results"| node_persistence

click node_gui "https://github.com/eomys/pyleecan/blob/master/pyleecan/run_GUI.py"
click node_setup "https://github.com/eomys/pyleecan/blob/master/pyleecan/GUI/Dialog/DMachineSetup/DMachineSetup.py"
click node_material_ui "https://github.com/eomys/pyleecan/blob/master/pyleecan/GUI/Dialog/DMatLib/DMatLib.py"
click node_machine "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/MachineSIPMSM.py"
click node_lamination "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Lamination.py"
click node_geometry "https://github.com/eomys/pyleecan/tree/master/pyleecan/Functions/Geometry"
click node_winding "https://github.com/eomys/pyleecan/blob/master/pyleecan/Functions/Winding/gen_phase_list.py"
click node_dxf "https://github.com/eomys/pyleecan/blob/master/pyleecan/GUI/Dxf/DXF_Hole.py"
click node_materials "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Material.py"
click node_femm "https://github.com/eomys/pyleecan/blob/master/pyleecan/Methods/Simulation/MagFEMM/solve_FEMM.py"
click node_elmer "https://github.com/eomys/pyleecan/blob/master/pyleecan/Methods/Simulation/MagElmer/solve_FEA.py"
click node_gmsh "https://github.com/eomys/pyleecan/blob/master/pyleecan/Functions/GMSH/draw_GMSH.py"
click node_electrical "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Electrical.py"
click node_losses "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Loss.py"
click node_sweep "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/VarSimu.py"
click node_outputs "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Output.py"
click node_plot "https://github.com/eomys/pyleecan/tree/master/pyleecan/Functions/Plot"
click node_optimization "https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/OptiProblem.py"
click node_persistence "https://github.com/eomys/pyleecan/blob/master/pyleecan/Functions/load.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_machine,node_lamination,node_geometry,node_winding,node_dxf,node_materials toneBlue
class node_femm,node_elmer,node_gmsh,node_electrical,node_losses,node_sweep toneAmber
class node_outputs,node_plot,node_persistence toneMint
class node_optimization toneRose
class node_gui,node_setup,node_material_ui,node_user toneIndigo
```

## Components

### Machine design

- [Machine models](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/MachineSIPMSM.py): `pyleecan/Classes/MachineSIPMSM.py`
- [Lamination geometry](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Lamination.py): `pyleecan/Classes/Lamination.py`
- [Geometry operations](https://github.com/eomys/pyleecan/tree/master/pyleecan/Functions/Geometry): `pyleecan/Functions/Geometry`
- [Winding models](https://github.com/eomys/pyleecan/blob/master/pyleecan/Functions/Winding/gen_phase_list.py): `pyleecan/Functions/Winding/gen_phase_list.py`
- [DXF import](https://github.com/eomys/pyleecan/blob/master/pyleecan/GUI/Dxf/DXF_Hole.py): `pyleecan/GUI/Dxf/DXF_Hole.py`
- [Material models](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Material.py): `pyleecan/Classes/Material.py`

### Simulation

- [FEMM analysis](https://github.com/eomys/pyleecan/blob/master/pyleecan/Methods/Simulation/MagFEMM/solve_FEMM.py): `pyleecan/Methods/Simulation/MagFEMM/solve_FEMM.py`
- [Elmer analysis](https://github.com/eomys/pyleecan/blob/master/pyleecan/Methods/Simulation/MagElmer/solve_FEA.py): `pyleecan/Methods/Simulation/MagElmer/solve_FEA.py`
- [GMSH meshing](https://github.com/eomys/pyleecan/blob/master/pyleecan/Functions/GMSH/draw_GMSH.py): `pyleecan/Functions/GMSH/draw_GMSH.py`
- [Electrical models](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Electrical.py): `pyleecan/Classes/Electrical.py`
- [Loss models](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Loss.py): `pyleecan/Classes/Loss.py`
- [Parameter sweep](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/VarSimu.py): `pyleecan/Classes/VarSimu.py`

### Results and analysis

- [Simulation outputs](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/Output.py): `pyleecan/Classes/Output.py`
- [Plotting](https://github.com/eomys/pyleecan/tree/master/pyleecan/Functions/Plot): `pyleecan/Functions/Plot`
- [Save and load](https://github.com/eomys/pyleecan/blob/master/pyleecan/Functions/load.py): `pyleecan/Functions/load.py`

### Optimization

- [Design optimization](https://github.com/eomys/pyleecan/blob/master/pyleecan/Classes/OptiProblem.py): `pyleecan/Classes/OptiProblem.py`

### User interface

- [Desktop GUI](https://github.com/eomys/pyleecan/blob/master/pyleecan/run_GUI.py): `pyleecan/run_GUI.py`
- [Machine setup](https://github.com/eomys/pyleecan/blob/master/pyleecan/GUI/Dialog/DMachineSetup/DMachineSetup.py): `pyleecan/GUI/Dialog/DMachineSetup/DMachineSetup.py`
- [Material library](https://github.com/eomys/pyleecan/blob/master/pyleecan/GUI/Dialog/DMatLib/DMatLib.py): `pyleecan/GUI/Dialog/DMatLib/DMatLib.py`

### Other components

- **Engineer**

## Connections

- Engineer → Desktop GUI: launches (evidence: `pyleecan/run_GUI.py`)
- Desktop GUI → Machine setup: opens setup (evidence: `pyleecan/run_GUI.py`)
- Desktop GUI → Material library: opens library (evidence: `pyleecan/run_GUI.py`)
- Machine setup → Machine models: configures (evidence: `README.md`)
- Material library → Material models: edits materials (evidence: `pyleecan/GUI/Dialog/DMatLib/DMatLib.py`)
- Machine models → Lamination geometry: comprises (evidence: `README.md`)
- Lamination geometry → Geometry operations: builds geometry (evidence: `pyleecan/Classes/Lamination.py`)
- DXF import → Lamination geometry: imports shapes (evidence: `pyleecan/GUI/Dxf/DXF_Hole.py`)
- Winding models → Machine models: supports winding (evidence: `README.md`)
- Machine models → FEMM analysis: simulates magnetics (evidence: `README.md`)
- Machine models → Elmer analysis: supplies machine (evidence: `pyleecan/Methods/Simulation/MagElmer/solve_FEA.py`)
- Machine models → GMSH meshing: meshes geometry (evidence: `pyleecan/Functions/GMSH/draw_GMSH.py`)
- Machine models → Electrical models: solves circuits (evidence: `README.md`)
- FEMM analysis → Loss models: feeds loss models (evidence: `README.md`)
- Machine models → Parameter sweep: varies parameters (evidence: `README.md`)
- Machine models → Design optimization: optimizes design (evidence: `README.md`)
- FEMM analysis → Simulation outputs: produces results (evidence: `README.md`)
- Elmer analysis → Simulation outputs: produces results (evidence: `README.md`)
- Electrical models → Simulation outputs: produces results (evidence: `README.md`)
- Simulation outputs → Plotting: visualizes results (evidence: `README.md`)
- Simulation outputs → Save and load: saves results (evidence: `README.md`)
