How to use the ase.Atom function in ase

To help you get started, we’ve selected a few ase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github uw-cmg / MAST / MAST / ingredients / checker / lammpschecker.py View on Github external
if atomlist:
        atlist=[pair for pair in enumerate(atomlist)]
        for line in f.readlines():
            sp=line.split()
            for i,sym in atlist:
                if sp[1]==str(i+1):
                    at=Atom(symbol=sym,position=[float(sp[2]),float(sp[3]),float(sp[4])])
                    a.append(at)
    else:
        atnum = []
        attype = []
        for line in f.readlines():
            sp=line.split()
            if sp[1] in atnum:
                sym = attype[[i for i,num in enumerate(atnum) if num==sp[1]][0]]
                at=Atom(symbol=sym,position=[float(sp[2]),float(sp[3]),float(sp[4])])
                a.append(at)
            else:
                symn = random.choice(range(1,100))
                at=Atom(symbol=symn,position=[float(sp[2]),float(sp[3]),float(sp[4])])
                a.append(at)
                atnum.append(sp[1])
                attype.append(at.symbol)
        atomlist=list(np.zeros(len(attype)))
        for i in range(len(atnum)):
            atomlist[int(atnum[i])-1]=attype[i]
    f.close()
    if writefile==True:
        write_xyz(filename+'.xyz',a,'xyz')
    if ratomlist:
        return a, atomlist
    else:
github rosswhitfield / ase / doc / ase / calculators / NaCl.py View on Github external
from ase import Atoms, Atom
from ase.calculators.vasp import Vasp

a = [6.5, 6.5, 7.7]
d = 2.3608
NaCl = Atoms([Atom('Na', [0, 0, 0], magmom=1.928),
              Atom('Cl', [0, 0, d], magmom=0.75)],
             cell=a)

calc = Vasp(prec='Accurate',
            xc='PBE',
            lreal=False)
NaCl.calc = calc

print(NaCl.get_magnetic_moment())
github rosswhitfield / ase / doc / tutorials / minimahopping / Cu2_Pt110.py View on Github external
from ase import Atoms, Atom
from ase.build import fcc110
from ase.optimize.minimahopping import MinimaHopping
from ase.calculators.emt import EMT
from ase.constraints import FixAtoms, Hookean

# Make the Pt 110 slab.
atoms = fcc110('Pt', (2, 2, 2), vacuum=7.)

# Add the Cu2 adsorbate.
adsorbate = Atoms([Atom('Cu', atoms[7].position + (0., 0., 2.5)),
                   Atom('Cu', atoms[7].position + (0., 0., 5.0))])
atoms.extend(adsorbate)

# Constrain the surface to be fixed and a Hookean constraint between
# the adsorbate atoms.
constraints = [FixAtoms(indices=[atom.index for atom in atoms if
                                 atom.symbol=='Pt']),
               Hookean(a1=8, a2=9, rt=2.6, k=15.),
               Hookean(a1=8, a2=(0., 0., 1., -15.), k=15.),]
atoms.set_constraint(constraints)

# Set the calculator.
calc = EMT()
atoms.calc = calc

# Instantiate and run the minima hopping algorithm.
github uw-cmg / MAST / MAST / structopt / crossover / clustbx.py View on Github external
exchangeindices=[]
        while len(exchangeindices) < diff:
            #Grab shortest distance in ds list
            d, index=ds.pop()
            if index not in exchangeindices:
                exchangeindices.append(index)
        nnsolid1=Atoms()
        for i in range(len(nsolid1)):
            if i not in exchangeindices:
                nnsolid1.append(nsolid1[i])
        nnsolid2=nsolid2.copy()
        for i in exchangeindices:
            #for j in range(3):
            #	position[j]=nsolid2[i].position[j]-pt1[j]+pt2[j]
            position=[random.uniform(pt2[0]-r/(2**0.5),pt2[0]+r/(2**0.5)),random.uniform(pt2[1]-r/(2**0.5),pt2[1]+r/(2**0.5)),random.uniform(pt2[2]-r/(2**0.5),pt2[2]+r/(2**0.5))]
            nnsolid2.append(Atom(symbol=nsolid1[i].symbol, position=position))
        nsolid1=nnsolid1.copy()
        nsolid2=nnsolid2.copy()

    elif nnat1 < nat1:
        ds=[]
        #More atoms in new solid2 means solid1 has less atoms
        #Need to transfer atoms from solid2 to solid1
        #Find atoms that are too close
        for i in range(len(dist1)):
            for j in range(len(dist1),len(nsolid2)):
                ds.append((nsolid2.get_distance(i,j),i))
        #Sort distances by longest to shortest
        ds=sorted(ds, key=lambda one:one[0])
        diff=nnat2-nat2
        exchangeindices=[]
        while len(exchangeindices) < diff:
github jkitchin / dft-book / dft-scripts / script-229.py View on Github external
from vasp import Vasp
from ase import Atom, Atoms
atoms = Atoms([Atom('Cu',  [0.000,      0.000,      0.000]),
               Atom('Pd',  [-1.652,     0.000,      2.039])],
              cell=  [[0.000, -2.039,  2.039],
                      [0.000,  2.039,  2.039],
                      [-3.303,  0.000,  0.000]])
atoms = atoms.repeat((2, 2, 2))
calc = Vasp('bulk/CuPd-cls-0',
            xc='PBE',
            encut=350,
            kpts=[4, 4, 4],
            ibrion=2,
            isif=3,
            nsw=40,
            atoms=atoms)
print(atoms.get_potential_energy())
github jkitchin / dft-book / dft-scripts / script-122.py View on Github external
atoms = FaceCenteredCubic(directions=[[0, 1, 1],
                                      [1, 0, 1],
                                      [1, 1, 0]],
                                      size=(1, 1, 1),
                                      symbol='Rh')
calc = Vasp('bulk/bulk-rh',
            xc='PBE',
            encut=350,
            kpts=[4, 4, 4],
            isif=3,
            ibrion=2,
            nsw=10,
            atoms=atoms)
bulk_energy = atoms.get_potential_energy()
# atomic system
atoms = Atoms([Atom('Rh',[5, 5, 5])],
              cell=(7, 8, 9))
calc = Vasp('bulk/atomic-rh',
            xc='PBE',
            encut=350,
            kpts=[1, 1, 1],
            atoms=atoms)
atomic_energy = atoms.get_potential_energy()
calc.stop_if(None in (bulk_energy, atomic_energy))
cohesive_energy = atomic_energy - bulk_energy
print 'The cohesive energy is {0:1.3f} eV'.format(cohesive_energy)
github libAtoms / matscipy / matscipy / calculators / mcfm / qm_cluster_tools / qm_clustering_tool.py View on Github external
cutoff_atoms_list : list of ints (atomic indexes)
            atoms to be changed into hydrogen, first atoms not in the buffer
        atomic_cluster : ase.Atoms
            QM region structure (with core and buffer atoms)
        atoms : ase.Atoms
            whole structure
        atomic_positions : np.array
            Positions of atoms in the whole structure (copy of the atoms.positions)
        """
        vector = atomic_positions[cutoff_atom_index] - atomic_positions[terminal_atom_index]
        # Make the bond approximately 1 angstrom
        vector /= np.linalg.norm(vector)
        vector *= 1
        # Add a hydrogen instead of the cutoff atom
        pos = atomic_positions[terminal_atom_index] + vector
        cutoff_hydro = Atom(symbol=1, position=pos, charge=0.1)
        atomic_cluster.append(cutoff_hydro)
        atomic_cluster.arrays["orig_index"][len(atomic_cluster) - 1] = len(atoms) + 1
        atomic_cluster.arrays["cluster_mark"][len(atomic_cluster) - 1] = 6
github jkitchin / dft-book / dft-scripts / script-29.py View on Github external
from vasp import Vasp
from enthought.mayavi import mlab
from ase.data import vdw_radii
from ase.data.colors import cpk_colors
from ase import Atom, Atoms
atoms = Atoms([Atom('C', [2.422, 0.0, 0.0]),
               Atom('O', [3.578, 0.0, 0.0])],
               cell=(10,10,10))
atoms.center()
calc = Vasp('molecules/co-centered',
            encut=350,
            xc='PBE',
            atoms=atoms)
calc.set(lcharg=True,)
calc.stop_if(calc.potential_energy is None)
atoms = calc.get_atoms()
x, y, z, cd = calc.get_charge_density()
mlab.figure(bgcolor=(1, 1, 1))
# plot the atoms as spheres
for atom in atoms:
    mlab.points3d(atom.x,
                  atom.y,
github vanceeasleaf / aces / materials / CNn-rotate.py View on Github external
,8.660500,15.000426,0.000000
,8.660500,16.000454,0.000000
,10.392600,15.000426,0.000000
,9.526550,16.500469,0.000000
,9.526550,17.500498,0.000000]).reshape(-1,3)/1.42*1.42
		pos1=[6.928400,13.000369,0.000000
			,7.794450,16.500469,0.000000]
		phi=pi/2-atan((pos1[4]-pos1[1])/(pos1[3]-pos1[0]))
		cbond=np.linalg.norm((pos1[4]-pos1[1],pos1[3]-pos1[0],0))
		dx=sqrt(3)*cbond;
		dy=3*cbond;
		atoms=Atoms()
		choice=np.random(len(pos2))
github jkitchin / dft-book / dft-scripts / script-142.py View on Github external
from vasp import Vasp
from ase import Atom, Atoms
# parent metals
cu = Vasp('bulk/alloy/cu')
cu_e = cu.potential_energy / len(cu.get_atoms())
pd = Vasp('bulk/alloy/pd')
pd_e = pd.potential_energy / len(pd.get_atoms())
atoms = Atoms([Atom('Cu',  [-1.867,     1.867,      0.000]),
               Atom('Cu',  [0.000,      0.000,      0.000]),
               Atom('Cu',  [0.000,      1.867,      1.867]),
               Atom('Pd',  [-1.867,     0.000,      1.86])],
               cell=[[-3.735,  0.000,  0.000],
                     [0.000,  0.000,  3.735],
                     [0.000,  3.735,  0.000]])
calc = Vasp('bulk/alloy/cu3pd-2',
            xc='PBE',
            encut=350,
            kpts=[8, 8, 8],
            nbands=34,
            ibrion=2,
            isif=3,
            nsw=10,
            atoms=atoms)
e4 = atoms.get_potential_energy()