Exemplo n.º 1
0
 def notestSpecies(self):
     siesta = Siesta()
     atoms = ch4.copy()
     species, numbers = siesta.species(atoms)
     self.assertTrue(all(numbers==np.array([1, 2, 2, 2, 2])))
     siesta = Siesta(species=[Specie(symbol='C', tag=1)])
     species, numbers = siesta.species(atoms)
     self.assertTrue(all(numbers==np.array([1, 2, 2, 2, 2])))
     atoms.set_tags([0,0,0,1,0])
     species, numbers = siesta.species(atoms)
     self.assertTrue(all(numbers==np.array([1, 2, 2, 2, 2])))
     siesta = Siesta(species=[Specie(symbol='H', tag=1)])
     species, numbers = siesta.species(atoms)
     self.assertTrue(all(numbers==np.array([1, 2, 2, 3, 2])))
Exemplo n.º 2
0
    H2O = Atoms("H2O",
                np.array([[0.0, -0.757, 0.587], [0.0, +0.757, 0.587],
                          [0.0, 0.0, 0.0]]),
                cell=np.eye(3, dtype=float))
    #H2O.center(vacuum=3.5)
    # unit cell 1 0 0
    #           0 1 0   => siesta default unit cell use
    #           0 0 1

    siesta_calc = Siesta(mesh_cutoff=150 * Ry,
                         basis_set='SZ',
                         energy_shift=(10 * 10**-3) * eV,
                         xc="PBE",
                         fdf_arguments={
                             'SCFMustConverge': False,
                             'COOP.Write': True,
                             'WriteDenchar': True,
                             'PAO.BasisType': 'split',
                             'DM.Tolerance': 1e-4,
                             'DM.MixingWeight': 0.01,
                             'MaxSCFIterations': 150,
                             'DM.NumberPulay': 4
                         })

    H2O.set_calculator(siesta_calc)
    efree_siesta = H2O.get_potential_energy()

    # run gpaw
    from gpaw import GPAW, PoissonSolver
    H2O_gp = Atoms(
        "H2O",
        np.array([[0.0, -0.757, 0.587], [0.0, +0.757, 0.587], [0.0, 0.0,
Exemplo n.º 3
0
from ase.optimize import BFGS
from ase.units import *
from ase.calculators.siesta import Siesta
# Read initial and final states:
from ase.io.trajectory import Trajectory, PickleTrajectory
traj = Trajectory("final7.traj")

#traj = io.read('last_iteration.traj')
#for images in traj:
#    print "hello2"


calc = Siesta(label='pes_neb',
              xc='RPBE',
              meshcutoff=200 * Ry,
              basis='dzp',
              mix=0.1,
              pulay=12,
              kpts=[6, 6, 1])

calc.set_fdf('xc.functional', 'GGA')
calc.set_fdf('PAO.EnergyShift', 0.01 * Ry)
calc.set_fdf('DM.KickMixingWeight', 0.008)
calc.set_fdf('SpinPolarized', 'false')

for images in traj:
#    print "hello"
#    pprint.pprint(images)
    images.set_calculator(calc)
    e = images.get_potential_energy()
    print e
Exemplo n.º 4
0
from ase.calculators.siesta import Siesta
from ase.calculators.siesta.parameters import Species, PAOBasisBlock
from ase.optimize import QuasiNewton
from ase import Atoms

atoms = Atoms('3H', [(0.0, 0.0, 0.0), (0.0, 0.0, 0.5), (0.0, 0.0, 1.0)],
              cell=[10, 10, 10])

basis_set = PAOBasisBlock("""1
0  2 S 0.2
0.0 0.0""")
atoms.set_tags([0, 1, 0])
siesta = Siesta(species=[
    Species(symbol='H', tag=None, basis_set='SZ'),
    Species(symbol='H', tag=1, basis_set=basis_set, ghost=True)
])

atoms.set_calculator(siesta)
dyn = QuasiNewton(atoms, trajectory='h.traj')
dyn.run(fmax=0.02)
Exemplo n.º 5
0
from ase.build import bulk
from ase.calculators.siesta import Siesta
from ase.io.siesta import _read_fdf_lines

atoms = bulk('Ti')
calc = Siesta()
atoms.calc = calc
calc.write_input(atoms, properties=['energy'])
# Should produce siesta.fdf but really we should be more explicit

fname = 'siesta.fdf'

with open(fname) as fd:
    thing = _read_fdf_lines(fd)
print(thing)

assert thing[0].split() == ['SystemName', 'siesta']
Exemplo n.º 6
0
from ase.constraints import FixAtoms
from ase.calculators.siesta import Siesta
from ase.md import VelocityVerlet
from ase import units

# Read in the geometry from a xyz file, set the cell, boundary conditions and center
atoms = read('geom.xyz')
atoms.set_cell([7.66348,7.66348,7.66348*2])
atoms.set_pbc((1,1,1))
atoms.center()

# Set initial velocities for hydrogen atoms along the z-direction
p = atoms.get_momenta()
p[0,2]= -1.5
p[1,2]= -1.5
atoms.set_momenta(p)

# Keep some atoms fixed during the simulation
atoms.set_constraint(FixAtoms(indices=range(18,38)))

# Set the calculator and attach it to the system
calc = Siesta('si001+h2',basis='SZ',xc='PBE',meshcutoff=50*units.Ry)
calc.set_fdf('PAO.EnergyShift', 0.25 * units.eV) 
calc.set_fdf('PAO.SplitNorm', 0.15)       
atoms.set_calculator(calc)

# Set the VelocityVerlet algorithm and run it
dyn = VelocityVerlet(atoms,dt=1.0 * units.fs,trajectory='si001+h2.traj')
dyn.run(steps=100)

Exemplo n.º 7
0
 def __init__(self, nodes=1, ppn=8, **kwargs):
     Siesta.__init__(self, **kwargs)
     self.nodes=nodes
     self.ppn=ppn
Exemplo n.º 8
0
 def calc(self, **kwargs):
     from ase.calculators.siesta import Siesta
     command = '{} < PREFIX.fdf > PREFIX.out'.format(self.executable)
     return Siesta(command=command,
                   pseudo_path=str(self.pseudo_path),
                   **kwargs)
Exemplo n.º 9
0
from ase import Atoms
from ase.calculators.siesta import Siesta
from ase.units import Ry

a0 = 5.43
bulk = Atoms('Si2', [(0, 0, 0), (0.25, 0.25, 0.25)], pbc=True)
b = a0 / 2
bulk.set_cell([(0, b, b), (b, 0, b), (b, b, 0)], scale_atoms=True)

calc = Siesta(
    label='Si',
    xc='PBE',
    spin='collinear',
    mesh_cutoff=200 * Ry,
    energy_shift=0.01 * Ry,
    basis_set='DZ',
    kpts=[1, 2, 3],
    fdf_arguments={
        'DM.MixingWeight': 0.10,
        'MaxSCFIterations': 10,
        'SCF.DM.Tolerance': 0.1,
    },
)
bulk.calc = calc
e = bulk.get_potential_energy()
print(e)
Exemplo n.º 10
0
                       [-1.90503810, -1.56107288, 0.00000000],
                       [0.00000000, 0.00000000, 2.08495836],
                       [0.00000000, 0.00000000, -2.08495836],
                       [0.00000000, 3.22798122, 2.08495836],
                       [0.00000000, 3.22798122, -2.08495836]],
            cell=[20, 20, 20])

# enter siesta input
siesta = Siesta(mesh_cutoff=150 * Ry,
                basis_set='DZP',
                pseudo_qualifier='',
                energy_shift=(10 * 10**-3) * eV,
                fdf_arguments={
                    'SCFMustConverge': False,
                    'COOP.Write': True,
                    'WriteDenchar': True,
                    'PAO.BasisType': 'split',
                    'DM.Tolerance': 1e-4,
                    'DM.MixingWeight': 0.01,
                    'MaxSCFIterations': 300,
                    'DM.NumberPulay': 4,
                    'XML.Write': True
                })

Na8.calc = siesta
e = Na8.get_potential_energy()
freq = np.arange(0.0, 5.0, 0.05)
siesta.lrtddft(freq,
               label="siesta",
               jcutoff=7,
               iter_broadening=0.15 / Ha,
Exemplo n.º 11
0
CO2 = Atoms('CO2',
            positions=[[-0.009026, -0.020241, 0.026760],
                       [1.167544, 0.012723, 0.071808],
                       [-1.185592, -0.053316, -0.017945]],
            cell=[20, 20, 20])

# enter siesta input
siesta = Siesta(
    mesh_cutoff=150 * Ry,
    basis_set='DZP',
    pseudo_qualifier='',
    energy_shift=(10 * 10**-3) * eV,
    fdf_arguments={
        'SCFMustConverge': False,
        'COOP.Write': True,
        'WriteDenchar': True,
        'PAO.BasisType': 'split',
        'DM.Tolerance': 1e-4,
        'DM.MixingWeight': 0.01,
        'MaxSCFIterations': 300,
        'DM.NumberPulay': 4,
        'XML.Write': True,
        'DM.UseSaveDM': True})

CO2.set_calculator(siesta)

ram = SiestaRaman(CO2, siesta, label="siesta", jcutoff=7, iter_broadening=0.15/Ha,
                  xc_code='LDA,PZ', tol_loc=1e-6, tol_biloc=1e-7,
                  freq=np.arange(0.0, 5.0, 0.05))
ram.run()
ram.summary(intensity_unit_ram='A^4 amu^-1')
Exemplo n.º 12
0
import matplotlib.pyplot as plt

H2O = Atoms('H2O', positions = [[-0.757,  0.586,  0.000],
                                [0.757,  0.586,  0.000],
                                [0.0, 0.0, 0.0]],
            cell=[20, 20, 20])

# enter siesta input and run siesta
siesta = Siesta(
    mesh_cutoff=150 * Ry,
    basis_set='DZP',
    pseudo_qualifier='lda',
    energy_shift=(10 * 10**-3) * eV,
    fdf_arguments={
        'SCFMustConverge': False,
        'COOP.Write': True,
        'WriteDenchar': True,
        'PAO.BasisType': 'split',
        'DM.Tolerance': 1e-4,
        'DM.MixingWeight': 0.01,
        'MaxSCFIterations': 300,
        'DM.NumberPulay': 4,
        'XML.Write': True})

H2O.set_calculator(siesta)
e = H2O.get_potential_energy()


# ### The TDDFT calculations with PySCF-NAO

siesta.pyscf_tddft(label="siesta", jcutoff=7, iter_broadening=0.15/Ha,
Exemplo n.º 13
0
                       (-0.776070, 0.590459, 0.00000),
                       (0.000000, -0.007702, -0.000001)],
            pbc=(1, 1, 1))

# Center the molecule in the cell with some vacuum around
h2o.center(vacuum=6.0)

# Select some energy-shifts for the basis orbitals
e_shifts = [0.01, 0.1, 0.2, 0.3, 0.4, 0.5]

# Run the relaxation for each energy shift, and print out the
# corresponding total energy, bond length and angle

for e_s in e_shifts:
    starttime = time.time()
    calc = Siesta('h2o', meshcutoff=200.0 * units.Ry, mix=0.5, pulay=4)
    calc.set_fdf('PAO.EnergyShift', e_s * units.eV)
    calc.set_fdf('PAO.SplitNorm', 0.15)
    calc.set_fdf('PAO.BasisSize', 'SZ')
    h2o.set_calculator(calc)
    # Make a -traj file named h2o_current_shift.traj:
    dyn = QuasiNewton(h2o, trajectory='h2o_%s.traj' % e_s)
    dyn.run(fmax=0.02)  # Perform the relaxation
    E = h2o.get_potential_energy()
    print  # Make the output more readable
    print "E_shift: %.2f" % e_s
    print "----------------"
    print "Total Energy: %.4f" % E  # Print total energy
    d = h2o.get_distance(0, 2)
    print "Bond length: %.4f" % d  # Print bond length
    p = h2o.positions
Exemplo n.º 14
0
 def prepare_input(self, struct):
     if self.calculator == "VASP":
         # POTCAR and POSCAR file generation, INCAR and KPOINTS must be provided in current dir
         write(filename="POSCAR", images=struct, format="vasp")
         if os.path.isfile('POTCAR'):
             os.system("rm POTCAR")
         tmp = open("POSCAR", "r")
         first_line = tmp.readline()
         line_sp = first_line.split()
         cat = "cat "
         # path from NGOptConfig
         for s in line_sp:
             cat = cat + self.vasp_pseudo_path + "/POTCAR_" + s + " "
         cat = cat + " > POTCAR"
         tmp.close()
         os.system(cat)
     if self.calculator == "siesta":
         # head.fdf file generation, tail.fdf must be provided in current dir
         calc = Siesta(
             label='siesta',
             xc='PBE',
             basis_set='SZP',
         )
         f = open("head.fdf", "w")
         calc._write_species(f, struct)
         calc._write_structure(f, struct)
         f.close()
         os.system("cat head.fdf tail.fdf > siesta.fdf")
     if self.calculator == "openmx":
         # center of file generation, head and tail must be provided in current dir
         label = "openmx"
         input = open("openmx.in.dat", "w")
         #
         input.write("\n")
         input.write("System.Name                      " + label + "\n")
         input.write("\n")
         input.write("# \n")
         input.write("# Definition of Atomic Species \n")
         input.write("# \n")
         input.write("\n")
         # print openmx species
         l = len(struct.get_chemical_symbols())
         symbols = struct.get_chemical_symbols()
         symbols_dist = set(symbols)
         input.write("Species.Number       " + str(len(symbols_dist)) +
                     "\n")
         input.write("<Definition.of.Atomic.Species \n")
         for symbol in symbols_dist:
             basis = get_basis_info_openmx(self.openmx_bases_file, symbol)
             pseudo = get_pseudos_openmx(self.openmx_pseudo_file, symbol)
             size = str(basis[2])
             input.write(
                 str(symbol) + "  " + str(basis[0] + "-" + size) + "  " +
                 str(pseudo) + " \n")
         input.write("Definition.of.Atomic.Species> \n")
         input.write("\n")
         input.write("# \n")
         input.write("# Atoms \n")
         input.write("# \n")
         input.write("\n")
         # print openmx positions
         positions = struct.get_positions()
         input.write("Atoms.Number      " + str(l) + "\n")
         input.write("Atoms.SpeciesAndCoordinates.Unit   Ang # Ang|AU \n")
         input.write("<Atoms.SpeciesAndCoordinates \n")
         for i in range(l):
             symbol = symbols[i]
             basis = get_basis_info_openmx(self.openmx_bases_file, symbol)
             valence = float(basis[1]) / 2.
             if basis[2] == "s2p2d2":
                 valence1 = valence + self.halfmom
                 valence2 = valence - self.halfmom
             else:
                 valence1 = valence2 = valence
                 # valence1 = valence+self.halfmom
                 # valence2 = valence-self.halfmom
             input.write(
                 str(i + 1) + "    " + str(symbols[i]) + "    " +
                 str(format(positions[i][0], '.12f')) + "   " +
                 str(format(positions[i][1], '.12f')) + "   " +
                 str(format(positions[i][2], '.12f')) + "    " +
                 str(valence1) + "    " + str(valence2) + "\n")
         input.write("Atoms.SpeciesAndCoordinates> \n")
         # print openmx unit cell
         input.write("Atoms.UnitVectors.Unit             Ang # Ang|AU \n"
                     )  # do poprawy!
         input.write("<Atoms.UnitVectors \n")
         cell = struct.get_cell()
         input.write(
             str(format(cell[0][0], '.12f')) + "    " +
             str(format(cell[0][1], '.12f')) + "    " +
             str(format(cell[0][2], '.12f')) + "\n")
         input.write(
             str(format(cell[1][0], '.12f')) + "    " +
             str(format(cell[1][1], '.12f')) + "    " +
             str(format(cell[1][2], '.12f')) + "\n")
         input.write(
             str(format(cell[2][0], '.12f')) + "    " +
             str(format(cell[2][1], '.12f')) + "    " +
             str(format(cell[2][2], '.12f')) + "\n")
         input.write("Atoms.UnitVectors> \n")
         input.close()
         os.system("cat head openmx.in.dat tail > openmx.dat")
Exemplo n.º 15
0
 def __init__(self, nodes=1, ppn=8, **kwargs):
     Siesta.__init__(self, **kwargs)
     self.nodes = nodes
     self.ppn = ppn
Exemplo n.º 16
0
imagesfinal=[]
for images in traj:
#for image in images:
    imagesfinal += [images] 

neb = NEB(imagesfinal, k=0.5)
# Interpolate linearly the potisions of the three middle images:
#neb.interpolate()

#view(images)

calc = Siesta(label='pes_neb',
              xc='RPBE',
              meshcutoff=200 * Ry,
              basis='dzp',
              mix=0.1,
              pulay=12,
              kpts=[6, 6, 1])

calc.set_fdf('xc.functional', 'GGA')
calc.set_fdf('PAO.EnergyShift', 0.01 * Ry)
calc.set_fdf('DM.KickMixingWeight', 0.008)
calc.set_fdf('DM.UseSaveDM', 'true')
calc.set_fdf('SpinPolarized', 'true')
#calc.set_fdf('ElectronicTemperature', 500 * C)


# Set calculators:
#for images in traj:
for image in imagesfinal:
Exemplo n.º 17
0
 def get_potential_energy(self, atoms):
     self.prepare_calc_dir()
     Siesta.get_potential_energy(self, atoms)
Exemplo n.º 18
0
                       [1.90503810, -1.56107288, 0.00000000],
                       [-1.90503810, -1.56107288, 0.00000000],
                       [0.00000000, 0.00000000, 2.08495836],
                       [0.00000000, 0.00000000, -2.08495836],
                       [0.00000000, 3.22798122, 2.08495836],
                       [0.00000000, 3.22798122, -2.08495836]],
            cell=[20, 20, 20])

# enter siesta input
siesta = Siesta(
    mesh_cutoff=150 * Ry,
    basis_set='DZP',
    pseudo_qualifier='',
    energy_shift=(10 * 10**-3) * eV,
    fdf_arguments={
        'SCFMustConverge': False,
        'COOP.Write': True,
        'WriteDenchar': True,
        'PAO.BasisType': 'split',
        'DM.Tolerance': 1e-4,
        'DM.MixingWeight': 0.01,
        'MaxSCFIterations': 300,
        'DM.NumberPulay': 4})


mbpt_inp = {'prod_basis_type': 'MIXED',
            'solver_type': 1,
            'gmres_eps': 0.001,
            'gmres_itermax': 256,
            'gmres_restart': 250,
            'gmres_verbose': 20,
            'xc_ord_lebedev': 14,
Exemplo n.º 19
0
from ase.constraints import FixAtoms
from ase.calculators.siesta import Siesta
from ase.md import VelocityVerlet
from ase import units

# Read in the geometry from a xyz file, set the cell, boundary conditions and center
atoms = read('geom.xyz')
atoms.set_cell([7.66348,7.66348,7.66348*2])
atoms.set_pbc((1,1,1))
atoms.center()

# Set initial velocities for hydrogen atoms along the z-direction
p = atoms.get_momenta()
p[0,2]= -1.5
p[1,2]= -1.5
atoms.set_momenta(p)

# Keep some atoms fixed during the simulation
atoms.set_constraint(FixAtoms(indices=range(18,38)))

# Set the calculator and attach it to the system
calc = Siesta('si001+h2',basis='SZ',xc='PBE',meshcutoff=50*units.Ry)
calc.set_fdf('PAO.EnergyShift', 0.25 * units.eV) 
calc.set_fdf('PAO.SplitNorm', 0.15)       
atoms.set_calculator(calc)

# Set the VelocityVerlet algorithm and run it
dyn = VelocityVerlet(atoms,dt=1.0 * units.fs,trajectory='si001+h2.traj')
dyn.run(steps=100)

Exemplo n.º 20
0
from ase.calculators.siesta import Siesta
from ase.optimize import BFGS
from ase.calculators.socketio import SocketIOCalculator

unixsocket = 'siesta'

fdf_arguments = {'MD.TypeOfRun': 'Master',
                 'Master.code': 'i-pi',
                 'Master.interface': 'socket',
                 'Master.address': unixsocket,
                 'Master.socketType': 'unix'}

# To connect through INET socket instead, use:
#   fdf_arguments['Master.port'] = port
#   fdf_arguments['Master.socketType'] = 'inet'
# Optional, for networking:
#   fdf_arguments['Master.address'] = <hostname or IP address>

atoms = molecule('H2O', vacuum=3.0)
atoms.rattle(stdev=0.1)

siesta = Siesta(fdf_arguments=fdf_arguments)
opt = BFGS(atoms, trajectory='opt.siesta.traj', logfile='opt.siesta.log')

with SocketIOCalculator(siesta, log=sys.stdout,
                        unixsocket=unixsocket) as calc:
    atoms.calc = calc
    opt.run(fmax=0.05)

# Note: Siesta does not exit cleanly - expect nonzero exit codes.
Exemplo n.º 21
0
 def get_potential_energy(self, atoms):
     self.prepare_calc_dir()
     Siesta.get_potential_energy(self, atoms)
Exemplo n.º 22
0
# In this script the Virtual Crystal approximation is used to model
# a stronger affinity for positive charge on the H atoms.
# This could model interaction with other molecules not explicitly
# handled.
import numpy as np
from ase.calculators.siesta import Siesta
from ase.calculators.siesta.parameters import Species
from ase.optimize import QuasiNewton
from ase import Atoms

atoms = Atoms('CH4', np.array([
    [0.000000, 0.000000, 0.000000],
    [0.682793, 0.682793, 0.682793],
    [-0.682793, -0.682793, 0.682790],
    [-0.682793, 0.682793, -0.682793],
    [0.682793, -0.682793, -0.682793]]))

siesta = Siesta(
    species=[
        Species(symbol='H', excess_charge=0.1)])

atoms.set_calculator(siesta)
dyn = QuasiNewton(atoms, trajectory='h.traj')
dyn.run(fmax=0.02)