Пример #1
0
    def write_3D(self, bias, file, filetype=None):
        """Write the density as a 3D file.

        Units: [e/A^3]"""
        self.calculate_ldos(bias)
        self.calc.wfs.kd.comm.sum(self.ldos)
        ldos = self.gd.collect(self.ldos)
        # print "write: integrated =", self.gd.integrate(self.ldos)

        if mpi.rank != MASTER:
            return

        if filetype is None:
            # estimate file type from name ending
            filetype = file.split('.')[-1]
        filetype.lower()

        if filetype == 'cube':
            write_cube(file, self.calc.get_atoms(), ldos / Bohr**3)
        elif filetype == 'plt':
            write_plt(file, self.calc.get_atoms(), ldos / Bohr**3)
        else:
            raise NotImplementedError('unknown file type "' + filetype + '"')
Пример #2
0
    def write_3D(self, bias, file, filetype=None):
        """Write the density as a 3D file.

        Units: [e/A^3]"""
        self.calculate_ldos(bias)
        self.calc.wfs.kpt_comm.sum(self.ldos)
        ldos = self.gd.collect(self.ldos)
##        print "write: integrated =", self.gd.integrate(self.ldos)
        
        if mpi.rank != MASTER:
            return

        if filetype is None:
            # estimate file type from name ending
            filetype = file.split('.')[-1]
        filetype.lower()

        if filetype == 'cube':
            write_cube(file, self.calc.get_atoms(), ldos / Bohr**3)
        elif filetype == 'plt':
            write_plt(file, self.calc.get_atoms(), ldos / Bohr**3)
        else:
            raise NotImplementedError('unknown file type "' + filetype + '"')
Пример #3
0
H2.rotate(57, [1, 1, 1])

fname = 'H2.gpw'
if (not load) or (not os.path.exists(fname)):
    calc = GPAW(xc='PBE', nbands=2, spinpol=False, txt=txt)
    H2.set_calculator(calc)
    H2.get_potential_energy()
    if load:
        calc.write(fname, 'all')
else:
    calc = GPAW(fname, txt=txt)
    calc.initialize_wave_functions()

fname = 'aed.plt'
cell = calc.get_atoms().get_cell()
# aed = calc.get_all_electron_density(1, pad=False)
aed = calc.get_pseudo_density(1, pad=False)
# aed = calc.wfs.gd.collect(aed)

if mpi.size == 1:
    data_org = [aed, cell]
    write_plt(fname, calc.get_atoms(), aed)

    # check if read arrays match the written ones
    data = read_plt(fname)
    for d, do in zip(data, data_org):
        dd2 = (d - do)**2
        norm = dd2.sum()
        print(norm)
        assert(norm < 1e-10)
Пример #4
0
fname = 'H2.gpw'
if (not load) or (not os.path.exists(fname)):
    calc = GPAW(xc='PBE', nbands=2, spinpol=False, txt=txt)
    H2.set_calculator(calc)
    H2.get_potential_energy()
    if load:
        calc.write(fname, 'all')
else:
    calc = GPAW(fname, txt=txt)
    calc.initialize_wave_functions()

import gpaw.mpi as mpi
fname = 'aed.plt'
cell = calc.get_atoms().get_cell()
#aed = calc.get_all_electron_density(1, pad=False)
aed = calc.get_pseudo_density(1, pad=False)
#aed = calc.wfs.gd.collect(aed)

if mpi.size == 1:
    data_org = [aed, cell]
    write_plt(fname, calc.get_atoms(), aed)
    
    # check if read arrays match the written ones
    data = read_plt(fname)
    for d, do in zip(data, data_org):
        dd2 = (d - do)**2
        norm = dd2.sum() 
        print(norm)
        assert(norm < 1e-10)
Пример #5
0
from __future__ import print_function
from ase.io.plt import write_plt
from gpaw import restart

basename = 'CO'

# load binary file and get calculator
atoms, calc = restart(basename + '.gpw')

# loop over all wfs and write their cube files
nbands = calc.get_number_of_bands()

for band in range(nbands):
    wf = calc.get_pseudo_wave_function(band=band)
    fname = '{0}_{1}.plt'.format(basename, band)
    print('writing wf', band, 'to file', fname)
    write_plt(fname, atoms, data=wf)