예제 #1
0
class TurbomoleResults(Results):
    def __init__(self, controlfile='control', coordfile='coord', outname=None):
        self.mol = VibToolsMolecule()
        self.coordfile = coordfile

        if outname:
            print "WARNING: normal modes are read from aoforce output file"

            self.aoforceoutput = AOForceOutputFile(filename=outname)
        else:
            self.aoforceoutput = None
        self.controlfile = TMControlFile(filename=controlfile)

    def _get_modes(self):
        if self.aoforceoutput:
            return self.aoforceoutput.modes
        else:
            return self.controlfile.modes

    modes = property(_get_modes)

    def read(self):
        self.mol.read_from_coord(filename=self.coordfile)

        self.controlfile.read(self.mol)
        if self.aoforceoutput:
            self.aoforceoutput.read(self.mol)
        else:
            self.controlfile.read_hessian(self.mol)

    def get_tensor_deriv_c(self, tens, ncomp=None):
        if tens == 'dipole':
            return self.controlfile.dipgrad
        else:
            raise Exception('Not implemented for Turbomole')
예제 #2
0
파일: PyAKIRA.py 프로젝트: xis19/LocVib
    def __init__(self,
                 iterationsfile='akira_iterations.out',
                 coordfile='coord'):
        self.mol = VibToolsMolecule()

        self.iterationsfile = iterationsfile
        self.coordfile = coordfile

        self.modes = None
        self.irints = None
예제 #3
0
    def __init__(self, controlfile='control', coordfile='coord', outname=None):
        self.mol = VibToolsMolecule()
        self.coordfile = coordfile

        if outname:
            print "WARNING: normal modes are read from aoforce output file"

            self.aoforceoutput = AOForceOutputFile(filename=outname)
        else:
            self.aoforceoutput = None
        self.controlfile = TMControlFile(filename=controlfile)
예제 #4
0
    def __init__(self,
                 outname='snf.out',
                 restartname='restart',
                 coordfile='coord'):
        self.mol = VibToolsMolecule()
        self.snfoutput = SNFOutputFile(filename=outname)
        self.snfcontrol = SNFControlFile()
        self.restartfile = SNFRestartFile()
        self.restartname = restartname
        self.coordfile = coordfile

        self.intonly = False
예제 #5
0
파일: PyVASP.py 프로젝트: xis19/LocVib
    def __init__(self, output='full-output.vasp', coordfile='coord'):
        """
        Constructor for VASPResults
        
        All arguments are optional, leaving out an argument will choose default settings.

        @param coordfile: path to Turbomole formated coordinates file (default: pwd/coord)
        @type coordfile: str
        @param output: path to VASP output file (OUTCAR) (default: full-output.vasp)
        @type output: str 
        """
        self.mol = VibToolsMolecule()
        self.coordfile = coordfile

        self.output = VASPoutput(filename=output)
예제 #6
0
파일: PyVASP.py 프로젝트: xis19/LocVib
class VASPResults(Results):
    """
    Class that reads in and contains VASP results.
    """
    def __init__(self, output='full-output.vasp', coordfile='coord'):
        """
        Constructor for VASPResults
        
        All arguments are optional, leaving out an argument will choose default settings.

        @param coordfile: path to Turbomole formated coordinates file (default: pwd/coord)
        @type coordfile: str
        @param output: path to VASP output file (OUTCAR) (default: full-output.vasp)
        @type output: str 
        """
        self.mol = VibToolsMolecule()
        self.coordfile = coordfile

        self.output = VASPoutput(filename=output)

    def _get_modes(self):
        return self.output.modes

    modes = property(_get_modes)

    def read(self):
        """
        Reading the results.
        """
        self.mol.read_from_coord(filename=self.coordfile)

        self.output.read(self.mol)
        self.output.read_hessian(self.mol)

    def get_tensor_deriv_c(self, tens, ncomp=None):
        if tens == 'dipole':
            return self.output.dipgrad
        else:
            raise Exception('Not implemented')
예제 #7
0
파일: PyAKIRA.py 프로젝트: xis19/LocVib
class AKIRAResults(Results):
    def __init__(self,
                 iterationsfile='akira_iterations.out',
                 coordfile='coord'):
        self.mol = VibToolsMolecule()

        self.iterationsfile = iterationsfile
        self.coordfile = coordfile

        self.modes = None
        self.irints = None

    def read(self):
        import numpy, re

        self.mol.read_from_coord(filename=self.coordfile)

        #read akira iterations
        f = open(self.iterationsfile)
        lines = f.readlines()
        f.close()
        for i, l in enumerate(lines):
            if re.search('Final results from module Davidson', l):
                start = i
        nbas = int(lines[start + 3].split()[-1])
        lines = lines[start + 8:start + 8 + nbas]
        modes = []
        for l in lines:
            spl = l.split()
            if spl[10] == 'YES':
                modes.append([float(spl[2]), float(spl[8])])

        self.modes = VibModes(len(modes), self.mol)
        self.modes.set_freqs(numpy.array([m[0] for m in modes]))
        self.irints = numpy.array([m[1] for m in modes])

    def get_ir_intensity(self):
        return self.irints
예제 #8
0
    def __init__(self):
        self.mol = VibToolsMolecule()

        self.modes = None  # instance of class VibModes
        self.lwl = None
예제 #9
0
class SNFResults(Results):
    def __init__(self,
                 outname='snf.out',
                 restartname='restart',
                 coordfile='coord'):
        self.mol = VibToolsMolecule()
        self.snfoutput = SNFOutputFile(filename=outname)
        self.snfcontrol = SNFControlFile()
        self.restartfile = SNFRestartFile()
        self.restartname = restartname
        self.coordfile = coordfile

        self.intonly = False

    def _get_modes(self):
        if self.snfoutput.intonly:
            return self.snfcontrol.modes
        else:
            return self.snfoutput.modes

    modes = property(_get_modes)
    lwl = property(lambda self: self.snfoutput.lwl)

    def read(self):
        self.mol.read_from_coord(filename=self.coordfile)

        self.snfoutput.read(self.mol)
        self.intonly = self.snfoutput.intonly

        if self.snfoutput.intonly:
            self.snfcontrol.read(self.mol)

        if self.restartname:
            self.restartfile.read(filename=self.restartname)
        else:
            self.snfoutput.read_derivatives(self.mol)

            self.dipole_deriv_c = self.snfoutput.dipole
            self.pollen_deriv_c = self.snfoutput.pollen[:, :, :
                                                        6] / Bohr_in_Angstrom**2
            self.polvel_deriv_c = self.snfoutput.polvel[:, :, :
                                                        6] / Bohr_in_Angstrom**2
            self.gtenlen_deriv_c = self.snfoutput.gtenlen
            self.gtenvel_deriv_c = self.snfoutput.gtenvel
            self.aten_deriv_c = self.snfoutput.aten

    def get_tensor_mean(self, tens, ncomp=None):
        tensor = eval('self.restartfile' + '.' + tens)

        ncalcsets = tensor.shape[0]
        nval = tensor.shape[1] / 2
        if (ncomp == None):
            ncomp = tensor.shape[2]

        displ = self.restartfile.displ

        mean = numpy.zeros((ncalcsets, nval, ncomp))

        for i in range(nval):
            mean[:, i, :] = (tensor[:, 2 * i, :ncomp] +
                             tensor[:, 2 * i + 1, :ncomp]) / 2.0

        return mean

    def get_tensor_deriv_c(self, tens, ncomp=None):

        if hasattr(self, tens + '_deriv_c'):
            return eval('self.' + tens + '_deriv_c')

        if not (self.restartfile.iaus == 2):
            raise Exception('Differentiation only implemented for iaus = 2')

        if self.intonly:
            raise Exception(
                'Cartesian derivatives not available in intensities only mode')

        tensor = eval('self.restartfile' + '.' + tens)

        natoms = tensor.shape[0]
        if (ncomp == None):
            ncomp = tensor.shape[2]

        displ = self.restartfile.displ

        deriv = numpy.zeros((natoms, 3, ncomp))

        for i in range(3):
            deriv[:, i, :] = (tensor[:, 2 * i, :ncomp] -
                              tensor[:, 2 * i + 1, :ncomp]) / (2.0 * displ)

        setattr(self, tens + '_deriv_c', deriv)

        return deriv

    def get_tensor_deriv_nm(self, tens, ncomp=None, modes=None):

        if modes == None:
            if hasattr(self, tens + '_deriv_nm'):
                return eval('self.' + tens + '_deriv_nm')
        elif self.intonly:
            raise Exception(
                'Argument modes of get_tensor_deriv_nm must be None in intensities-only mode'
            )

        if self.intonly:
            tensor = eval('self.restartfile' + '.' + tens)

            nmodes = tensor.shape[0]
            if (ncomp == None):
                ncomp = tensor.shape[2]

            displ = self.restartfile.displ

            deriv_nm = numpy.zeros((nmodes, ncomp))
            deriv_nm[:, :] = (tensor[:, 0, :ncomp] -
                              tensor[:, 1, :ncomp]) / (2.0 * displ)

            modes = self.get_c_normalmodes()
            for i in range(nmodes):
                deriv_nm[i, :] = deriv_nm[i, :] * math.sqrt(sum(modes[i, :]**
                                                                2))

        else:
            deriv_nm = Results.get_tensor_deriv_nm(self, tens, ncomp, modes)

        if modes == None:
            setattr(self, tens + '_deriv_nm', deriv_nm)

        return deriv_nm

    def check_consistency(self):
        print
        print "Checking consistency of SNF restart file "
        print "  Large numbers mean that the change of the polarizabilities deviates from linear behavior."
        print

        def check(ten):
            if ten.startswith('pol'):
                mean_pol = self.get_tensor_mean(ten, 6)
            else:
                mean_pol = self.get_tensor_mean(ten)
            ncalcsets = mean_pol.shape[0]
            nval = mean_pol.shape[1]
            ncomp = mean_pol.shape[2]

            mean_pol = mean_pol.reshape((ncalcsets * nval, ncomp))
            for icomp in range(ncomp):
                print " %14.8f  min: %3i  max:  %3i" % \
                      (mean_pol[:,icomp].max()-mean_pol[:,icomp].min(),
                       mean_pol[:,icomp].argmin(), mean_pol[:,icomp].argmax() )
            print

            wrong = {}

            for i in range(ncalcsets):
                if (max(abs(mean_pol[3 * i:3 * i + 3, 0] - mean_pol[0, 0])) >
                        0.001):
                    wrong[i + 1] = [
                        abs(mean_pol[3 * i, 0] - mean_pol[0, 0]) > 0.001,
                        abs(mean_pol[3 * i + 1, 0] - mean_pol[0, 0]) > 0.001,
                        abs(mean_pol[3 * i + 2, 0] - mean_pol[0, 0]) > 0.001
                    ]
                    print i + 1, mean_pol[3 * i:3 * i + 3, 0] - mean_pol[0, 0]

            return wrong

        print " Dipole moment "
        return check('dipole')

        return

        print " Polarizability (length) "
        check('pollen')

        print " Polarizability (vel) "
        check('polvel')

        print " G-tensor (len) "
        check('gtenlen')

        print " G-tensor (vel) "
        check('gtenvel')

        print " A-tensor "
        check('aten')