Example #1
0
    def analyse(self, atomsfile=None):
        BulkTask.analyse(self)

        for name, data in self.data.items():
            if 'strains' in data:
                atoms = self.create_system(name)
                volume = atoms.get_volume()
                data['volume error [%]'] = (data['volume'] / volume - 1) * 100
                if self.collection.xc == 'PBE':
                    B = self.collection.data[name][-1] * units.kJ * 1e-24
                    data['B error [%]'] = (data['B'] / B - 1) * 100

        if atomsfile:
            atomdata = read_json(atomsfile)
            for name, data in self.data.items():
                atoms = self.create_system(name)
                e = -data['energy']
                for atom in atoms:
                    e += atomdata[atom.symbol]['energy']
                e /= len(atoms)
                data['cohesive energy'] = e
                if self.collection.xc == 'PBE':
                    eref = self.collection.data[name][7]
                else:
                    eref = self.collection.data[name][9]
                data['cohesive energy error [%]'] = (e / eref - 1) * 100

            self.summary_keys += ['cohesive energy',
                                  'cohesive energy error [%]']
Example #2
0
    def __init__(self, **kwargs):
        BulkTask.__init__(self,
                          collection=DeltaCodesDFTCollection(),
                          **kwargs)

        self.summary_keys = ['energy', 'fitted energy', 'volume',
                             'volume error [%]', 'B', 'B error [%]']
Example #3
0
    def __init__(self, **kwargs):
        BulkTask.__init__(self,
                          collection=HarlSchimkaKresseBulkCollection('PBE'),
                          **kwargs)

        self.summary_keys = ['energy', 'fitted energy', 'volume',
                             'volume error [%]', 'B', 'B error [%]']
Example #4
0
    def __init__(self, **kwargs):
        BulkTask.__init__(self, collection=DeltaCodesDFTCollection(), **kwargs)

        self.summary_keys = [
            'energy', 'fitted energy', 'volume', 'volume error [%]', 'B',
            'B error [%]'
        ]
Example #5
0
    def __init__(self, xc='PBE', **kwargs):
        BulkTask.__init__(self,
                          collection=HaasTranBlahaBulkCollection(xc),
                          **kwargs)

        self.summary_keys = [
            'energy', 'fitted energy', 'crystal structure', 'strukturbericht',
            'lattice constant', 'lattice constant error [%]', 'volume',
            'volume error [%]', 'B', 'B error [%]'
        ]
Example #6
0
File: htb.py Project: PHOTOX/fuase
    def __init__(self, xc='PBE', **kwargs):
        BulkTask.__init__(self,
                          collection=HaasTranBlahaBulkCollection(xc),
                          **kwargs)

        self.summary_keys = ['energy', 'fitted energy',
                             'crystal structure',
                             'strukturbericht',
                             'lattice constant', 'lattice constant error [%]',
                             'volume', 'volume error [%]',
                             'B', 'B error [%]']
Example #7
0
    def analyse(self, atomsfile=None):
        try:
            BulkTask.analyse(self)
        except ValueError:  # allow fit outside of range
            pass

        for name, data in self.data.items():
            if 'strains' in data:
                atoms = self.create_system(name)
                # full equation of state
                # use relaxed volume if present
                if 'relaxed volume' in data:
                    volume = data['relaxed volume']
                else:
                    volume = atoms.get_volume()
                volumes = data['strains']**3 * volume
                energies = data['energies']
                eos = FullEquationOfState(volumes, energies)
                try:
                    v, e, B0, B1, R = eos.fit()
                except ValueError:
                    pass
                else:
                    data['dcdft fitted energy'] = e / len(atoms)
                    data['dcdft volume'] = v / len(atoms)
                    data['dcdft B0'] = B0
                    data['dcdft B1'] = B1
                    data['dcdft R'] = R

        if atomsfile:
            # MDTMP: TODO
            atomdata = read_json(atomsfile)
            for name, data in self.data.items():
                atoms = self.create_system(name)
                e = -data['energy']
                for atom in atoms:
                    e += atomdata[atom.symbol]['energy']
                e /= len(atoms)
                data['cohesive energy'] = e
                if self.collection.xc == 'PBE':
                    eref = self.collection.data[name][7]
                else:
                    eref = self.collection.data[name][9]
                data['cohesive energy error [%]'] = (e / eref - 1) * 100

            self.summary_keys += [
                'cohesive energy', 'cohesive energy error [%]'
            ]
Example #8
0
    def analyse(self, atomsfile=None):
        try:
            BulkTask.analyse(self)
        except ValueError: # allow fit outside of range
            pass

        for name, data in self.data.items():
            if 'strains' in data:
                atoms = self.create_system(name)
                # full equation of state
                # use relaxed volume if present
                if 'relaxed volume' in data:
                    volume = data['relaxed volume']
                else:
                    volume = atoms.get_volume()
                volumes = data['strains']**3 * volume
                energies = data['energies']
                eos = FullEquationOfState(volumes, energies)
                try:
                    v, e, B0, B1, R = eos.fit()
                except ValueError:
                    pass
                else:
                    data['dcdft fitted energy'] = e / len(atoms)
                    data['dcdft volume'] = v / len(atoms)
                    data['dcdft B0'] = B0
                    data['dcdft B1'] = B1
                    data['dcdft R'] = R

        if atomsfile:
            # MDTMP: TODO
            atomdata = read_json(atomsfile)
            for name, data in self.data.items():
                atoms = self.create_system(name)
                e = -data['energy']
                for atom in atoms:
                    e += atomdata[atom.symbol]['energy']
                e /= len(atoms)
                data['cohesive energy'] = e
                if self.collection.xc == 'PBE':
                    eref = self.collection.data[name][7]
                else:
                    eref = self.collection.data[name][9]
                data['cohesive energy error [%]'] = (e / eref - 1) * 100

            self.summary_keys += ['cohesive energy',
                                  'cohesive energy error [%]']
Example #9
0
def run(args=sys.argv[1:], calcname='emt', task=None):

    if isinstance(args, str):
        args = args.split(' ')

    argsoriginal = args[:]

    if len(args) > 0 and args[0] in calcnames:
        calcname = args.pop(0)

    if task is None:
        taskname = 'molecule'
        if (len(args) > 0 and
            (args[0] in ['molecule', 'bulk'] or args[0].endswith('.py'))):
            taskname = args.pop(0)

        if taskname.endswith('.py'):
            locals = {}
            execfile(taskname, locals, locals)
            tasks = [task for task in locals.values() if isinstance(task, Task)]
            assert len(tasks) == 1
            task = tasks[0]
        elif taskname == 'bulk':
            task = BulkTask()
        else:
            task = MoleculeTask()

    if len(args) == 0 and task.collection is None:
        sys.stderr.write(
            usage % textwrap.fill(', '.join(calcnames[:-1]) +
                                  ' or ' + calcnames[-1] +
                                  '.  Default value is emt.',
                                  initial_indent='calculator: ',
                                  subsequent_indent=' ' * 12))
        return
    
    task.set_calculator_factory(calcname)

    args = task.parse_args(args)

    if task.interactive_python_session:
        if '-i' in argsoriginal:
            argsoriginal.remove('-i')
        if '--interactive-python-session' in argsoriginal:
            argsoriginal.remove('--interactive-python-session')
        file = tempfile.NamedTemporaryFile()
        file.write('import os\n')
        file.write('if "PYTHONSTARTUP" in os.environ:\n')
        file.write('    execfile(os.environ["PYTHONSTARTUP"])\n')
        file.write('from ase.tasks.main import run\n')
        file.write('atoms, task = run(%r, %r)\n' % (argsoriginal, calcname))
        file.flush()
        os.system('python -i %s' % file.name)
        return

    atoms = task.run(args)

    return atoms, task
Example #10
0
File: main.py Project: jboes/ase
def run(args=sys.argv[1:], calcname='emt', task=None):

    if isinstance(args, str):
        # leading/trailing/extra-mid spaces result in weird errors
        args = ' '.join(args.split())
        args = args.split(' ')

    argsoriginal = args[:]

    if len(args) > 0 and args[0] in calcnames:
        calcname = args.pop(0)

    if task is None:
        taskname = 'molecule'
        if (len(args) > 0 and
            (args[0] in ['molecule', 'bulk'] or args[0].endswith('.py'))):
            taskname = args.pop(0)

        if taskname.endswith('.py'):
            locals = {}
            exec(compile(open(taskname).read(), taskname, 'exec'), locals, locals)
            tasks = [task for task in locals.values() if isinstance(task, Task)]
            assert len(tasks) == 1
            task = tasks[0]
        elif taskname == 'bulk':
            task = BulkTask()
        else:
            task = MoleculeTask()

    if len(args) == 0 and task.collection is None:
        sys.stderr.write(
            usage % textwrap.fill(', '.join(calcnames[:-1]) +
                                  ' or ' + calcnames[-1] +
                                  '.  Default value is emt.',
                                  initial_indent='calculator: ',
                                  subsequent_indent=' ' * 12))
        return

    task.set_calculator_factory(calcname)

    args = task.parse_args(args)

    if task.interactive_python_session:
        if '-i' in argsoriginal:
            argsoriginal.remove('-i')
        if '--interactive-python-session' in argsoriginal:
            argsoriginal.remove('--interactive-python-session')
        file = tempfile.NamedTemporaryFile()
        file.write('import os\n')
        file.write('if "PYTHONSTARTUP" in os.environ:\n')
        file.write('    execfile(os.environ["PYTHONSTARTUP"])\n')
        file.write('from ase.tasks.main import run\n')
        file.write('atoms, task = run(%r, %r)\n' % (argsoriginal, calcname))
        file.flush()
        os.system('python -i %s' % file.name)
        return

    atoms = task.run(args)

    return atoms, task
Example #11
0
    def analyse(self, atomsfile=None):
        try:
            BulkTask.analyse(self)
        except ValueError:  # allow fit outside of range
            pass

        for name, data in self.data.items():
            if 'strains' in data:
                atoms = self.create_system(name)
                # use relaxed volume if present
                if 'relaxed volume' in data:
                    volume = data['relaxed volume']
                else:
                    volume = atoms.get_volume()
                volumes = data['strains']**3 * volume
                energies = data['energies']
                # allow selection of eos type independent of data
                if self.eos is not None:
                    eos = EquationOfState(volumes, energies, self.eos)
                else:
                    eos = EquationOfState(volumes, energies)
                try:
                    v, e, B = eos.fit()
                except ValueError:
                    pass
                else:
                    data['fitted energy'] = e
                    data['volume'] = v
                    data['B'] = B
                # with respect tot the reference volume
                data['volume error [%]'] = (
                    data['volume'] / atoms.get_volume() - 1) * 100
                if self.collection.B:
                    i = self.collection.labels.index(self.collection.xc) - 1
                    B = self.collection.B[name][i] * units.kJ * 1e-24
                    data['B error [%]'] = (data['B'] / B - 1) * 100
                else:
                    data['B error [%]'] = None
                data['strukturbericht'] = self.collection.data[name][0]
                data['crystal structure'] = strukturbericht[
                    data['strukturbericht']]
                # calculate lattice constant from volume
                cs = data['crystal structure']
                if cs == 'bcc':
                    a0 = (volume * 2)**(1 / 3.)
                    a = (data['volume'] * 2)**(1 / 3.)
                elif cs == 'cesiumchloride':
                    a0 = (volume)**(1 / 3.)
                    a = (data['volume'])**(1 / 3.)
                elif cs in [
                        'fcc', 'diamond', 'zincblende', 'rocksalt', 'fluorite'
                ]:
                    a0 = (volume * 4)**(1 / 3.)
                    a = (data['volume'] * 4)**(1 / 3.)
                i = self.collection.labels.index(self.collection.xc) - 1
                a0_ref = self.collection.data[name][i]
                if 'relaxed volume' not in data:
                    # no volume relaxation performed - volume equals the reference one
                    assert abs(a0 - a0_ref) < 1.e-4
                data['lattice constant'] = a
                data['lattice constant error [%]'] = (a -
                                                      a0_ref) / a0_ref * 100

        if atomsfile:
            # MDTMP: TODO
            atomdata = read_json(atomsfile)
            for name, data in self.data.items():
                atoms = self.create_system(name)
                e = -data['energy']
                for atom in atoms:
                    e += atomdata[atom.symbol]['energy']
                e /= len(atoms)
                data['cohesive energy'] = e
                if self.collection.xc == 'PBE':
                    eref = self.collection.data[name][7]
                else:
                    eref = self.collection.data[name][9]
                data['cohesive energy error [%]'] = (e / eref - 1) * 100

            self.summary_keys += [
                'cohesive energy', 'cohesive energy error [%]'
            ]
Example #12
0
File: htb.py Project: PHOTOX/fuase
    def analyse(self, atomsfile=None):
        try:
            BulkTask.analyse(self)
        except ValueError: # allow fit outside of range
            pass

        for name, data in self.data.items():
            if 'strains' in data:
                atoms = self.create_system(name)
                # use relaxed volume if present
                if 'relaxed volume' in data:
                    volume = data['relaxed volume']
                else:
                    volume = atoms.get_volume()
                volumes = data['strains']**3 * volume
                energies = data['energies']
                # allow selection of eos type independent of data
                if self.eos is not None:
                    eos = EquationOfState(volumes, energies, self.eos)
                else:
                    eos = EquationOfState(volumes, energies)
                try:
                    v, e, B = eos.fit()
                except ValueError:
                    pass
                else:
                    data['fitted energy'] = e
                    data['volume'] = v
                    data['B'] = B
                # with respect tot the reference volume
                data['volume error [%]'] = (data['volume'] / atoms.get_volume() - 1) * 100
                if self.collection.B:
                    i = self.collection.labels.index(self.collection.xc) - 1
                    B = self.collection.B[name][i] * units.kJ * 1e-24
                    data['B error [%]'] = (data['B'] / B - 1) * 100
                else:
                    data['B error [%]'] = None
                data['strukturbericht'] = self.collection.data[name][0]
                data['crystal structure'] = strukturbericht[data['strukturbericht']]
                # calculate lattice constant from volume
                cs = data['crystal structure']
                if cs == 'bcc':
                    a0 = (volume*2)**(1/3.)
                    a = (data['volume']*2)**(1/3.)
                elif cs == 'cesiumchloride':
                    a0 = (volume)**(1/3.)
                    a = (data['volume'])**(1/3.)
                elif cs in ['fcc',
                            'diamond',
                            'zincblende',
                            'rocksalt',
                            'fluorite']:
                    a0 = (volume*4)**(1/3.)
                    a = (data['volume']*4)**(1/3.)
                i = self.collection.labels.index(self.collection.xc) - 1
                a0_ref = self.collection.data[name][i]
                if 'relaxed volume' not in data:
                    # no volume relaxation performed - volume equals the reference one
                    assert abs(a0 - a0_ref) < 1.e-4
                data['lattice constant'] = a
                data['lattice constant error [%]'] = (a - a0_ref) / a0_ref * 100

        if atomsfile:
            # MDTMP: TODO
            atomdata = read_json(atomsfile)
            for name, data in self.data.items():
                atoms = self.create_system(name)
                e = -data['energy']
                for atom in atoms:
                    e += atomdata[atom.symbol]['energy']
                e /= len(atoms)
                data['cohesive energy'] = e
                if self.collection.xc == 'PBE':
                    eref = self.collection.data[name][7]
                else:
                    eref = self.collection.data[name][9]
                data['cohesive energy error [%]'] = (e / eref - 1) * 100

            self.summary_keys += ['cohesive energy',
                                  'cohesive energy error [%]']
Example #13
0
 def calculate(self, name, atoms):
     data = BulkTask.calculate(self, name, atoms)
     dexx = atoms.calc.get_xc_difference(HybridXC('EXX', acdf=True))
     data['selfconsistent energy'] = data['energy']
     data['energy'] += dexx
     return data
Example #14
0
 def __init__(self, **kwargs):
     BulkTask.__init__(self,
                       collection=HarlSchimkaKresseBulkCollection('EXX'),
                       **kwargs)