Beispiel #1
0
    def output(self):
        """Outputs BMDL input file as a formatted string

        Creates a long string containing the batch
        job script which will later be written on disk.

        :returns: batch script input file
        :rtype: str
        """

        mdlfile = "bmdl/"
        prnfile = "bmdl/"

        now = datetime.datetime.now()
        line = "BMDL      HP......=N                              "\
            + str(now.day) + "." + str(now.month) + "." + str(now.year) + "\n"
        JOBNAMline = "JOBNAM...=" + self.jobname_lat
        MSGLline = "MSGL.=  " + str(self.msgl)
        NPRNline = "NPRN.=  " + str(self.nprn)
        line = line + \
            "{0:21s}{1:9s} {2:9s}".format(
                JOBNAMline, MSGLline, NPRNline) + "\n"
        line = line + "DIR001=" + mdlfile + "\n"
        line = line + "DIR006=" + prnfile + "\n"
        line = line + "Madelung potential for {0}".format(
            self.jobname_lat) + "\n"
        line = line + "NL.....={0:2d}".format(self.bmdl_nl) + "\n"
        line = line + "LAMDA....=      {0:4.2f} AMAX....=      {1:4.2f} BMAX....=      {2:4.2f}"\
            .format(self.lamda, self.amax, self.bmax) + "\n"
        line = line + "NQ....={0:3d} LAT...={1:2d} IPRIM.= {2} NQR2..= {3}"\
            .format(self.nq, common.lat_to_ibz(self.lat), self.iprim, self.nqr2) + "\n"
        line = line + "A........={0:10.8f} B.......={1:10.8f} C.......={2:10.8f}"\
            .format(self.latparams[0], self.latparams[1], self.latparams[2]) + "\n"
        if self.iprim == 1:
            line = line + "ALPHA....={0:10.6f} BETA....={1:10.6f} GAMMA...={2:10.6f}"\
                .format(self.latvectors[0], self.latvectors[1], self.latvectors[2]) + "\n"
        elif self.iprim == 0:
            line = line + "BSX......={0:10.7f} BSY.....={1:10.7f} BSZ.....={2:10.7f}"\
                .format(self.latvectors[0][0], self.latvectors[0][1], self.latvectors[0][2]) + "\n"
            line = line + "BSX......={0:10.7f} BSY.....={1:10.7f} BSZ.....={2:10.7f}"\
                .format(self.latvectors[1][0], self.latvectors[1][1], self.latvectors[1][2]) + "\n"
            line = line + "BSX......={0:10.7f} BSY.....={1:10.7f} BSZ.....={2:10.7f}"\
                .format(self.latvectors[2][0], self.latvectors[2][1], self.latvectors[2][2]) + "\n"
        for i in range(self.nq):
            line = line + "QX({3:03})..={0:10.7f} QY({3:03}).={1:10.7f} QZ({3:03}).={2:10.7f}"\
                .format(self.basis[i,0], self.basis[i,1], self.basis[i,2], i + 1) + "\n"

        return line
Beispiel #2
0
 def generate_prims(self, angles):
     """Generates the primitive lattice vectors from the angle and Bravais-lattice
     type information.
     """
     deg_to_rad = np.pi / 180.0
     alpha = angles[0] * deg_to_rad
     beta = angles[1] * deg_to_rad
     gamma = angles[2] * deg_to_rad
     ibz = common.lat_to_ibz(self.lat)
     boa = self.latparams[1] / self.latparams[0]
     coa = self.latparams[2] / self.latparams[0]
     #
     if ibz == 1:
         prims = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0],
                           [0.0, 0.0, 1.0]])
     elif ibz == 2:
         prims = np.array([[0.5, 0.5, 0.0], [0.0, 0.5, 0.5],
                           [0.5, 0.0, 0.5]])
     elif ibz == 3:
         prims = np.array([[0.5, 0.5, -0.5], [-0.5, 0.5, 0.5],
                           [0.5, -0.5, 0.5]])
     elif ibz == 4:
         prims = np.array([[1.0, 0.0, 0.0], [-0.5, 0.5 * np.sqrt(3.0), 0.0],
                           [0.0, 0.0, coa]])
     elif ibz == 5:
         prims = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0],
                           [0.0, 0.0, coa]])
     elif ibz == 6:
         prims = np.array([[-0.5, 0.5, 0.5 * coa], [0.5, -0.5, 0.5 * coa],
                           [0.5, 0.5, -0.5 * coa]])
     elif ibz == 7:
         prims = np.array([[0.0, 1.0, coa],
                           [-0.5 * np.sqrt(3.0), -0.5, coa],
                           [0.5 * np.sqrt(3.0), -0.5, coa]])
     elif ibz == 8:
         prims = np.array([[1.0, 0.0, 0.0], [0.0, boa, 0.0],
                           [0.0, 0.0, coa]])
     elif ibz == 9:
         prims = np.array([[0.5, -0.5 * boa, 0.0], [0.5, 0.5 * boa, 0.0],
                           [0.0, 0.0, coa]])
     elif ibz == 10:
         prims = np.array([[0.5, -0.5 * boa, 0.5 * coa],
                           [0.5, 0.5 * boa, -0.5 * coa],
                           [-0.5, 0.5 * boa, 0.5 * coa]])
     elif ibz == 11:
         prims = np.array([[0.5, 0.0, 0.5 * coa], [0.5, 0.5 * boa, 0.0],
                           [0.0, 0.5 * boa, 0.5 * coa]])
     elif ibz == 12:
         prims = np.array([[1.0, 0.0, 0.0],
                           [boa * np.cos(gamma), boa * np.sin(gamma), 0.0],
                           [0.0, 0.0, coa]])
     elif ibz == 13:
         prims = np.array(
             [[0.0, -boa, 0.0],
              [0.5 * np.sin(gamma), -0.5 * np.cos(gamma), -0.5 * coa],
              [0.5 * np.sin(gamma), -0.5 * np.cos(gamma), 0.5 * coa]])
     elif ibz == 14:
         tmp1 = (np.cos(alpha) -
                 np.cos(beta) * np.cos(gamma)) / np.sin(gamma)
         tmp2 = np.sqrt((1.0 - np.cos(gamma)**2 - np.cos(alpha)**2 -
                         np.cos(beta)**2 + 2.0 * np.cos(alpha) *
                         np.cos(beta) * np.cos(gamma))) / np.sin(gamma)
         prims = np.array([[1.0, 0.0, 0.0],
                           [boa * np.cos(gamma), boa * np.sin(gamma), 0.0],
                           [coa * np.cos(beta), coa * tmp1, coa * tmp2]])
     #print('generated prims:')
     #print(prims)
     return prims
Beispiel #3
0
    def output(self, index):
        """Outputs KSTR input file as a formatted string.

        :param index:
        :type index:
        :returns: KSTR input file string
        :rtype: str
        """

        slope = 'kstr/'
        prn = 'kstr/'
        boolean = {True: "Y", False: "N"}

        if index == 1:
            kappaw = self.kappaw[0]
            jobname_lat = self.jobname_lat
        elif index == 2:
            kappaw = self.kappaw[1]
            jobname_lat = self.jobname_lat2

        now = datetime.datetime.now()
        line = "KSTR      HP......=N                              "\
            + str(now.day) + "." + str(now.month) + "." + str(now.year) + "\n"
        JOBNAMline = "JOBNAM...=" + jobname_lat
        MSGLline = "MSGL.=  " + str(self.msgl)
        line = line + "{0:21s}{1:9s}".format(JOBNAMline, MSGLline) +\
            " MODE...={0} STORE..={1} HIGH...={2}"\
            .format(self.mode, self.store, self.high) + "\n"
        line = line + "DIR001=" + slope + "\n"
        line = line + "DIR006=" + prn + "\n"
        line = line + "Slope matrices, {0:10}, (kappa*w)^2= {1:5.1f}"\
            .format(jobname_lat, kappaw) + "\n"
        line = line + "NL.....={0:2d} NLH...={1:2d} NLW...={2:2d} "\
            .format(self.kstr_nl, self.nlh, self.nlw) +\
            "NDER..={0:2d} ITRANS={1:2d} NPRN..={2:2d}"\
            .format(self.nder, self.itrans, self.nprn) + "\n"
        line = line + "(K*W)^2..={0:10.6f} DMAX....={1:10.4f} RWATS...={2:10.2f}"\
            .format(kappaw, self.dmax, self.rwats) + "\n"
        line = line + "NQ3...={0:3d} LAT...={1:2d} IPRIM.={2:2d} NGHBP.={3:2d} NQR2..={4:2d}"\
            .format(self.nq, common.lat_to_ibz(self.lat), self.iprim, self.nghbp, self.nqr2) + "\n"
        line = line + "A........={0:10.8f} B.......={1:10.8f} C.......={2:10.8f}"\
            .format(self.latparams[0], self.latparams[1], self.latparams[2]) + "\n"
        if self.iprim == 1:
            line = line + "ALPHA....={0:10.6f} BETA....={1:10.6f} GAMMA...={2:10.6f}"\
                .format(self.latvectors[0], self.latvectors[1], self.latvectors[2]) + "\n"
        elif self.iprim == 0:
            line = line + "BSX......={0:10.7f} BSY.....={1:10.7f} BSZ.....={2:10.7f}"\
                .format(self.latvectors[0][0], self.latvectors[0][1], self.latvectors[0][2]) + "\n"
            line = line + "BSX......={0:10.7f} BSY.....={1:10.7f} BSZ.....={2:10.7f}"\
                .format(self.latvectors[1][0], self.latvectors[1][1], self.latvectors[1][2]) + "\n"
            line = line + "BSX......={0:10.7f} BSY.....={1:10.7f} BSZ.....={2:10.7f}"\
                .format(self.latvectors[2][0], self.latvectors[2][1], self.latvectors[2][2]) + "\n"
        for i in range(self.nq):
            #line = line + "QX.......={0:10.7f} QY......={1:10.7f} QZ(...={2:10.7f}"\
            line = line + "QX({3:03})..={0:10.7f} QY({3:03}).={1:10.7f} QZ({3:03}).={2:10.7f}"\
            .format(self.basis[i,0], self.basis[i,1], self.basis[i,2], i+1) + "\n"
        for i in range(self.nq):
            line = line + "a/w(IQ)..= {0:4.2f} {1:4.2f} {2:4.2f} {3:4.2f}"\
                .format(*self.awIQ[i, :]) + "\n"
        line = line + "LAMDA....={0:10.7f} AMAX....={1:10.7f} BMAX....={2:10.7f}"\
            .format(self.lamda, self.amax, self.bmax) + "\n"

        return line
Beispiel #4
0
    def check_input_file(self):
        """Perform various checks on the class data

        Makes sure that all necessary data exists
        before we attempt to write the input file to disk.

        :returns: None
        :rtype: None
        """

        # Mission critical arguments
        if self.jobname is None:
            sys.exit('Kgrn: \'jobname\' has to be given!')
        if self.latname is None:
            sys.exit('Kgrn: \'latname\' has to be given!')
        if self.ibz is None:
            try:
                self.ibz = common.lat_to_ibz(self.latname)
            except KeyError:
                sys.exit('Kgrn: \'ibz\' has to be given for \'latname\'={0}!'.
                         format(self.latname))
        if self.latpath is None:
            self.latpath = './'
        if self.sws is None or self.sws == 0.0:
            sys.exit('Kgrn: \'sws\' has to be given!')
        if self.atomblock is None:
            sys.exit('Kgrn: Some atomic information is missing =>' +
                     ' self.atomblock has not been constructed!')
        if self.atconf is None:
            sys.exit('Kgrn: Some atomic information is missing =>' +
                     ' self.atconf has not been constructed!')
        else:
            if isinstance(self.atconf[0], list):
                pass
            else:
                self.atconf = [self.atconf]

        # Arguments for which reasonable default values exist
        if self.strt is None:
            self.strt = 'A'
        if self.msgl is None:
            self.msgl = 1
        if self.expan is None:
            self.expan = 'S'
        if self.fcd is None:
            self.fcd = 'Y'
        if self.func is None:
            self.func = 'SCA'
        if self.niter is None:
            self.niter = 100
        if self.nlin is None:
            self.nlin = 31
        if self.nprn is None:
            self.nprn = 0
        if self.ncpa is None:
            self.ncpa = 7
        if self.mode is None:
            self.mode = '3D'
        if self.frc is None:
            self.frc = 'N'
        if self.dos is None:
            self.dos = 'N'
        if self.ops is None:
            self.ops = 'N'
        if self.afm is None:
            self.afm = 'P'
            for i in range(len(self.splts)):
                if not self.splts[i] == 0.0:
                    self.afm = 'F'
                    break
        if self.crt is None:
            self.crt = 'M'
        if self.lmaxh is None:
            self.lmaxh = 8
        if self.lmaxt is None:
            self.lmaxt = 4
        if self.kgrn_nfi is None:
            self.kgrn_nfi = 31
        if self.fixg is None:
            self.fixg = 2
        if self.shf is None:
            self.shf = 0
        if self.sofc is None:
            self.sofc = 'N'
        if self.kmsh is None:
            self.kmsh = 'G'
        if self.nkx is None:
            self.nkx = 0
        if self.nky is None:
            if self.ibz == 2:
                self.nky = 13
            elif self.ibz == 3:
                self.nky = 17
            elif self.ibz == 4:
                self.nky = 13
                self.nkz = 9
            else:
                self.nky = 13
        if self.nkz is None:
            self.nkz = 0
        if self.fbz is None:
            self.fbz = 'N'
        if self.kmsh2 is None:
            self.kmsh2 = 'G'
        if self.ibz2 is None:
            self.ibz2 = 1
        if self.nkx2 is None:
            self.nkx2 = 4
        if self.nky2 is None:
            self.nky2 = 0
        if self.nkz2 is None:
            self.nkz2 = 51
        if self.zmsh is None:
            self.zmsh = 'C'
        if self.nz1 is None:
            self.nz1 = 16
        if self.nz2 is None:
            self.nz2 = 8
        if self.nz3 is None:
            self.nz3 = 8
        if self.nres is None:
            self.nres = 4
        if self.nzd is None:
            self.nzd = 1500
        if self.depth is None:
            self.depth = 1.0
        if self.imagz is None:
            self.imagz = 0.020
        if self.eps is None:
            self.eps = 0.2
        if self.elim is None:
            self.elim = -1.0
        if self.amix is None:
            self.amix = 0.05
        if self.efmix is None:
            self.efmix = 1.0
        if self.vmtz is None:
            self.vmtz = 0.0
        if self.mmom is None:
            self.mmom = 0.0
        if self.tole is None:
            self.tole = 1.0e-7
        if self.tolef is None:
            self.tolef = 1.0e-7
        if self.tolcpa is None:
            self.tolcpa = 1.0e-6
        if self.tfermi is None:
            self.tfermi = 500.0
        if self.nsws is None:
            self.nsws = 1
        if self.dsws is None:
            self.dsws = 0.05
        if self.alpcpa is None:
            self.alpcpa = 0.6020
        if self.efgs is None:
            self.efgs = 0.0
        if self.hx is None:
            self.hx = 0.1
        if self.nx is None:
            self.nx = 5
        if self.nz0 is None:
            self.nz0 = 6
        if self.stmp is None:
            self.stmp = 'N'
        if self.iex is None:
            self.iex = 4
        if self.dirac_np is None:
            self.dirac_np = 251
        if self.nes is None:
            self.nes = 15
        if self.dirac_niter is None:
            self.dirac_niter = 100
        if self.iwat is None:
            self.iwat = 0
        if self.nprna is None:
            self.nprna = 0
        if self.vmix is None:
            self.vmix = 0.3
        if self.rwat is None:
            self.rwat = 3.5
        if self.rmax is None:
            self.rmax = 20.0
        if self.dx is None:
            self.dx = 0.03
        if self.dr1 is None:
            self.dr1 = 0.002
        if self.test is None:
            self.test = 1.0e-12
        if self.teste is None:
            self.teste = 1.0e-12
        if self.testy is None:
            self.testy = 1.0e-12
        if self.testv is None:
            self.testv = 1.0e-12
        if self.FOR001 is None:
            self.FOR001 = self.latpath + '/kstr/' + self.latname + '.tfh'
            self.FOR001_2 = self.latpath + '/kstr/' + self.latname + '2.tfh'
            self.FOR001 = common.cleanup_path(self.FOR001)
            self.FOR001_2 = common.cleanup_path(self.FOR001_2)
        if self.DIR002 is None:
            self.DIR002 = 'kgrn/'
        if self.DIR003 is None:
            self.DIR003 = 'kgrn/'
        if self.FOR004 is None:
            self.FOR004 = self.latpath + '/bmdl/' + self.latname + '.mdl'
            self.FOR004 = common.cleanup_path(self.FOR004)
        if self.DIR006 is None:
            self.DIR006 = 'kgrn/'
        if self.DIR009 is None:
            self.DIR009 = 'kgrn/'
        if self.DIR010 is None:
            self.DIR010 = 'kgrn/'
        if self.DIR011 is None:
            self.DIR011 = 'kgrn/tmp/'
        if self.CQNA is None:
            self.CQNA = 'N'
        if self.ncpu is None:
            self.ncpu = 1