Esempio n. 1
0
def minimize_energy(traj_file):
	"""
	Run a BFGS energy minimization of the smamp molecule in vacuum.

	Args:
	traj_file: the path to a trajectory file (all atom format)

	Returns:
	struc: an internal molecular structure object
	calc: internal calculation object	
	"""

	# Read in the trajectory file
	struc = read(traj_file)
	# Set up the box
	struc.set_cell([25,25,25])
	struc.set_pbc([0,0,0])
	struc.center()
	# Define gpaw convergence&simulation parameters
	calc  = GPAW(xc='PBE', h=0.2, charge=0,
		     spinpol=True, convergence={'energy': 0.001})
	struc.set_calculator(calc)
	dyn = BFGSLineSearch(struc, trajectory='molecule.traj',
			     restart='bfgs_ls.pckl', logfile='BFGSLinSearch.log')

	# run the simulation
	dyn.run(fmax=0.05)

	# Maybe this is useful? Does not seem to be needed.
	# Epot  = struc.get_potential_energy()

	# Save everything into a restart file
	calc.write('restart.gpw', mode='all')

	return struc, calc
 def minimise(self, cluster):
     '''Minimise a cluster
     parameters:
     cluster- a Cluster object from bcga.cluster
     
     Using this method will overwrite the coordinates and energy of the
     supplied Cluster object.'''
     # Fix overlapping atoms to avoid NWChem errors
     cluster.fix_overlaps(1.5)
     # Set up element labels for NWChem
     atom_string = ""
     for i in range(0, len(cluster.labels)):
         atom_string += cluster.labels[i] + str(
             get_composition(cluster.atom_types)[i])
     print(atom_string)
     mol = Atoms(atom_string,
                 positions=cluster._coords,
                 cell=(6.0, 6.0, 6.0))
     mol.center()
     # Run GPAW calculation
     calc = GPAW(**self.GPAWargs)
     mol.set_calculator(calc)
     opt = BFGSLineSearch(mol)
     try:
         opt.run(fmax=0.25)
     except:
         sys.exit()
     # Get back cluster properties from GPAW
     cluster.energy = mol.get_potential_energy()
     cluster.quenched = True
     return cluster
Esempio n. 3
0
def createparticle(type1, type2, numbertype1):
    calc = QSC()
    atoms = ase.io.read('POSCAR_genetic', format='vasp')
    shell = deepcopy(atoms)
    core = deepcopy(atoms)
    for i in range(85, 225):
        core.pop(85)
    for i in range(85):
        shell.pop(0)
    dummyarray = core.get_chemical_symbols()
    for i in range(numbertype1):
        dummyarray[i] = type1
    for i in range(numbertype1, 85):
        dummyarray[i] = type2
    random.shuffle(dummyarray)
    core.set_chemical_symbols(dummyarray)
    for i in range(len(shell)):
        core.append(shell.pop(0))
    core.set_calculator(calc)
    opt = BFGSLineSearch(core)
    opt.run(steps=8)
    opt = FIRE(core)
    opt.run(steps=2000)
    return core
Esempio n. 4
0
#!/usr/bin/env python

#PBS -m ae
#PBS -q verylong
#PBS -l nodes=1:ppn=8
#!/usr/bin/env python

from ase.io import read
from gpaw import GPAW
from ase.optimize.bfgslinesearch import BFGSLineSearch

slab = read('CH4Au532.xyz')
slab.set_cell([[7.309254, 0., 0.], [4.872836, 7.509545, 0.], [0., 0., 20.]],
              scale_atoms=False)
slab.set_pbc((1, 1, 1))

calc = GPAW(h=0.18, kpts=(4, 4, 1))
slab.set_calculator(calc)

dyn = BFGSLineSearch(slab, trajectory='relax.traj')
dyn.run(fmax=0.02)
Esempio n. 5
0
parser.add_argument('outfile_pckl',
                    nargs='?',
                    metavar='bfgs_ls.pckl',
                    default='bfgs_ls.pckl',
                    help="Restart file, default 'bfgs_ls.pckl'")
parser.add_argument('logfile',
                    nargs='?',
                    metavar='BFGSLinSearch.log',
                    default='BFGSLinSearch.log',
                    help="Optimization's log, default 'BFGSLinSearch.log'")

args = parser.parse_args()

struc = molecule('H2O')
struc.set_pbc([0, 0, 0])
struc.set_cell([5, 5, 5])
struc.center()

calc = GPAW(xc='PBE',
            h=0.2,
            charge=0,
            spinpol=True,
            convergence={'energy': 0.001})
struc.set_calculator(calc)

dyn = BFGSLineSearch(struc,
                     trajectory=args.outfile_traj,
                     restart=args.outfile_pckl,
                     logfile=args.logfile)
dyn.run(fmax=0.05)
Esempio n. 6
0
traj_file = 'benzene.traj'

if not os.path.isfile(traj_file):
    struc.set_cell([15, 15, 15])
    struc.set_pbc([0, 0, 0])
    struc.center()
    calc = GPAW(xc='PBE',
                h=0.2,
                charge=0,
                spinpol=True,
                convergence={'energy': 0.001})

    struc.set_calculator(calc)
    #opt   = FIRE(struc, trajectory='benzene.traj', logfile='fire.log')
    dyn = BFGSLineSearch(struc,
                         trajectory=traj_file,
                         restart='bfgs_ls.pckl',
                         logfile='BFGSLinSearch.log')
    dyn.run(fmax=0.05)

# Did not find any documentation on how to directly continue with results
struc = read(traj_file)
calc = GPAW(xc='PBE',
            h=0.2,
            charge=0,
            spinpol=True,
            convergence={'energy': 0.001})
struc.set_calculator(calc)  # is it necessary?
struc.get_potential_energy()

vHtg = struc.calc.get_electrostatic_potential()
rho4 = struc.calc.get_all_electron_density(gridrefinement=4)
Esempio n. 7
0
#Relax the Au 55 atoms cluster with both lcao and paw modes
cluster = read('Au55.xyz')
cell = [(17.79365715,0,0),
        (0,19.60846479,0),
        (0,0, 19.84025464)]
cluster.set_cell(cell,scale_atoms=False)
cluster.center()

kwargs_lcao = dict(mode='lcao',
              #basis='dzp',
              convergence={'density':0.1, 'energy':0.1})

calc = GPAW(h=0.18,txt=None,**kwargs_lcao)
cluster.set_calculator(calc)

dyn1 = BFGSLineSearch(cluster, trajectory='Au_cluster_lcao.traj')
dyn1.run(fmax=0.02)
e_cluster_lcao = cluster.get_potential_energy()

#cluster.set_calculator(GPAW(h=0.18,tex=None))
dyn2 = BFGSLineSearch(cluster, trajectory='Au_cluster_paw.traj')
dyn2.run(fmax=0.02)
e_cluster_paw = cluster.get_potential_energy()

#Relax CO molecule with both lcao and paw modes
CO = Atoms([Atom('C',(1.0,1.0,1.0)),
            Atom('O',(1.0,1.0,2.3))],
            cell=(12,12.5,14.5))
CO.set_calculator(calc)
CO.center()
dyn3 = BFGSLineSearch(CO)