#!/usr/bin/env python3
"""Educational thin-film model summaries for SemiAgora process replays.

This script documents the simple equations used by the public process seed.
It does not write recipe files, control equipment, or qualify any process.
"""

from __future__ import annotations

import math


def half_range_nonuniformity_percent(samples: list[float]) -> float:
    mean = sum(samples) / len(samples)
    return (max(samples) - min(samples)) / (2 * mean) * 100


def ald_gpc_nm_per_cycle(pulse_s: float, tau_s: float = 0.42, saturated_gpc_nm: float = 0.11) -> float:
    return saturated_gpc_nm * (1 - math.exp(-pulse_s / tau_s))


def main() -> None:
    sputter_reference = [92.3, 95.1, 97.4, 98.9, 99.7, 100.0, 99.7, 98.9, 97.4, 95.1, 92.3]
    evaporation_long_throw = [97.9, 98.7, 99.3, 99.7, 99.9, 100.0, 99.9, 99.7, 99.3, 98.7, 97.9]
    pulses = [0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 4.0]

    print("sputter reference nonuniformity %:", round(half_range_nonuniformity_percent(sputter_reference), 2))
    print("evaporation long-throw nonuniformity %:", round(half_range_nonuniformity_percent(evaporation_long_throw), 2))
    print("ald gpc nm/cycle:", [round(ald_gpc_nm_per_cycle(p), 4) for p in pulses])


if __name__ == "__main__":
    main()
