def freeze_one_half(basis):
    """
    Split the structure into two parts along the z-axis and then freeze the position of the atoms
    of the upper part (z>0.5) by setting selective dynamics to False.

    Args:
        basis (pyiron_atomistics.structure.atoms.Atoms): Atomistic structure object

    Returns:
        pyiron_atomistics.structure.atoms.Atoms: Atomistic structure object with half of the atoms fixed
    """
    basis.add_tag(selective_dynamics=None)
    _, _, z = basis.scaled_pos_xyz()
    for selector, ind in zip(z < 0.5, range(len(basis))):
        if selector:
            basis.selective_dynamics[ind] = [True, True, True]
        else:
            basis.selective_dynamics[ind] = [False, False, False]
    return basis