def system_pair_bond_lengths(Zs, length_scales):
    # shortest bond in this composition
    shortest_bond = min([length_scales[str(Z)]["min_bond_len"][0] for Z in Zs])

    # longest bond in this composition
    longest_bond = max([length_scales[str(Z)]["bond_len"][0] for Z in Zs])

    return shortest_bond, longest_bond


def round_sigfigs(v, n_sig_figs):
    # https://stackoverflow.com/questions/3410976/how-to-round-a-number-to-significant-figures-in-python
    return '{:g}'.format(float('{:.{p}g}'.format(v, p=n_sig_figs)))


uni_length_scales = {"1": {"bond_len": [1.2, "NB VASP auto_length_scale"],
                           "min_bond_len": [0.75, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [3.4, "NB VASP auto_length_scale"]},
                     "11": {"bond_len": [3.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [35, "NB VASP auto_length_scale"]},
                     "12": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [23, "NB VASP auto_length_scale"]},
                     "13": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [17, "NB VASP auto_length_scale"]},
                     "14": {"bond_len": [2.4, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [20, "NB VASP auto_length_scale"]},
                     "15": {"bond_len": [2.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [1.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [15, "NB VASP auto_length_scale"]},
                     "16": {"bond_len": [2.3, "NB VASP auto_length_scale"],
                            "min_bond_len": [1.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [17, "NB VASP auto_length_scale"]},
                     "17": {"bond_len": [2.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [36, "NB VASP auto_length_scale"]},
                     "19": {"bond_len": [4.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [71, "NB VASP auto_length_scale"]},
                     "20": {"bond_len": [3.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [41, "NB VASP auto_length_scale"]},
                     "21": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [22, "NB VASP auto_length_scale"]},
                     "22": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.4, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [17, "NB VASP auto_length_scale"]},
                     "23": {"bond_len": [2.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [1.8, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [13, "NB VASP auto_length_scale"]},
                     "24": {"bond_len": [2.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [1.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [12, "NB VASP auto_length_scale"]},
                     "26": {"bond_len": [2.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [1.8, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [11, "NB VASP auto_length_scale"]},
                     "27": {"bond_len": [2.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [11, "NB VASP auto_length_scale"]},
                     "28": {"bond_len": [2.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [11, "NB VASP auto_length_scale"]},
                     "29": {"bond_len": [2.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [12, "NB VASP auto_length_scale"]},
                     "3": {"bond_len": [3, "NB VASP auto_length_scale"],
                           "min_bond_len": [2.4, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [20, "NB VASP auto_length_scale"]},
                     "30": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [15, "NB VASP auto_length_scale"]},
                     "31": {"bond_len": [3, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [19, "NB VASP auto_length_scale"]},
                     "32": {"bond_len": [2.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [24, "NB VASP auto_length_scale"]},
                     "33": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [20, "NB VASP auto_length_scale"]},
                     "34": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [22, "NB VASP auto_length_scale"]},
                     "35": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [29, "NB VASP auto_length_scale"]},
                     "37": {"bond_len": [4.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.7, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [81, "NB VASP auto_length_scale"]},
                     "38": {"bond_len": [4.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.8, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [54, "NB VASP auto_length_scale"]},
                     "39": {"bond_len": [3.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [33, "NB VASP auto_length_scale"]},
                     "4": {"bond_len": [2.2, "NB VASP auto_length_scale"],
                           "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [7.9, "NB VASP auto_length_scale"]},
                     "40": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [23, "NB VASP auto_length_scale"]},
                     "41": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [18, "NB VASP auto_length_scale"]},
                     "42": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [16, "NB VASP auto_length_scale"]},
                     "43": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [14, "NB VASP auto_length_scale"]},
                     "44": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [14, "NB VASP auto_length_scale"]},
                     "45": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [14, "NB VASP auto_length_scale"]},
                     "46": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.4, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [15, "NB VASP auto_length_scale"]},
                     "47": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [18, "NB VASP auto_length_scale"]},
                     "48": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [23, "NB VASP auto_length_scale"]},
                     "49": {"bond_len": [3.4, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.8, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [27, "NB VASP auto_length_scale"]},
                     "5": {"bond_len": [1.8, "NB VASP auto_length_scale"],
                           "min_bond_len": [1.6, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [8.3, "NB VASP auto_length_scale"]},
                     "50": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [36, "NB VASP auto_length_scale"]},
                     "51": {"bond_len": [3.1, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [29, "NB VASP auto_length_scale"]},
                     "52": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [32, "NB VASP auto_length_scale"]},
                     "53": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.7, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [39, "NB VASP auto_length_scale"]},
                     "56": {"bond_len": [4.3, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [59, "NB VASP auto_length_scale"]},
                     "57": {"bond_len": [3.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [36, "NB VASP auto_length_scale"]},
                     "58": {"bond_len": [3.4, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [27, "NB VASP auto_length_scale"]},
                     "59": {"bond_len": [3.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.8, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [36, "NB VASP auto_length_scale"]},
                     "6": {"bond_len": [1.4, "NB VASP auto_length_scale"],
                           "min_bond_len": [1.3, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [5.7, "NB VASP auto_length_scale"]},
                     "60": {"bond_len": [3.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [35, "NB VASP auto_length_scale"]},
                     "61": {"bond_len": [3.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.7, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [34, "NB VASP auto_length_scale"]},
                     "62": {"bond_len": [3.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.7, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [33, "NB VASP auto_length_scale"]},
                     "64": {"bond_len": [3.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [33, "NB VASP auto_length_scale"]},
                     "65": {"bond_len": [3.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [32, "NB VASP auto_length_scale"]},
                     "66": {"bond_len": [3.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [31, "NB VASP auto_length_scale"]},
                     "69": {"bond_len": [3.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [30, "NB VASP auto_length_scale"]},
                     "7": {"bond_len": [1.6, "NB VASP auto_length_scale"],
                           "min_bond_len": [1.1, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [9.2, "NB VASP auto_length_scale"]},
                     "70": {"bond_len": [3.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [39, "NB VASP auto_length_scale"]},
                     "72": {"bond_len": [3.2, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.6, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [22, "NB VASP auto_length_scale"]},
                     "73": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [18, "NB VASP auto_length_scale"]},
                     "74": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [16, "NB VASP auto_length_scale"]},
                     "75": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [15, "NB VASP auto_length_scale"]},
                     "76": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.1, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [14, "NB VASP auto_length_scale"]},
                     "77": {"bond_len": [2.7, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.2, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [15, "NB VASP auto_length_scale"]},
                     "78": {"bond_len": [2.8, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [16, "NB VASP auto_length_scale"]},
                     "79": {"bond_len": [2.9, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [18, "NB VASP auto_length_scale"]},
                     "8": {"bond_len": [1.7, "NB VASP auto_length_scale"],
                           "min_bond_len": [1.2, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [11, "NB VASP auto_length_scale"]},
                     "80": {"bond_len": [3.3, "NB VASP auto_length_scale"],
                            "min_bond_len": [3, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [28, "NB VASP auto_length_scale"]},
                     "81": {"bond_len": [3.4, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [31, "NB VASP auto_length_scale"]},
                     "82": {"bond_len": [3.5, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.9, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [31, "NB VASP auto_length_scale"]},
                     "83": {"bond_len": [3.3, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.7, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [34, "NB VASP auto_length_scale"]},
                     "84": {"bond_len": [3.3, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.8, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [36, "NB VASP auto_length_scale"]},
                     "89": {"bond_len": [4, "NB VASP auto_length_scale"],
                            "min_bond_len": [3.5, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [46, "NB VASP auto_length_scale"]},
                     "9": {"bond_len": [2.1, "NB VASP auto_length_scale"],
                           "min_bond_len": [1.4, "NB VASP auto_length_scale"],
                           "other links": {},
                           "vol_per_atom": [15, "NB VASP auto_length_scale"]},
                     "90": {"bond_len": [3.6, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.7, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [32, "NB VASP auto_length_scale"]},
                     "91": {"bond_len": [3.3, "NB VASP auto_length_scale"],
                            "min_bond_len": [2.4, "NB VASP auto_length_scale"],
                            "other links": {},
                            "vol_per_atom": [25, "NB VASP auto_length_scale"]}}
