5.3.2. NBO with ADF

NBO 6.0 is a tool for Natural Bond order analysis that uses the results of an ADF calculation. More information about NBO can be found in the corresponding section of the ADF manual.

NBO analysis is performed based on a prior ADF calculation (with some special keywords) by using two separate binary executables: adfnbo and gennbo6. In this case no special job type is created for these binaries. Instead of that we extend the ADFJob class in such a way that calls of adfnbo and gennbo6 are appended to the usual ADF runscript. We also make sure that all the required ADF keywords are present in the initial ADF input file. Input keywords for adfnbo are taken from myjob.settings.adfnbo. All this work happens in prerun(). No specialized Results subclass is defined for ADFNBOJob.

The source code of the whole module:

from ..interfaces.adfsuite.adf import ADFJob
from ..core.functions import log
from ..core.settings import ig

__all__ = ['ADFNBOJob']

class ADFNBOJob(ADFJob):

    def prerun(self):
        s = self.settings.input
        s[ig('fullfock')] = True
        s[ig('aomat2file')] = True
        s[ig('symmetry')] = 'NoSym'
        s[ig('basis')][ig('core')] = 'None'
        save = s.find_case('save')
        if save in s:
            if isinstance(s.save, str):
                s.save += ' TAPE15'
            elif isinstance(s.save, list):
                s.save.append('TAPE15')
            else:
                log("WARNING: 'SAVE TAPE15' could not be added to the input settings of {}. Make sure (thisjob).settings.input.save is a string or a list.".format(self.name), 1)
        else:
            s[save] = 'TAPE15'

        if isinstance(self.settings.adfnbo, list):
            adfnbo_input = self.settings.adfnbo
        else:
            adfnbo_input = ['write', 'spherical', 'fock']
            log('WARNING: (thisjob).settings.adfnbo should be a list. Using default settings: write, fock, spherical', 1)
        self.settings.runscript.post = '$ADFBIN/adfnbo <<eor\n' + '\n'.join(adfnbo_input) + '\neor\n\n$ADFBIN/gennbo6 FILE47\n'

An example usage:

mol = Molecule('methane.xyz')

s = Settings()
s.input.basis.type = 'DZP'
s.input.xc.lda = 'SCF VWN'
s.input.relativistic = 'scalar zora'
s.adfnbo = ['write', 'spherical', 'fock']

j = ADFNBOJob(molecule=mol, settings=s)
r = j.run()

lines = r.get_output_chunk(begin='NATURAL BOND ORBITALS (Summary):', end='Charge unit', inc_begin=True, inc_end=True)
for line in lines: print(line)