Esempio n. 1
0
    def make_relaxed():
        # Load data from results file
        if (not os.path.isfile(g.files['relaxed'])):
            g.end("No relaxed data - unable to continue.")

        d = []
        fh = open(g.files['relaxed'], 'r')
        for line in fh:
            d.append(line.strip())
        fh.close()
        nat = float(d[0])
        a0 = float(d[1])
        a0_scaled = float(d[2])
        a0_scaled_bohr = float(d[3])
        uv = numpy.zeros(
            (
                3,
                3,
            ),
            dtype=numpy.float64,
        )
        n = 4
        for i in range(3):
            for j in range(3):
                uv[i, j] = float(d[n])
                n = n + 1
        vpa = float(d[13])
        relaxed_energy_dft = float(d[14])
        relaxed_energy = float(d[15])
        relaxed_epa = float(d[16])

        # Output
        output.log("Making relaxed template using:", verbose=0)
        output.log("{:20s} {:12.6f} ".format("Relaxed a0", a0), verbose=0)
        output.log("{:20s} {:12.6f} ".format("Cx", g.ifile['cxyz'][0]),
                   verbose=0)
        output.log("{:20s} {:12.6f} {:6s} ".format("Relaxed a0 (scaled)",
                                                   a0_scaled, 'angs'),
                   verbose=0)
        output.log("{:20s} {:12.6f} {:6s}".format("Relaxed a0 (scaled)",
                                                  a0_scaled_bohr, 'bohr'),
                   verbose=0)
        output.log("{:20s} {:12.6f} {:12.6f} {:12.6f} ".format(
            "Relaxed UV", uv[0, 0], uv[0, 1], uv[0, 2]),
                   verbose=0)
        output.log("{:20s} {:12.6f} {:12.6f} {:12.6f} ".format(
            "", uv[1, 0], uv[1, 1], uv[1, 2]),
                   verbose=0)
        output.log("{:20s} {:12.6f} {:12.6f} {:12.6f} ".format(
            "", uv[2, 0], uv[2, 1], uv[2, 2]),
                   verbose=0)

        t = template.load()
        t.set_alat(a0_scaled_bohr)
        t.set_cp_arr(uv)
        t.save("template_relaxed.in", g.dirs['template'])
Esempio n. 2
0
    def run():

        # Check file specified and that it exists
        if (len(sys.argv) < 2):
            g.end("ERROR.  Please specifiy input file.")
        if (not os.path.isfile(sys.argv[1])):
            g.end("ERROR.  Input file does not exist.")

        # Load file
        g.ifile['path'] = os.path.join(os.getcwd(), sys.argv[1])
        ifile.load(g.ifile['path'])
Esempio n. 3
0
    def run():
        output.log("", verbose=0)
        output.log("", verbose=0)
        output.log("Process Results", verbose=0)
        output.log("##########################", verbose=0)

        if (not os.path.isfile(g.files['relaxed'])):
            g.end("No relaxed data - unable to continue.")

        # Clear output
        g.output = '#################################################################\n'
        g.output = g.output + '#                       QEEOS Results                           #\n'
        g.output = g.output + '#################################################################\n'
        g.output = g.output + '\n'

        process_results.relaxed()
        process_results.eos_bm()
        process_results.ec_mskp()
        process_results.ec_rfkj()

        fh = open(os.path.join(g.dirs['out'], "output.txt"), 'w')
        fh.write(g.output)
        fh.close()
Esempio n. 4
0
    def load(file_path):
        output.log("Read input file", verbose=0)

        #   Default units
        ###############################################################
        input_units = {
            'energy': 'ev',
            'length': 'ang',
            'pressure': 'gpa',
        }

        #   Read file
        ###############################################################

        d = std.read(file_path)

        #   Loop over lines in file
        ###############################################################
        for line in d:
            f = line.split(" ")
            f[0] = f[0].upper()

            if (f[0] == "#TEMPLATE"):
                template_file = os.path.abspath(f[1])
                if (os.path.isfile(template_file)):
                    g.ifile['template'] = template_file
                else:
                    g.end("ERROR.  Template file does not exist.")

            elif (f[0] == "#CONFIG"):
                a0_units = None
                a0 = None
                for fn in f:
                    fn = fn.split("=")
                    if (fn[0].upper() == "STRUCTURE"):
                        g.ifile['structure'] = fn[1].lower()
                    elif (fn[0].upper() == "A0"):
                        a0 = float(fn[1])
                    elif (fn[0].upper() == "UNITS"):
                        a0_units = fn[1]
                    elif (fn[0].upper() == "CXYZ"):
                        g.ifile['cxyz'] = ds.config_cxyz(fn[1].split(","))
                    elif (fn[0].upper() == "LABELS"):
                        g.ifile['labels'] = fn[1].split(",")
                if (a0 is not None):
                    if (a0_units is not None):
                        g.ifile['a0'] = units.convert(a0_units, 'angs', a0)
                    else:
                        g.ifile['a0'] = a0

            elif (f[0] == "#DFTSETTINGS"):
                for fn in f:
                    fn = fn.split("=")
                    if (fn[0].upper() == "ECUTWFC"):
                        g.ifile['ecutwfc'] = float(fn[1])
                    elif (fn[0].upper() == "ECUTRHO"):
                        g.ifile['ecutrho'] = float(fn[1])
                    elif (fn[0].upper() == "KPOINTS"):
                        g.ifile['kpoints'] = ds.kpoints(fn[1])
                    elif (fn[0].upper() == "DEGAUSS"):
                        g.ifile['degauss'] = float(fn[1])

            elif (f[0] == "#RELAX"):
                for fn in f:
                    fn = fn.split("=")
                    if (fn[0].upper() == "RUN"):
                        g.ifile['relax'] = True
                        if (fn[1][0].upper() == "F"):
                            g.ifile['relax'] = False

            elif (f[0] == "#EOS_BM"):
                for fn in f:
                    fn = fn.split("=")
                    if (fn[0].upper() == "RUN"):
                        g.ifile['eos_bm'] = True
                        if (fn[1][0].upper() == "F"):
                            g.ifile['eos_bm'] = False
                    elif (fn[0].upper() == "STRAIN"):
                        g.ifile['eos_bm_strain'] = float(fn[1])
                    elif (fn[0].upper() == "STEPS"):
                        g.ifile['eos_bm_steps'] = int(fn[1])
                    elif (fn[0].upper() == "CALC"):
                        g.ifile['eos_bm_calc'] = fn[1].lower()

            elif (f[0] == "#EC_MSKP"):
                for fn in f:
                    fn = fn.split("=")
                    if (fn[0].upper() == "RUN"):
                        g.ifile['ec_mskp'] = True
                        if (fn[1][0].upper() == "F"):
                            g.ifile['ec_mskp'] = False
                    elif (fn[0].upper() == "STRAIN"):
                        g.ifile['ec_mskp_strain'] = float(fn[1])
                    elif (fn[0].upper() == "STEPS"):
                        g.ifile['ec_mskp_steps'] = int(fn[1])
                    elif (fn[0].upper() == "CALC"):
                        g.ifile['ec_mskp_calc'] = fn[1].lower()

            elif (f[0] == "#EC_RFKJ"):
                for fn in f:
                    fn = fn.split("=")
                    if (fn[0].upper() == "RUN"):
                        g.ifile['ec_rfkj'] = True
                        if (fn[1][0].upper() == "F"):
                            g.ifile['ec_rfkj'] = False
                    elif (fn[0].upper() == "STRAIN"):
                        g.ifile['ec_rfkj_strain'] = float(fn[1])
                    elif (fn[0].upper() == "STEPS"):
                        g.ifile['ec_rfkj_steps'] = int(fn[1])
                    elif (fn[0].upper() == "CALC"):
                        g.ifile['ec_rfkj_calc'] = fn[1].lower()

            elif (f[0] == "#DFTADJUST"):
                for fn in f:
                    if ("=" in fn):
                        print(fn)
                        fn = fn.split("=")
                        label = fn[0].strip().upper()
                        fd = fn[1].split(',')
                        if (len(fd) == 4):
                            dft_energy = units.convert(fd[1], 'ev',
                                                       float(fd[0]))
                            known_energy = units.convert(
                                fd[3], 'ev', float(fd[2]))
                            g.adjust[label] = known_energy - dft_energy
Esempio n. 5
0
 def end():
     g.end(msg=None)