#!/usr/bin/env python3
"""Small scale estimates for micromagnetic teaching examples."""

from __future__ import annotations

import math


MU0 = 4 * math.pi * 1e-7


def exchange_length(A: float, Ms: float) -> float:
    """Return magnetostatic exchange length in meters."""
    return math.sqrt(2 * A / (MU0 * Ms**2))


def bloch_wall_width(A: float, K: float) -> float:
    """Return the Bloch-wall width scale pi*sqrt(A/K) in meters."""
    return math.pi * math.sqrt(A / K)


def main() -> None:
    # Magnetite-like room-temperature teaching constants.
    A = 1.3e-11  # J/m
    Ms = 480e3  # A/m
    K_values = [1.0e3, 1.0e4, 1.0e5]

    print("Magnetite-like micromagnetic length scales")
    print(f"A  = {A:.2e} J/m")
    print(f"Ms = {Ms:.2e} A/m")
    print(f"exchange length = {exchange_length(A, Ms) * 1e9:.1f} nm")
    for K in K_values:
        print(f"K = {K:.1e} J/m^3 -> wall width = {bloch_wall_width(A, K) * 1e9:.1f} nm")


if __name__ == "__main__":
    main()
