コード例 #1
0
ファイル: gpaw_interface.py プロジェクト: marktoakley/PyBCGA
 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
コード例 #2
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
コード例 #3
0
 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
コード例 #4
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
コード例 #5
0
ファイル: genetic.py プロジェクト: ZacharyDPozun/PGSS
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
コード例 #6
0
ファイル: CH4Au532.py プロジェクト: yihsuanliu/gpaw
#!/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)
コード例 #7
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)
コード例 #8
0
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}
              )#poissonsolver=poissonsolver)

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)
dyn3.run(fmax=0.02)
コード例 #9
0
ファイル: Au55_cluster.py プロジェクト: thonmaker/gpaw
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)
dyn3.run(fmax=0.02)
コード例 #10
0
ファイル: CH4Au532.py プロジェクト: robwarm/gpaw-symm
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)
コード例 #11
0
ファイル: test_pjt2.py プロジェクト: mathiasljungberg/sckh
theta = 114.4996469200000 * np.pi / 180.0

r_o, r_h1, r_h2 = get_cart_coords_h2o(r_OH1, r_OH2, theta, [0.0,0.0, 0.0])

atoms = Atoms('OHH', positions=[r_o, r_h1, r_h2])

calc  = H2o_pjt2_calculator()
atoms.set_calculator(calc)

E = atoms.get_potential_energy()

print(E)

# optimize geometry
dyn = BFGSLineSearch(atoms, logfile='h2o_opt.log')
dyn.run(fmax=0.00001)

pos = atoms.get_positions()

q1,q2,theta = get_internal_coords_h2o(pos[0], pos[1], pos[2])
coords = [q1, q2, theta * 180/np.pi]

ref=np.array([0.957920759532, 0.957920773357, 104.499646202])

error = np.sqrt(np.sum((coords - ref)**2))
print('coords')
print(coords)
print('diff from reference:')
print(error)