Ejemplo n.º 1
0
    def __init__(self,
                 filename=None,
                 configString=None,
                 sectionList=None,
                 taskList=None):
        QECalc.__init__(self)

        # tasks definition:
        # specify taskName/taskConstructur pairs
        self._taskSpec = [['pw', PWTask], ['ph', PHTask], ['q2r', Q2RTask],
                          ['matdyn', MatdynTask]]
        # Merging map sets tasks to be merged. Last two columns identify name
        # of default task (its input and output objects will be directly
        #accessible) and last column is the name of merged task object (e.g.'pwph')

        #is not implemented yet !!!!
        self._mergingMap = [
            ['pw', 'ph', 'pw', 'pwph'],
        ]

        self._populateTasks(filename, configString, sectionList, taskList)

        self.pwph = PWPHMerger(self.pw, self.ph, cleanOutDir=True)
        self.taskList = [self.pwph, self.q2r, self.matdyn]

        self._dispersion = PHDispersion(self.pw.input.structure.lattice,
                                        self.matdyn)

        self.dos = PhononDOS(self.matdyn)
Ejemplo n.º 2
0
 def gammaDispersion(self, *pathNPoints):        
     #self.pw.input.parse()
     #self.matdyn.input.parse()
     self.dispersion = PHDispersion( self.pw.input.structure.lattice, self.matdyn)
     if self.freqs.fitter.type != 'polynom':
         raise Exception('This method is only relevant for polynomial fit')
     self.dispersion = PHDispersion( self.pw.input.structure.lattice, self.matdyn)
     self.dispersion.setPath(*pathNPoints)
     self.dispersion.setValues(-self.freqs.coeff()[:,:,-1])
     self.dispersion.save('gamma_disp')
     self.dispersion.plot()
Ejemplo n.º 3
0
 def gammaDispersion(self, *pathNPoints):
     #self.pw.input.parse()
     #self.matdyn.input.parse()
     self.dispersion = PHDispersion(self.pw.input.structure.lattice,
                                    self.matdyn)
     if self.freqs.fitter.type != 'polynom':
         raise Exception('This method is only relevant for polynomial fit')
     self.dispersion = PHDispersion(self.pw.input.structure.lattice,
                                    self.matdyn)
     self.dispersion.setPath(*pathNPoints)
     self.dispersion.setValues(-self.freqs.coeff()[:, :, -1])
     self.dispersion.save('gamma_disp')
     self.dispersion.plot()
Ejemplo n.º 4
0
    def __init__(self, filename = None, configString = None, sectionList = None, taskList = None):
        QECalc.__init__(self)

        # tasks definition:
        # specify taskName/taskConstructur pairs
        self._taskSpec = [
                          ['pw', PWTask],
                          ['ph', PHTask],
                          ['q2r', Q2RTask],
                          ['matdyn', MatdynTask]
                         ]
        # Merging map sets tasks to be merged. Last two columns identify name
        # of default task (its input and output objects will be directly
        #accessible) and last column is the name of merged task object (e.g.'pwph')

        #is not implemented yet !!!!
        self._mergingMap = [ ['pw', 'ph', 'pw','pwph'],
                           ]

        self._populateTasks(filename, configString, sectionList, taskList)


        self.pwph = PWPHMerger(self.pw,self.ph, cleanOutDir = True)
        self.taskList = [self.pwph, self.q2r, self.matdyn]

        self._dispersion = PHDispersion(self.pw.input.structure.lattice, self.matdyn)

        self.dos = PhononDOS(self.matdyn)
Ejemplo n.º 5
0
class VoluPhon():
    def __init__(self, prcntVolume, filename = None ):
        """
        This class requires a set of  "n_matdyn.modes" files 
        corresponding to different volume expansions 
        prcntVolume - array with 
        """
        self.pw = PWTask(filename = filename)
        self.matdyn = MatdynTask(filename = filename)
        self.__prcntVolume = prcntVolume


    def setA(self, values, fitter):
        self.a = volufit.ValueFit(self.__prcntVolume, values, fitter)

        
    def setC(self, values, fitter):
        self.c = volufit.ValueFit(self.__prcntVolume, values, fitter)


    def setEnergy(self, values, fitter):
        self.energy = volufit.ValueFit(self.__prcntVolume, values, fitter)


    def setPhonons(self, indexRange, fitter):
        """Will read freqs from x_matdyn.modes files and fit the freqs"""
        matdynModesName = self.matdyn.setting.get('flvec')
        self.matdyn.setting.set('flvec', str(indexRange[0]) + '_' + matdynModesName)
        self.matdyn.output.parse()
        Pol, Omega, qPoints = self.matdyn.output.property('multi phonon')
        volOmega = numpy.zeros(shape=(len(indexRange), numpy.shape(Omega)[0], \
                                                      numpy.shape(Omega)[1]  ) )
        volOmega[0] = Omega
        for i in range(1,len(indexRange)):
            self.matdyn.setting.set('flvec', str(indexRange[i]) + '_' + matdynModesName)
            self.matdyn.output.parse()
            Pol, Omega, qPoints = self.matdyn.output.property('multi phonon')
            volOmega[i] = Omega
        self.matdyn.setting.set('flvec', matdynModesName)
        self.freqs = volufit.FreqFit(self.__prcntVolume, volOmega,fitter)


    def gammaDispersion(self, *pathNPoints):        
        #self.pw.input.parse()
        #self.matdyn.input.parse()
        self.dispersion = PHDispersion( self.pw.input.structure.lattice, self.matdyn)
        if self.freqs.fitter.type != 'polynom':
            raise Exception('This method is only relevant for polynomial fit')
        self.dispersion = PHDispersion( self.pw.input.structure.lattice, self.matdyn)
        self.dispersion.setPath(*pathNPoints)
        self.dispersion.setValues(-self.freqs.coeff()[:,:,-1])
        self.dispersion.save('gamma_disp')
        self.dispersion.plot()


    def prcntVolume (self):
        return self.__prcntVolume
Ejemplo n.º 6
0
class VoluPhon():
    def __init__(self, prcntVolume, filename=None):
        """
        This class requires a set of  "n_matdyn.modes" files 
        corresponding to different volume expansions 
        prcntVolume - array with 
        """
        self.pw = PWTask(filename=filename)
        self.matdyn = MatdynTask(filename=filename)
        self.__prcntVolume = prcntVolume

    def setA(self, values, fitter):
        self.a = volufit.ValueFit(self.__prcntVolume, values, fitter)

    def setC(self, values, fitter):
        self.c = volufit.ValueFit(self.__prcntVolume, values, fitter)

    def setEnergy(self, values, fitter):
        self.energy = volufit.ValueFit(self.__prcntVolume, values, fitter)

    def setPhonons(self, indexRange, fitter):
        """Will read freqs from x_matdyn.modes files and fit the freqs"""
        matdynModesName = self.matdyn.setting.get('flvec')
        self.matdyn.setting.set('flvec',
                                str(indexRange[0]) + '_' + matdynModesName)
        self.matdyn.output.parse()
        Pol, Omega, qPoints = self.matdyn.output.property('multi phonon')
        volOmega = numpy.zeros(shape=(len(indexRange), numpy.shape(Omega)[0], \
                                                      numpy.shape(Omega)[1]  ) )
        volOmega[0] = Omega
        for i in range(1, len(indexRange)):
            self.matdyn.setting.set('flvec',
                                    str(indexRange[i]) + '_' + matdynModesName)
            self.matdyn.output.parse()
            Pol, Omega, qPoints = self.matdyn.output.property('multi phonon')
            volOmega[i] = Omega
        self.matdyn.setting.set('flvec', matdynModesName)
        self.freqs = volufit.FreqFit(self.__prcntVolume, volOmega, fitter)

    def gammaDispersion(self, *pathNPoints):
        #self.pw.input.parse()
        #self.matdyn.input.parse()
        self.dispersion = PHDispersion(self.pw.input.structure.lattice,
                                       self.matdyn)
        if self.freqs.fitter.type != 'polynom':
            raise Exception('This method is only relevant for polynomial fit')
        self.dispersion = PHDispersion(self.pw.input.structure.lattice,
                                       self.matdyn)
        self.dispersion.setPath(*pathNPoints)
        self.dispersion.setValues(-self.freqs.coeff()[:, :, -1])
        self.dispersion.save('gamma_disp')
        self.dispersion.plot()

    def prcntVolume(self):
        return self.__prcntVolume
Ejemplo n.º 7
0
class MultiPhononCalc(QECalc):
    """ Calc for multi phonon calculations:
    
    Task list:
      pw     -- PWTask

      ph     -- PHTask

      q2r    -- Q2RTask

      matdyn -- MatdynTask

      pwph   -- PWPHMerger - task merger used for submission of pw.x and ph.x
      commands in a single command string

      taskList = [pwph, q2r, matdyn]
      
    Example:
      
      >>> mphonCalc = MultiPhononCalc('config.ini')
      >>> mphon.launch()
      >>> print mphon.pw.output.property('total energy')
      >>> print mphon.matdyn.output.listParsers()
      >>> print mphon.matdyn.output.property('phonon dos')
      >>> polVecs, freqs, qpoints =  mphon.lookupProperty('multi phonon')
            
    """
    def __init__(self, filename = None, configString = None, sectionList = None, taskList = None):
        QECalc.__init__(self)

        # tasks definition:
        # specify taskName/taskConstructur pairs
        self._taskSpec = [
                          ['pw', PWTask],
                          ['ph', PHTask],
                          ['q2r', Q2RTask],
                          ['matdyn', MatdynTask]
                         ]
        # Merging map sets tasks to be merged. Last two columns identify name
        # of default task (its input and output objects will be directly
        #accessible) and last column is the name of merged task object (e.g.'pwph')

        #is not implemented yet !!!!
        self._mergingMap = [ ['pw', 'ph', 'pw','pwph'],
                           ]

        self._populateTasks(filename, configString, sectionList, taskList)


        self.pwph = PWPHMerger(self.pw,self.ph, cleanOutDir = True)
        self.taskList = [self.pwph, self.q2r, self.matdyn]

        self._dispersion = PHDispersion(self.pw.input.structure.lattice, self.matdyn)

        self.dos = PhononDOS(self.matdyn)
        
    def _get_dispersion(self):
        self._dispersion.matdynTask = self.matdyn
        self._dispersion.setLattice(self.pw.input.structure.lattice)
        return self._dispersion
    dispersion = property(_get_dispersion, doc ="dispersion object") 


    def syncInputs(self):
        for task in self.taskList:
            task.input.parse()

        # remove amass from phonon input
        for param in self.ph.input.namelist('input').params:
            if 'amass(' in param:
                self.ph.input.namelist('input').remove(param)
        # initialize amass based on PW input
        for i, atom in enumerate(self.pw.input.structure.atomicSpecies):
            amass = 'amass(' + str(i+1) + ')'
            self.ph.input.namelist('input').add(amass,atom.mass)
        #sync outdir based on PW input
        self.ph.input.namelist('input').add('outdir', \
                             self.pw.input.namelist('control').param('outdir'))
Ejemplo n.º 8
0
class MultiPhononCalc(QECalc):
    """ Calc for multi phonon calculations:
    
    Task list:
      pw     -- PWTask

      ph     -- PHTask

      q2r    -- Q2RTask

      matdyn -- MatdynTask

      pwph   -- PWPHMerger - task merger used for submission of pw.x and ph.x
      commands in a single command string

      taskList = [pwph, q2r, matdyn]
      
    Example:
      
      >>> mphonCalc = MultiPhononCalc('config.ini')
      >>> mphon.launch()
      >>> print mphon.pw.output.property('total energy')
      >>> print mphon.matdyn.output.listParsers()
      >>> print mphon.matdyn.output.property('phonon dos')
      >>> polVecs, freqs, qpoints =  mphon.lookupProperty('multi phonon')
            
    """
    def __init__(self,
                 filename=None,
                 configString=None,
                 sectionList=None,
                 taskList=None):
        QECalc.__init__(self)

        # tasks definition:
        # specify taskName/taskConstructur pairs
        self._taskSpec = [['pw', PWTask], ['ph', PHTask], ['q2r', Q2RTask],
                          ['matdyn', MatdynTask]]
        # Merging map sets tasks to be merged. Last two columns identify name
        # of default task (its input and output objects will be directly
        #accessible) and last column is the name of merged task object (e.g.'pwph')

        #is not implemented yet !!!!
        self._mergingMap = [
            ['pw', 'ph', 'pw', 'pwph'],
        ]

        self._populateTasks(filename, configString, sectionList, taskList)

        self.pwph = PWPHMerger(self.pw, self.ph, cleanOutDir=True)
        self.taskList = [self.pwph, self.q2r, self.matdyn]

        self._dispersion = PHDispersion(self.pw.input.structure.lattice,
                                        self.matdyn)

        self.dos = PhononDOS(self.matdyn)

    def _get_dispersion(self):
        self._dispersion.matdynTask = self.matdyn
        self._dispersion.setLattice(self.pw.input.structure.lattice)
        return self._dispersion

    dispersion = property(_get_dispersion, doc="dispersion object")

    def syncInputs(self):
        for task in self.taskList:
            task.input.parse()

        # remove amass from phonon input
        for param in self.ph.input.namelist('input').params:
            if 'amass(' in param:
                self.ph.input.namelist('input').remove(param)
        # initialize amass based on PW input
        for i, atom in enumerate(self.pw.input.structure.atomicSpecies):
            amass = 'amass(' + str(i + 1) + ')'
            self.ph.input.namelist('input').add(amass, atom.mass)
        #sync outdir based on PW input
        self.ph.input.namelist('input').add('outdir', \
                             self.pw.input.namelist('control').param('outdir'))
Ejemplo n.º 9
0
# input/output files relevant to multiple phonon calculation
matdynInput:   matdyn.in
matdynOutput:  matdyn.out
flfrc:         mgb2666.fc
"""

if __name__ == "__main__":
    matdyn = MatdynTask(configString = configString)
    pw = PWTask(configString = configString)
    pw.input.parse()

    matdyn.input.parse()
    matdyn.syncSetting()


    phDisp = PHDispersion(pw.input.structure.lattice, matdyn)

    #phDisp.launch('M', 'Gamma', 'A', 'L', 200, 200, 200)
    nP = 100
    phDisp.launch('Gamma', 'K', 'M', 'Gamma', 'A','H', 'L', 'A', nP, nP, nP, nP , nP , nP, nP)
    #phDisp.launch('Gamma', 'H', nP)
    #phDisp.launch('Gamma', 'K', 'M', 'Gamma', nP , nP, nP)
    #phDisp.launch( 'Gamma', 'K',  nP )

   # phDisp.solveIndex((0,0,0), [-0.1,0.2,0.4])

#    matdyn.output.parse()
#
#    Pol, Omegas, qPoints = matdyn.output.property('multi phonon')
#    Pol2 = Pol.reshape(Pol.shape[0], Pol.shape[1], Pol.shape[2]*Pol.shape[3])
#    print Pol2
Ejemplo n.º 10
0
[matdyn.x]
# input/output files relevant to multiple phonon calculation
matdynInput:   matdyn.in
matdynOutput:  matdyn.out
flfrc:         mgb2666.fc
"""

if __name__ == "__main__":
    matdyn = MatdynTask(configString=configString)
    pw = PWTask(configString=configString)
    pw.input.parse()

    matdyn.input.parse()
    matdyn.syncSetting()

    phDisp = PHDispersion(pw.input.structure.lattice, matdyn)

    #phDisp.launch('M', 'Gamma', 'A', 'L', 200, 200, 200)
    nP = 100
    phDisp.launch('Gamma', 'K', 'M', 'Gamma', 'A', 'H', 'L', 'A', nP, nP, nP,
                  nP, nP, nP, nP)
    #phDisp.launch('Gamma', 'H', nP)
    #phDisp.launch('Gamma', 'K', 'M', 'Gamma', nP , nP, nP)
    #phDisp.launch( 'Gamma', 'K',  nP )

    # phDisp.solveIndex((0,0,0), [-0.1,0.2,0.4])

    #    matdyn.output.parse()
    #
    #    Pol, Omegas, qPoints = matdyn.output.property('multi phonon')
    #    Pol2 = Pol.reshape(Pol.shape[0], Pol.shape[1], Pol.shape[2]*Pol.shape[3])