Metadata-Version: 2.2
Name: PyMMM
Version: 0.7.12
Summary: Python wrapper for MMM module
Author-Email: Alfonso Martinez <alfonso.martinez@we-online.com>
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: C++
Project-URL: Homepage, https://we-online.com
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# PyMMM - Würth Elektronik Magnetic Modeling Module

Python wrapper over OpenMagnetics for flyback transformer and current transformer selection from Würth's catalog.

## Features

- **Energy-based magnetic filtering** - Quickly filter catalog by storable energy
- **Virtual magnetics** - Generate winding combinations from real products
- **Flyback/CT design** - Process design inputs for flyback and current transformers
- **Full simulation** - Core losses, winding losses, temperature rise calculations
- **Visualization** - SVG plots of cores, windings, and magnetic fields

## Installation

```bash
pip install wheelhouse/pymmm-*.whl
```

## Quick Start

```python
import PyMMM

# Load catalog
PyMMM.load_magnetics_from_file("flybacks.ndjson", expand=True)

# Define requirements
inputs = {
    "inputVoltage": {"minimum": 85, "maximum": 265},
    "operatingPoints": [{
        "outputVoltages": [12],
        "outputCurrents": [1],
        "switchingFrequency": 100000,
        "mode": "Discontinuous Conduction Mode"
    }]
}

# Filter by energy
PyMMM.compute_energy_cache(100, inputs)
min_energy = PyMMM.calculate_flyback_required_magnetic_energy(inputs)
refs = PyMMM.filter_magnetics_by_energy(min_energy, min_energy * 2)

# Get virtual magnetics
for ref in refs:
    result = PyMMM.calculate_virtual_magnetics_by_reference(ref, inputs, True)
    print(result["virtualMagnetics"])
```

## Building from Source

```bash
# Build wheel
python3 -m pipx run build

# Or with cibuildwheel for manylinux
cibuildwheel
```

## Documentation

See [llms.txt](llms.txt) for detailed API documentation and usage patterns.

## API Reference

Run `help(PyMMM)` or `help(PyMMM.function_name)` for function documentation.

### Key Functions

| Function | Description |
|----------|-------------|
| `load_magnetics_from_file` | Load catalog from NDJSON |
| `compute_energy_cache` | Precompute storable energy |
| `filter_magnetics_by_energy` | Filter by energy range |
| `calculate_virtual_magnetics_by_reference` | Generate winding combinations |
| `filter_magnetics_by_flow` | Score and rank magnetics |
| `devirtualize_mas_by_reference` | Map virtual to real product |
| `calculate_saturation_current` | Calculate saturation current |

## License

Proprietary - Würth Elektronik