def test_mos2(i): size = 2 atoms = mx2(formula='MoS2', size=(size, size, 1)) permutation = np.roll(np.arange(3), i) atoms = permute_axes(atoms, permutation) result = find_inversion_symmetry(atoms) check_result(atoms, result)
def write_gpw_file(): """write gs dft calculation """ # start by cleaning up a bit if world.rank == 0: for name in Path().glob('*.npy'): Path(name).unlink() for name in Path().glob('*.tmp.*.pckl'): Path(name).unlink() world.barrier() params = dict(mode=PW(400), xc='PBE', basis='dzp', kpts={ 'size': (6, 6, 1), 'gamma': True }, occupations=FermiDirac(width=0.05)) slab = mx2('MoSS', '2H', 3.184, 3.127) slab.center(vacuum=8, axis=2) slab.pbc = (1, 1, 0) slab.calc = GPAW(txt='gs.txt', **params) slab.get_forces() slab.get_stress() slab.calc.write('gs.gpw')
def monolayer_MX2(formula, a, thickness,vacuum): crystal=mx2(formula=formula, kind='2H', a=a, thickness=thickness, size=(1,1,1), vacuum=None) #print(crystal.positions) #convert to all PBC cell slab=Atoms(crystal) slab.set_cell([crystal.cell[0],crystal.cell[1],[0.0,0.0,vacuum]], scale_atoms=False) slab.set_pbc([True, True, True]) return slab
def test_mos2(seed, i): size = 4 atoms = mx2(formula='MoS2', size=(size, size, 1)) permutation = np.roll(np.arange(3), i) atoms = permute_axes(atoms, permutation) rng = np.random.RandomState(seed=seed) atoms = randomize(rng, atoms) result = find_crystal_reductions(atoms) assert len(result) == size + 1 assert all([reduced.rmsd < TOL for reduced in result]) factors = [reduced.factor for reduced in result] assert tuple(factors) == (1, 2, 4, 8, 16) check_components(atoms, result)
from ase.build import mx2 from gpaw import GPAW, FermiDirac atoms = mx2(formula='HfS2', kind='1T', a=3.648, thickness=2.895, size=(1, 1, 1), vacuum=12.0) atoms.center(vacuum=6.0, axis=2) name = atoms.get_chemical_formula(mode='hill') h = 0.18 kx = 9 ky = 9 kz = 1 calc = GPAW(mode='lcao', h=h, kpts={ 'size': (kx, ky, kz), 'gamma': True }, xc='PBE', basis='dzp', parallel={'band': 1}, symmetry='off', convergence={'bands': -2}, maxiter=600, txt=None,
from ase.build import mx2 from gpaw import GPAW, PW, FermiDirac structure = mx2(formula='WSe2', kind='2H', a=3.319, thickness=3.359, size=(1, 1, 1), vacuum=5) structure.pbc = (1, 1, 1) ecut = 600 calc = GPAW(mode=PW(ecut), xc='LDA', kpts={ 'size': (30, 30, 1), 'gamma': True }, occupations=FermiDirac(0.01), parallel={'domain': 1}, txt='WSe2_gs_out.txt') structure.set_calculator(calc) structure.get_potential_energy() calc.diagonalize_full_hamiltonian(nbands=500, expert=True) calc.write('WSe2_gs_fulldiag.gpw', 'all')
from __future__ import print_function import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import matplotlib as mpl from ase.io import read from pyqstem.util import atoms_plot from pyqstem import PyQSTEM from ase.build import mx2 mpl.rc('font',**{'size' : 13}) atoms=mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19, size=(2, 2, 1), vacuum=2) cell=atoms.get_cell() cell[1,0]=0 atoms.set_cell(cell) atoms.wrap() # wrap atoms outside the unit cell atoms.center() # center the atoms in the unit cell #atoms_plot(atoms,direction=1,scale_atoms=.5) atoms*=(3,3,1) scan_range=[[cell[0,0],2*cell[0,0],30], [cell[1,1],2*cell[1,1],30]] qstem = PyQSTEM('STEM') qstem.set_atoms(atoms)
from gpaw.response.g0w0 import G0W0 from ase.build import mx2 from gpaw import GPAW, PW, FermiDirac structure = mx2(formula='MoS2', kind='2H', a=3.184, thickness=3.127, size=(1, 1, 1), vacuum=3.5) structure.pbc = (1, 1, 1) Ecut = 400 calc = GPAW(mode=PW(Ecut), parallel={'domain': 1}, xc='PBE', basis='dzp', kpts={ 'size': (9, 9, 1), 'gamma': True }, occupations=FermiDirac(0.01), txt='MoS2_out_gs.txt') structure.set_calculator(calc) structure.get_potential_energy() calc.write('MoS2_gs.gpw', 'all') calc.diagonalize_full_hamiltonian() calc.write('MoS2_fulldiag.gpw', 'all')
from ase.build import mx2 from gpaw import GPAW, PW, FermiDirac calc = GPAW(mode=PW(600), xc='PBE', occupations=FermiDirac(width=0.001), kpts={'size': (6, 6, 1), 'gamma': True}, txt='gs_Sn.txt') slab = mx2(formula='SnSn2', a=4.67, thickness=1.7, vacuum=5.0) del slab[-1] slab.set_calculator(calc) slab.get_potential_energy() calc.write('gs_Sn.gpw')
from ase.build import mx2 from gpaw import GPAW, FermiDirac from ase.dft.kpoints import bandpath, special_points from gpaw.unfold import Unfold, find_K_from_k,plot_spectral_function from ase.units import Hartree import pickle structure = mx2(formula='MoS2', kind='2H', a=3.184, thickness=3.127, size=(3, 3, 1), vacuum=7.5) structure.pbc = (1, 1, 1) # Create vacancy del structure[2] calc = GPAW(mode='pw', #changed from LCAO with dbz basis set xc='PBE', kpts=(4, 4, 1), occupations=FermiDirac(0.01), txt='gs_3x3_defect.txt') structure.set_calculator(calc) structure.get_potential_energy() calc.write('gs_3x3_defect.gpw', 'all') a = 3.184 PC = mx2(a=a).get_cell(complete=True) path = [special_points['hexagonal'][k] for k in 'MKG'] kpts, x, X = bandpath(path, PC, 48)
from math import pi import numpy as np from ase.build import mx2 from gpaw import GPAW, PW, Davidson # Create tube of MoS2: atoms = mx2('MoS2', size=(3, 2, 1)) atoms.cell[1, 0] = 0 atoms = atoms.repeat((1, 10, 1)) p = atoms.positions p2 = p.copy() L = atoms.cell[1, 1] r0 = L / (2 * pi) angle = p[:, 1] / L * 2 * pi p2[:, 1] = (r0 + p[:, 2]) * np.cos(angle) p2[:, 2] = (r0 + p[:, 2]) * np.sin(angle) atoms.positions = p2 atoms.cell = [atoms.cell[0, 0], 0, 0] # setup calculator ecut = 800 kpoints = (4, 1, 1) atoms.center(vacuum=6, axis=[1, 2]) atoms.pbc = True tag = 'MoS2-benchmark' atoms.calc = GPAW(mode=PW(ecut), eigensolver=Davidson(2), xc='PBE', txt=tag + '.txt', kpts={'size': kpoints}, nbands='120%',
from ase.build import mx2 from ase.constraints import UnitCellFilter import sys import os.path # solve path issue sys.path.append(os.path.dirname(os.path.abspath(__file__))) print(sys.path) from optimize import QuasiNewton from gpaw import GPAW, PW, FermiDirac, PoissonSolver from ase.parallel import parprint, paropen mol = mx2("MoS2", kind="2H", a=3, vacuum=7.5) mol.set_pbc((True, True, False)) mol.center(axis=2) calc = GPAW( mode=PW(800), kpts=dict(density=4, gamma=True), occupations=FermiDirac(0.01), xc="PBE", basis="dzp", poissonsolver=dict(dipolelayer="xy"), # txt="MoS2_relax.txt" ) mol.set_calculator(calc) if __name__ == "__main__": opt = QuasiNewton(mol, trajectory="MoS2.traj") opt.run(fmax=0.01, smax=2e-4, smask=[1, 1, 0, 0, 0, 0]) calc.write("MoS2.gpw") parprint(mol.cell)
import ase.build as ab from pyramids.io.output import writeSiesta from ase.visualize import view atom = ab.mx2() view(atom) writeSiesta('structure.fdf',atom)
from matid.geometry import get_dimensionality from ase.build import molecule from ase.build import nanotube from ase.build import mx2 from ase.build import bulk # Here we create one example of each dimensionality class zero_d = molecule("H2O", vacuum=5) one_d = nanotube(6, 0, length=4, vacuum=5) two_d = mx2(vacuum=5) three_d = bulk("NaCl", "rocksalt", a=5.64) # In order to make the dimensionality detection interesting, we add periodic # boundary conditions. This is more realistic as not that many electronic # structure codes support anything else than full periodic boundary conditions, # and thus the dimensionality information is typically not available. zero_d.set_pbc(True) one_d.set_pbc(True) two_d.set_pbc(True) three_d.set_pbc(True) # Here we perform the dimensionality detection with clustering threshold epsilon epsilon = 3.5 dim0 = get_dimensionality(zero_d, epsilon) dim1 = get_dimensionality(one_d, epsilon) dim2 = get_dimensionality(two_d, epsilon) dim3 = get_dimensionality(three_d, epsilon) # Printing out the results print(dim0)
from ase.build import mx2 from gpaw import GPAW, PW, FermiDirac calc = GPAW(mode=PW(400), xc='PBE', setups={'Mo': '6'}, parallel={ 'band': 1, 'domain': 1 }, occupations=FermiDirac(width=0.001), kpts={ 'size': (30, 30, 1), 'gamma': True }, txt='gs_MoS2.txt') slab = mx2(formula='MoS2', a=3.16, thickness=3.17, vacuum=5.0) slab.set_calculator(calc) slab.get_potential_energy() calc.diagonalize_full_hamiltonian(nbands=50) calc.write('gs_MoS2.gpw', mode='all')
from ase.build import mx2 from ase.dft.kpoints import bandpath, special_points from gpaw import GPAW from gpaw.unfold import Unfold, find_K_from_k a = 3.184 PC = mx2(a=a).get_cell(complete=True) path = [special_points['hexagonal'][k] for k in 'MKG'] kpts, x, X = bandpath(path, PC, 48) M = [[3, 0, 0], [0, 3, 0], [0, 0, 1]] Kpts = [] for k in kpts: K = find_K_from_k(k, M)[0] Kpts.append(K) calc_bands = GPAW('gs_3x3_defect.gpw', fixdensity=True, kpts=Kpts, symmetry='off', nbands=220, convergence={'bands': 200}) calc_bands.get_potential_energy() calc_bands.write('bands_3x3_defect.gpw', 'all') unfold = Unfold(name='3x3_defect', calc='bands_3x3_defect.gpw', M=M,
continue ''' main program begins here ''' #Generate atoms objects for molecule and framework. gas_mol = vasp.read_vasp("./POSCAR_unwrapped") #Include file name of ".cif" if surface not capable of being built using ASE. #frmwrk = get_framework("./MoS2_mp-2815_computed.cif",(1,1,1)) #Build framework frmwrk = mx2(formula='MoS2', kind='2H', a=3.18, thickness=3.19, size=(5, 5, 2), vacuum=12) #Constrain bottom layer #Find midpoint in "z" direction of structure and unconstrain top layer in z-direction. frmwrk_com = frmwrk.get_center_of_mass() #Set molecule's unit cell to be that of framework's unit cell. gas_mol.set_cell(frmwrk.get_cell_lengths_and_angles()) #Center the molecule's center of mass at the origin of the framework's unit cell. gas_mol.center(about=0) #Generate random orientations within the framework. gen_orient(gas_mol, frmwrk, 5, True, True, True)
def test_mos2(seed, i, translate): size = 2 atoms = mx2(formula='MoS2', size=(size, size, 1)) prepare(seed, i, translate, atoms)
"""Self-consistent SOC.""" from unittest import SkipTest import numpy as np from ase.build import mx2 from gpaw import GPAW from gpaw.test import equal from gpaw.spinorbit import get_spinorbit_eigenvalues from gpaw.mpi import size if size > 1: raise SkipTest() a = mx2('MoS2') a.center(vacuum=3, axis=2) params = dict(mode='pw', kpts={'size': (3, 3, 1), 'gamma': True}) # Selfconsistent: a.calc = GPAW(experimental={ 'magmoms': np.zeros((3, 3)), 'soc': True }, convergence={'bands': 28}, **params) a.get_potential_energy() E1 = a.calc.get_eigenvalues(kpt=2) # Non-selfconsistent: a.calc = GPAW(convergence={'bands': 14}, **params)