def automatic_density(cls, structure, kppa, chksymbreak=None, use_symmetries=True, use_time_reversal=True,
                          shifts=(0.5, 0.5, 0.5)):
        """
        Returns an automatic Kpoint object based on a structure and a kpoint
        density. Uses Gamma centered meshes for hexagonal cells and Monkhorst-Pack grids otherwise.

        Algorithm:
            Uses a simple approach scaling the number of divisions along each
            reciprocal lattice vector proportional to its length.

        Args:
            structure: Input structure
            kppa: Grid density
        """
        lattice = structure.lattice
        lengths = lattice.abc
        shifts = np.reshape(shifts, (-1, 3))
        ngrid = kppa / structure.num_sites / len(shifts)

        mult = (ngrid * lengths[0] * lengths[1] * lengths[2]) ** (1 / 3.)

        num_div = [int(round(1.0 / lengths[i] * mult)) for i in range(3)]
        # ensure that num_div[i] > 0
        num_div = [i if i > 0 else 1 for i in num_div]

        angles = lattice.angles
        hex_angle_tol = 5      # in degrees
        hex_length_tol = 0.01  # in angstroms

        right_angles = [i for i in range(3) if abs(angles[i] - 90) < hex_angle_tol]

        hex_angles = [i for i in range(3)
                      if abs(angles[i] - 60) < hex_angle_tol or
                      abs(angles[i] - 120) < hex_angle_tol]

        is_hexagonal = (len(right_angles) == 2 and len(hex_angles) == 1
                        and abs(lengths[right_angles[0]] -
                                lengths[right_angles[1]]) < hex_length_tol)

        #style = KSamplingModes.gamma
        #if not is_hexagonal:
        #    num_div = [i + i % 2 for i in num_div]
        #    style = KSamplingModes.monkhorst

        comment = "pymatge.io.abinit generated KPOINTS with grid density = " + "{} / atom".format(kppa)

        return cls(
            mode="monkhorst", num_kpts=0, kpts=[num_div], kpt_shifts=shifts,
            use_symmetries=use_symmetries, use_time_reversal=use_time_reversal, chksymbreak=chksymbreak,
            comment=comment)
def automatic_density ( cls , structure , kppa , chksymbreak = None , use_symmetries = True , use_time_reversal = True , shifts = ( 0.5 , 0.5 , 0.5 ) ) : lattice = structure . lattice lengths = lattice . abc shifts = np . reshape ( shifts , ( - 1 , 3 ) ) ngrid = kppa / structure . num_sites / len ( shifts ) mult = ( ngrid * lengths [ 0 ] * lengths [ 1 ] * lengths [ 2 ] ) ** ( 1 / 3. ) num_div = [ int ( round ( 1.0 / lengths [ i ] * mult ) ) for i in range ( 3 ) ] num_div = [ i if i > 0 else 1 for i in num_div ] angles = lattice . angles hex_angle_tol = 5 hex_length_tol = 0.01 right_angles = [ i for i in range ( 3 ) if abs ( angles [ i ] - 90 ) < hex_angle_tol ] hex_angles = [ i for i in range ( 3 ) if abs ( angles [ i ] - 60 ) < hex_angle_tol or abs ( angles [ i ] - 120 ) < hex_angle_tol ] is_hexagonal = ( len ( right_angles ) == 2 and len ( hex_angles ) == 1 and abs ( lengths [ right_angles [ 0 ] ] - lengths [ right_angles [ 1 ] ] ) < hex_length_tol ) comment = "pymatge.io.abinit generated KPOINTS with grid density = " + "{} / atom" . format ( kppa ) return cls ( mode = "monkhorst" , num_kpts = 0 , kpts = [ num_div ] , kpt_shifts = shifts , use_symmetries = use_symmetries , use_time_reversal = use_time_reversal , chksymbreak = chksymbreak , comment = comment )
Returns an automatic Kpoint object based on a structure and a kpoint
        density. Uses Gamma centered meshes for hexagonal cells and Monkhorst-Pack grids otherwise.

        Algorithm:
            Uses a simple approach scaling the number of divisions along each
            reciprocal lattice vector proportional to its length.

        Args:
            structure: Input structure
            kppa: Grid density