Author: Alper TEZCAN • PhD Track, Institut Polytechnique de Paris
Advisors: Prof. Jean‑Eric Wegrowe (supervisor), Dr. Valentin Desbuis (mentorship)
License: MIT (see LICENSE)
This library implements fast, modular simulations of the Stoner-Wohlfarth model with multiple anisotropy terms and experiment helpers.
- Core SW energy + numerical minimization (L‑BFGS‑B)
- Anisotropy hierarchy:
Uniaxial(single axis)ManyUniaxial(sum of multiple uniaxials)Cubiccrystal anisotropyHexagonalcrystal anisotropy
- Angle scans ((theta/phi)) and field sweeps (hysteresis)
- Transport helpers: AMR / PHE / AHE, plus basic astroid utilities
- Simple plotting utilities for quick inspection
Requirements: Python >= 3.9, NumPy, SciPy, Matplotlib, Joblib (see pyproject.toml).
For now, the package is under active development and can be installed directly from the GitHub repository:
pip install git+https://github.com/alperTezcan/Hall-Effect-Sim.git@mainor, for editable development inside a local clone:
git clone https://github.com/alperTezcan/Hall-Effect-Sim.git
cd Hall-Effect-Sim
pip install -e .A PyPI release (pip install stoner-wohlfarth) will be available later once the package reaches a stable version.
sw/
├─ anisotropies.py # Anisotropy hierarchy (Uniaxial, ManyUniaxial, Cubic, Hexagonal)
├─ SW_model.py # SWModel: energies, minimization, sweeps & scans
├─ experiments.py # Transport, switching/astroid, plotting helpers
└─ __init__.py # Public API
examples/
├─ Uniaxial.py # Examples with Uniaxial anisotropy
| ├─ Field-sweep.py # +H --> -H --> +H experiment
| ├─ Astroid.py # SW astroid experiment
| └─ Angle-scan.py # theta/phi scan at fixed H experiment
└─ generic_demo.py
pyproject.toml
README.md
LICENSE
Example scripts in the examples/ folder do not require a pip installation as they import the functions from parent folders explicitly. If you install the package and build it with pip, you can also run them by adjusting the imports accordingly.
-
Anisotropies
Uniaxial(Han, u)— withaxis_from_degrees(Han, theta_deg, phi_deg)helperManyUniaxial(Han_list=[...], u_list=[...])orManyUniaxial(terms=[Uniaxial(...), ...])Cubic(K1, K2=0.0, R=None)— energy in the crystal frame (a = R @ M)Hexagonal(K1, K2=0.0, K6=0.0, R=None)— uses (theta, phi) in the crystal frameeuler_zyx(z, y, x)— build rotation matrix mapping LAB → CRYSTAL
-
SW_model
SWModel(axes, Hd=0.0)hysteresis(theta_H, phi_H, H_values)angle_scan_theta(H, phi_H, thetas)/angle_scan_phi(H, theta_H, phis)
-
Experiments
hall_effects(...)/hall_from_angle_scan(...)switching_fields(...),astroid_*helpersplot_hysteresis(...),plot_angle_scan(...),plot_halls(...)
If this software assists your research, please cite it. Example BibTeX:
@software{tezcan_stoner_wohlfarth_2025,
author = {Alper Tezcan},
title = {Stoner-Wohlfarth Macrospin Simulations},
year = {2025},
version = {2.0.0},
url = {https://github.com/alperTezcan/Hall-Effect-Sim}
}Pull requests and issues are welcome. Please include a minimal failing example if you report a bug.