Ejemplo n.º 1
0
    def __init__(self, symbol, filename=None, index=None, txt=None):
        if filename is None or filename == '-':
            formula, index = get_system(symbol)
            filename = restart_filename % formula
        calc = Calculator(filename, txt=txt)
        
        atoms = calc.get_atoms()
        symbols = atoms.get_chemical_symbols()
        if index is None:
            index = symbols.index(symbol)
        else:
            if not symbols[index] == symbol:
                raise ValueError(('Atom (%s) at specified index (%d) not of '+
                                  'requested type (%s)') % (symbols[index],
                                                            index, symbol))
        self.calc = calc
        self.filename = filename
        self.atoms = atoms
        self.symbol = symbol
        self.symbols = symbols
        self.index = index
        self.cell = atoms.get_cell().diagonal() # cubic cell
        #self.center = atoms.positions[index]
        self.spos_ac = atoms.positions / self.cell

        self.gpts = calc.wfs.gd.N_c
        if calc.kpt_u[0].psit_nG is None:
            raise RuntimeError('No wave functions found in .gpw file')
Ejemplo n.º 2
0
    def __init__(self, symbol, filename=None, index=None, txt=None):
        if filename is None or filename == '-':
            formula, index = get_system(symbol)
            filename = restart_filename % formula
        calc = Calculator(filename, txt=txt)

        atoms = calc.get_atoms()
        symbols = atoms.get_chemical_symbols()
        if index is None:
            index = symbols.index(symbol)
        else:
            if not symbols[index] == symbol:
                raise ValueError(
                    ('Atom (%s) at specified index (%d) not of ' +
                     'requested type (%s)') % (symbols[index], index, symbol))
        self.calc = calc
        self.filename = filename
        self.atoms = atoms
        self.symbol = symbol
        self.symbols = symbols
        self.index = index
        self.cell = atoms.get_cell().diagonal()  # cubic cell
        #self.center = atoms.positions[index]
        self.spos_ac = atoms.positions / self.cell

        self.gpts = calc.wfs.gd.N_c
        if calc.kpt_u[0].psit_nG is None:
            raise RuntimeError('No wave functions found in .gpw file')
Ejemplo n.º 3
0
                              txt=file_prefix + '.txt',
                              tolerance=1e-10)

            fcc.set_calculator(calc)
            #fcc[0].set_magnetic_moment(magmom)
            e = fcc.get_potential_energy()
            calc.write(file_prefix + '.gpw')
            del calc, fcc

        for nhosts in nhostsread:
            file_prefix = 'Fe_%d_%1.1f_par%d' % (nkpt, magmom, nhosts)
            print '------ restart calculation  ', file_prefix, rank * 111111111
            calc = Calculator(file_prefix + '.gpw',
                              txt=file_prefix + '_restart.txt',
                              tolerance=1e-10)
            atoms = calc.get_atoms()
            atoms.positions[0] = (0, 0, -0.0001)
            erg = atoms.get_potential_energy()

            result = 'ok'
            equal(e, erg, 1e-4)

            niter = calc.niter
            tests.append((test, result, niter, nhosts))

del calc, atoms

for test in tests:
    print "%s ---- %10s --- %d ---- %d " % (test[0], test[1], test[2], test[3])

nhosts = 8
Ejemplo n.º 4
0
                              txt=file_prefix+'.txt',
                              tolerance = 1e-10)
	
            fcc.set_calculator(calc)
            #fcc[0].set_magnetic_moment(magmom)
            e = fcc.get_potential_energy()
            calc.write(file_prefix+'.gpw')
            del calc,fcc

        for nhosts in nhostsread: 
            file_prefix = 'Fe_%d_%1.1f_par%d'%(nkpt,magmom,nhosts)
            print '------ restart calculation  ',file_prefix, rank*111111111
            calc = Calculator(file_prefix+'.gpw',
                              txt=file_prefix+'_restart.txt',
                              tolerance = 1e-10)
            atoms = calc.get_atoms()
            atoms.positions[0] = (0, 0, -0.0001)
            erg = atoms.get_potential_energy()


            result = 'ok'
            equal(e,erg,1e-4)

            niter = calc.niter
            tests.append((test,result,niter,nhosts))

del calc,atoms

for test in tests: 
    print "%s ---- %10s --- %d ---- %d "%(test[0],test[1],test[2],test[3])