import math


def kd_formula(r1, r2, dielectric, temp=298):
    """
    Applies the Fuoss formula to model dissociation constants of spherical ions.
    Note that as written this formula is applicable only to charge ±1 ions!

    Args:
        r1 (float): radius of first ion in Å
        r2 (float): radius of second ion in Å
        dielectric (float): dielectric constant of solvent
        temp (float): temperature in Kelvin

    Returns:
        dissociation constant
    """
    assert isinstance(r1, (float, int)), "Need numeric value for r1!"
    assert isinstance(r2, (float, int)), "Need numeric value for r1!"
    assert isinstance(dielectric, (float, int)), "Need numeric value for dielectric!"
    assert isinstance(temp, (float, int)), "Need numeric value for temperature!"

    x = (r1 + r2) * 10 ** -8 # convert to cm

    N = 6.023 * 10 ** 23 # mol^-1
    e = 4.8 * 10 ** -10 # esu
    k = 1.38 * 10 ** -16 # erg/degree

    b = e ** 2 / (x * dielectric * k * temp)
    K = 3000 * math.exp(-1 * b) / (4 * math.pi * N * (x ** 3))

    return K