コード例 #1
0
ファイル: series.py プロジェクト: WMD-group/kgrid
def main():
    parser = ArgumentParser("Calculate a systematic series of k-point samples")
    parser.add_argument("-f", "--file", type=str, default="geometry.in", help="Crystal structure file")
    parser.add_argument("-t", "--type", type=str, default=None, help="Format of crystal structure file")
    parser.add_argument("--min", type=float, default=10, help="Minimum real-space cutoff / angstroms")
    parser.add_argument("--max", type=float, default=30, help="Maximum real-space cutoff / angstroms")

    args = parser.parse_args()

    if args.type:
        atoms = ase.io.read(args.file, format=args.type)
    else:
        atoms = ase.io.read(args.file)

    cutoffs = cutoff_series(atoms, args.min, args.max)

    kspacing = [np.pi / c for c in cutoffs]

    samples = [calc_kpt_tuple(atoms, cutoff_length=(cutoff - 1e-4)) for cutoff in cutoffs]

    print "Length cutoff  KSPACING    Samples"
    print "-------------  --------  ------------"

    fstring = "{0:12.3f}   {1:7.4f}   {2:3d} {3:3d} {4:3d}"
    for cutoff, s, sample in zip(cutoffs, kspacing, samples):
        print fstring.format(cutoff, s, *sample)
コード例 #2
0
def main():
    parser = ArgumentParser("Calculate a systematic series of k-point samples")
    parser.add_argument("structure",
                        type=str,
                        help="Path to input file",
                        nargs='?',
                        default=None)
    parser.add_argument("-f",
                        "--file",
                        action="store",
                        type=str,
                        dest="file",
                        default="geometry.in",
                        help="Path to input file [default: ./geometry.in]")
    parser.add_argument('-t',
                        '--type',
                        type=str,
                        default=None,
                        help='Format of crystal structure file')
    parser.add_argument('--min',
                        type=float,
                        default=10,
                        help='Minimum real-space cutoff / angstroms')
    parser.add_argument('--max',
                        type=float,
                        default=30,
                        help='Maximum real-space cutoff / angstroms')

    args = parser.parse_args()

    if args.structure is None:
        filename = args.file
    else:
        filename = args.structure

    if args.type:
        atoms = ase.io.read(filename, format=args.type)
    else:
        atoms = ase.io.read(filename)

    cutoffs = cutoff_series(atoms, args.min, args.max)

    kspacing = [np.pi / c for c in cutoffs]

    samples = [
        calc_kpt_tuple(atoms, cutoff_length=(cutoff - 1e-4))
        for cutoff in cutoffs
    ]

    print("Length cutoff  KSPACING    Samples")
    print("-------------  --------  ------------")

    fstring = "{0:12.3f}   {1:7.4f}   {2:3d} {3:3d} {4:3d}"
    for cutoff, s, sample in zip(cutoffs, kspacing, samples):
        print(fstring.format(cutoff, s, *sample))
コード例 #3
0
def calc_grid(cutoff_length,
              mode='default',
              filename='geometry.in',
              filetype=False,
              realspace=False,
              pretty_print=False):

    if filetype:
        atoms = ase.io.read(filename, format=filetype)
    else:
        atoms = ase.io.read(filename)

    k_samples = calc_kpt_tuple(
        atoms, mode=mode, cutoff_length=cutoff_length, realspace=realspace)

    # Print vectors
    if pretty_print:
        print '{0:3.0f} {1:3.0f} {2:3.0f}'.format(*k_samples)
    else:
        return k_samples
コード例 #4
0
ファイル: cli.py プロジェクト: antisymmetric/kgrid
def calc_grid(cutoff_length,
              mode='default',
              filename='geometry.in',
              filetype=False,
              realspace=False,
              pretty_print=False):

    if filetype:
        atoms = ase.io.read(filename, format=filetype)
    else:
        atoms = ase.io.read(filename)

    k_samples = calc_kpt_tuple(atoms,
                               mode=mode,
                               cutoff_length=cutoff_length,
                               realspace=realspace)

    # Print vectors
    if pretty_print:
        print '{0:3.0f} {1:3.0f} {2:3.0f}'.format(*k_samples)
    else:
        return k_samples
コード例 #5
0
def main(params=None):
    args = get_parser().parse_args(params)

    if args.type:
        atoms = ase.io.read(args.filename, format=args.type)
    else:
        atoms = ase.io.read(args.filename)

    cutoffs = cutoff_series(atoms, args.min, args.max)

    if args.castep:
        kspacing = [0.5 / c for c in cutoffs]
    else:
        kspacing = [np.pi / c for c in cutoffs]

    samples = [
        calc_kpt_tuple(atoms, cutoff_length=(cutoff - 1e-4))
        for cutoff in cutoffs
    ]

    if args.comma_sep:

        def print_sample(sample):
            return ' '.join((str(x) for x in sample))

        print(','.join((print_sample(sample) for sample in samples)))

    else:
        if args.castep:
            print("Length cutoff  MP SPACING    Samples")
            print("-------------  ----------  ------------")
            fstring = "{0:12.3f}   {1:9.6f}   {2:3d} {3:3d} {4:3d}"
        else:
            print("Length cutoff  KSPACING    Samples")
            print("-------------  --------  ------------")
            fstring = "{0:12.3f}   {1:7.4f}   {2:3d} {3:3d} {4:3d}"

        for cutoff, s, sample in zip(cutoffs, kspacing, samples):
            print(fstring.format(cutoff, s, *sample))
コード例 #6
0
def main():
    parser = ArgumentParser("Calculate a systematic series of k-point samples")
    parser.add_argument('filename',
                        nargs='?',
                        type=str,
                        default="geometry.in",
                        help="Path to input file [default: ./geometry.in]")
    parser.add_argument('-t',
                        '--type',
                        type=str,
                        default=None,
                        help='Format of crystal structure file')
    parser.add_argument('--min',
                        type=float,
                        default=10,
                        help='Minimum real-space cutoff / angstroms')
    parser.add_argument('--max',
                        type=float,
                        default=30,
                        help='Maximum real-space cutoff / angstroms')
    parser.add_argument('--comma_sep',
                        action='store_true',
                        help='Output as comma-separated list on one line')
    parser.add_argument('--castep',
                        action='store_true',
                        help=('Provide CASTEP-like MP spacing instead of '
                              'vasp-like KSPACING'))

    args = parser.parse_args()

    if args.type:
        atoms = ase.io.read(args.filename, format=args.type)
    else:
        atoms = ase.io.read(args.filename)

    cutoffs = cutoff_series(atoms, args.min, args.max)

    if args.castep:
        kspacing = [0.5 / c for c in cutoffs]
    else:
        kspacing = [np.pi / c for c in cutoffs]

    samples = [
        calc_kpt_tuple(atoms, cutoff_length=(cutoff - 1e-4))
        for cutoff in cutoffs
    ]

    if args.comma_sep:

        def print_sample(sample):
            return ' '.join((str(x) for x in sample))

        print(','.join((print_sample(sample) for sample in samples)))

    else:
        if args.castep:
            print("Length cutoff  MP SPACING    Samples")
            print("-------------  ----------  ------------")
            fstring = "{0:12.3f}   {1:9.6f}   {2:3d} {3:3d} {4:3d}"
        else:
            print("Length cutoff  KSPACING    Samples")
            print("-------------  --------  ------------")
            fstring = "{0:12.3f}   {1:7.4f}   {2:3d} {3:3d} {4:3d}"

        for cutoff, s, sample in zip(cutoffs, kspacing, samples):
            print(fstring.format(cutoff, s, *sample))
コード例 #7
0
ファイル: test_kgrid_lib.py プロジェクト: Compphysguy/kgrid
def test_calc_kpt_tuple(atoms, expected, kwargs):
    assert kgrid.calc_kpt_tuple(atoms, **kwargs) == expected