def makeatoms(self, *args): self.update_element() if self.legal_element is None: self.atoms = None self.pybut.python = None else: n = int(self.n.value) m = int(self.m.value) symb = self.legal_element length = int(self.length.value) bl = self.bondlength.value self.atoms = nanotube(n, m, length=length, bond=bl, symbol=symb) # XXX can this be translated? self.pybut.python = py_template % { 'n': n, 'm': m, 'length': length, 'symb': symb, 'bl': bl } h = np.zeros(3) uc = self.atoms.get_cell() for i in range(3): norm = np.cross(uc[i - 1], uc[i - 2]) norm /= np.sqrt(np.dot(norm, norm)) h[i] = np.abs(np.dot(norm, uc[i])) label = label_template % { 'natoms': len(self.atoms), 'symbols': formula(self.atoms.get_atomic_numbers()), 'volume': self.atoms.get_volume(), 'diameter': self.atoms.get_cell()[0][0] / 2.0 } self.status.set_markup(label)
def make_atoms(l): atoms = nanotube(6, 0, length=l) atoms.rotate(-90, 'x', rotate_cell=True) atoms.center(vacuum=5, axis=(0, 1)) cell = atoms.cell.copy() cell[1] = np.abs(atoms.cell[2]) cell[2] = np.abs(atoms.cell[1]) atoms.set_cell(cell) return atoms
def test_nanotube(i): size = 4 atoms = nanotube(3, 3, length=size) permutation = np.roll(np.arange(3), i) atoms = permute_axes(atoms, permutation) result = find_inversion_symmetry(atoms) assert result.rmsd < TOL check_result(atoms, result) atoms.rattle() result = find_inversion_symmetry(atoms) check_result(atoms, result)
def test_nanotube(seed, i): size = 4 atoms = nanotube(3, 3, length=size) 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)[:3] factors = [reduced.factor for reduced in result] assert tuple(factors) == (1, 2, 4) assert all([reduced.rmsd < TOL for reduced in result]) check_components(atoms, result)
def make(self, element=None): symbol = self.element.symbol if symbol is None: self.atoms = None self.python = None self.description.text = '' return n = self.n.value m = self.m.value length = self.length.value bl = self.bondlength.value self.atoms = nanotube(n, m, length=length, bond=bl, symbol=symbol) label = label_template.format(natoms=len(self.atoms), total_length=self.atoms.cell[2, 2], diameter=self.atoms.cell[0, 0] / 2) self.description.text = label return py_template.format(n=n, m=m, length=length, symb=symbol, bl=bl)
def makeatoms(self, *args): self.update_element() if self.legal_element is None: self.atoms = None self.pybut.python = None else: n = int(self.n.value) m = int(self.m.value) symb = self.legal_element length = int(self.length.value) bl = self.bondlength.value self.atoms = nanotube(n, m, length=length, bond=bl, symbol=symb) # XXX can this be translated? self.pybut.python = py_template % {'n': n, 'm':m, 'length':length, 'symb':symb, 'bl':bl} label = label_template % {'natoms' : len(self.atoms), 'symbols' : formula(self.atoms.get_atomic_numbers()), 'volume' : np.inf, 'diameter' : self.atoms.get_cell()[0][0]/2.0} self.status.set_markup(label)
def test_nanotube(seed, i, translate): size = 4 atoms = nanotube(3, 3, length=size) prepare(seed, i, translate, atoms)
'h': 0.2, 'nbands': -60, 'occupations': FermiDirac(0.1), 'mixer': Mixer(0.1, 5, 50), 'poissonsolver': PoissonSolver(eps=1e-12), 'eigensolver': 'rmm-diis', 'maxiter': maxiter, 'convergence': conv, 'xc_thread': False, 'txt': txt } if use_cuda: args['gpu'] = {'cuda': True, 'hybrid_blas': True} try: args['parallel'] = parallel except: pass # setup the system atoms = nanotube(n, m, length) atoms.center(vacuum=4.068, axis=0) atoms.center(vacuum=4.068, axis=1) calc = GPAW(**args) atoms.set_calculator(calc) # execute the run try: atoms.get_potential_energy() except ConvergenceError: pass
# creates: a1.png, a2.png, a3.png, cnt1.png, cnt2.png, gnr1.png, gnr2.png from ase.io import write from ase.build import bulk from ase.build import nanotube, graphene_nanoribbon for i, a in enumerate( [bulk('Cu', 'fcc', a=3.6), bulk('Cu', 'fcc', a=3.6, orthorhombic=True), bulk('Cu', 'fcc', a=3.6, cubic=True)]): write('a%d.pov' % (i + 1), a, show_unit_cell=2, display=False, run_povray=True) cnt1 = nanotube(6, 0, length=4, vacuum=2.5) cnt1.rotate('x', 'z', rotate_cell=True) cnt2 = nanotube(3, 3, length=6, bond=1.4, symbol='Si', vacuum=2.5) cnt2.rotate('x', 'z', rotate_cell=True) for i, a in enumerate([cnt1, cnt2]): write('cnt%d.pov' % (i + 1), a, show_unit_cell=2, display=False, run_povray=True) gnr1 = graphene_nanoribbon(3, 4, type='armchair', saturated=True, vacuum=2.5) gnr2 = graphene_nanoribbon(2, 6, type='zigzag', saturated=True, C_H=1.1, C_C=1.4, vacuum=3.0, magnetic=True, initial_mag=1.12) for i, a in enumerate([gnr1, gnr2]): write('gnr%d.pov' % (i + 1), a, rotation='90x', show_unit_cell=2, display=False, run_povray=True)
from ase.build import nanotube # nanotube(n, m, length=1, bond=1.42, symbol='C', verbose=False, vacuum=None) atoms = nanotube(2, 2, length=5, bond=1.42, symbol='C', verbose=True, vacuum=5.0) atoms.set_pbc([True, True, True]) atoms.write('CNT.xsf')
from ase.build import bulk from ase.build import nanotube, graphene_nanoribbon import numpy as np for i, a in enumerate([ bulk('Cu', 'fcc', a=3.6), bulk('Cu', 'fcc', a=3.6, orthorhombic=True), bulk('Cu', 'fcc', a=3.6, cubic=True) ]): write('a%d.pov' % (i + 1), a, show_unit_cell=2, display=False, run_povray=True) cnt1 = nanotube(6, 0, length=4) cnt1.rotate('x', 'z', rotate_cell=True) cnt2 = nanotube(3, 3, length=6, bond=1.4, symbol='Si') cnt2.rotate('x', 'z', rotate_cell=True) for i, a in enumerate([cnt1, cnt2]): write('cnt%d.pov' % (i + 1), a, show_unit_cell=2, display=False, run_povray=True) ind = [2, 0, 1] gnr1 = graphene_nanoribbon(3, 4, type='armchair', saturated=True) gnr1.set_cell(np.diag(gnr1.cell)[ind]) gnr1.positions = gnr1.positions[:, ind]
'tsmear': 0.1, 'chksymbreak': 0, 'toldfe': 1.0e-6, 'occopt': 7, } rest = MPRester('XaCJrv4nBIeuy3kd') params_dict = {} structures = {} psps = os.listdir( '/home/bcomer3/sparc/ase_sparc/pysparcx/sparc/pseudos/LDA_pseudos/') available_psps = [a.split('.')[0] for a in psps] wire = nanotube(6, 0, length=1, vacuum=6) wire.rotate(90, 'y', rotate_cell=True) wire.set_cell([wire.cell[2], wire.cell[1], wire.cell[0] * -1]) wire.center() #view(wire) add_to_dict(AseAtomsAdaptor.get_structure(wire), 'CNT') # nano-ribbon ribbon = graphene_nanoribbon(2, 2, saturated=True, vacuum=6) ribbon.rotate(90, 'y', rotate_cell=True) ribbon.set_cell([ribbon.cell[2], ribbon.cell[1], ribbon.cell[0] * -1]) ribbon.center() add_to_dict(AseAtomsAdaptor.get_structure(ribbon), 'graphene_ribbon') from ase import Atoms
# creates: a1.png a2.png a3.png cnt1.png cnt2.png gnr1.png gnr2.png from ase.io import write from ase.build import bulk from ase.build import nanotube, graphene_nanoribbon import numpy as np for i, a in enumerate( [bulk('Cu', 'fcc', a=3.6), bulk('Cu', 'fcc', a=3.6, orthorhombic=True), bulk('Cu', 'fcc', a=3.6, cubic=True)]): write('a%d.pov' % (i + 1), a, show_unit_cell=2, display=False, run_povray=True) cnt1 = nanotube(6, 0, length=4, vacuum=2.5) cnt1.rotate('x', 'z', rotate_cell=True) cnt2 = nanotube(3, 3, length=6, bond=1.4, symbol='Si', vacuum=2.5) cnt2.rotate('x', 'z', rotate_cell=True) for i, a in enumerate([cnt1, cnt2]): write('cnt%d.pov' % (i + 1), a, show_unit_cell=2, display=False, run_povray=True) ind = [2, 0, 1] gnr1 = graphene_nanoribbon(3, 4, type='armchair', saturated=True, vacuum=2.5) gnr1.set_cell(np.diag(gnr1.cell)[ind]) gnr1.positions = gnr1.positions[:, ind] gnr2 = graphene_nanoribbon(2, 6, type='zigzag', saturated=True, C_H=1.1, C_C=1.4, vacuum=3.0, magnetic=True, initial_mag=1.12) gnr2.set_cell(np.diag(gnr2.cell)[ind]) gnr2.positions = gnr2.positions[:, ind]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Mar 9 17:00:55 2020 @author: Tanvir Chowdhury """ from ase.build import nanotube, molecule, add_adsorbate from ase.io.vasp import write_vasp from ase.visualize import view # creating a (10,0) nanotube cnt = nanotube(10, 0, length=2) # creating an ammonia molecule ammonia = molecule('NH3') ''' #print ammonia unit cell print(ammonia.get_cell()) #print cnt unit cell print(cnt.get_cell()) #print ammonia coordinates of the atoms N and 3 H print(ammonia.get_positions()) #print cnt coordinates print(cnt.get_positions())''' # adding ammonia on top of cnt at a z value of 1.5 Angstroms add_adsorbate(cnt, ammonia, -4.55, position=(0, 5.914)) #new coordinates after adding ammonia on top of cnt #print(cnt.get_positions())
from ase.build import nanotube # nanotube(n, m, length=1, bond=1.42, symbol='C', verbose=False, vacuum=None) atoms = nanotube(3, 3, bond=1.42, symbol='C', verbose=True, vacuum=10.0) atoms.set_pbc([True, True, True]) atoms.write('CNT.xsf')
from ase.build import nanotube from ase.md.langevin import Langevin from ase.optimize import BFGS from ase import units import torch import my_torchani # Now let's set up a crystal atoms = nanotube(5, 5, length=10, bond=1.420, symbol='C') print(len(atoms), "atoms in the cell") atoms.set_pbc([True,True,True]) Lz = atoms.cell.array[2,2] Lx = 20.0 Ly = 20.0 atoms.set_cell([Lx, Ly, Lz]) atoms.center() atoms.write("STRUCT_cnt_5x5.xsf") #device = torch.device("cuda" if torch.cuda.is_available() else "cpu") device = "cpu" print("device = ", device) # Now let's create a calculator from builtin models: calculator = my_torchani.models.ANI1ccx().to(device).ase() # Now let's set the calculator for ``atoms``: atoms.set_calculator(calculator) # Now let's minimize the structure: print("Begin minimizing...")
txt = 'output.txt' maxiter = 16 conv = {'eigenstates' : 1e-4, 'density' : 1e-2, 'energy' : 1e-3} # output benchmark parameters if rank == 0: print("#"*60) print("GPAW benchmark: Carbon Nanotube") print(" nanotube dimensions: n=%d, m=%d, length=%d" % (n, m, length)) print(" MPI task: %d out of %d" % (rank, size)) print(" using MICs: " + str(use_mic)) print("#"*60) print("") # setup the system atoms = nanotube(n, m, length) calc = GPAW(h=0.2, nbands=-60, width=0.1, poissonsolver=PoissonSolver(eps=1e-12), eigensolver=RMM_DIIS(keep_htpsit=True), maxiter=maxiter, mixer=Mixer(0.1, 5, 50), convergence=conv, txt=txt) atoms.set_calculator(calc) # execute the run try: atoms.get_potential_energy() except ConvergenceError: pass
from ase.build import nanotube # nanotube(n, m, length=1, bond=1.42, symbol='C', verbose=False, vacuum=None) atoms = nanotube(2,2, length=5, bond=1.42, symbol='C', verbose=True, vacuum=5.0) atoms.set_pbc([True,True,True]) atoms.write('CNT.xsf')
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)