def auto_parameterize(nn_dist, snn_dist, smear=None):
    """
    Automatically calculate fermi parameters from crystal properties so that the midpoint and width of the smearing
    depend on the distance between first and second nearest neighbours.

    Args:
        nn_dist (float): Nearest neighbour distance.
        snn_dist (float): Second-nearest neighbour distance.
        smear (float): Fermi sigma value to use. (Default is twenty percent of the first and second nearest neighbour
                       distance difference.)

    Returns:
        2-element tuple containing

        - (*float*) -- Distance for half contribution.
        - (*float*) -- Smearing width.
    """
    center = 0.5 * (nn_dist + snn_dist)
    if smear is None:
        # Set smearing to 20% of the 2NN-1NN distance
        percentage = 0.2
        smear = percentage * (snn_dist - nn_dist)
    return center, smear