Ejemplo n.º 1
0
 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'   : self.atoms.get_number_of_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)                
Ejemplo n.º 2
0
 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': self.atoms.get_number_of_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)
Ejemplo n.º 3
0
def test_Foutier_ASE_C_Ring():
    pytest.importorskip("ase")
    from ase.structure import nanotube
    cnt = nanotube(3, 3, length=1, bond=1.4)
    four = Fourier()
    four.grid.bins = [6, 6, 2]
    four.structure = cnt
    four.grid.ll = [0.0, 0.0, 0.0]
    four.grid.lr = [2.0, 0.0, 0.0]
    four.grid.ul = [0.0, 2.0, 0.0]
    four.grid.tl = [0.0, 0.0, 0.5]
    results = four.calc()
    expected_result = [[[6.36497605e+03,   3.18248802e+03],
                        [5.19826149e+03,   2.62430530e+03],
                        [2.62792897e+03,   1.44984089e+03],
                        [5.38964665e+02,   4.77287736e+02],
                        [1.77345692e+01,   5.96777257e+01],
                        [5.61330972e+02,   2.13240090e-01]],
                       [[5.19824634e+03,   2.58464390e+03],
                        [4.19804025e+03,   2.08045239e+03],
                        [2.02566353e+03,   1.13472923e+03],
                        [3.43108613e+02,   3.82910378e+02],
                        [4.89415344e+01,   6.29938344e+01],
                        [5.92919277e+02,   4.58410816e+00]],
                       [[2.62726847e+03,   1.23823945e+03],
                        [2.02670889e+03,   8.48260672e+02],
                        [7.91958690e+02,   3.42380372e+02],
                        [3.33463046e+01,   5.27598268e+01],
                        [2.30729880e+02,   5.28798893e-01],
                        [7.98830716e+02,   8.58598324e+00]],
                       [[5.35796499e+02,   1.75090475e+02],
                        [3.44314616e+02,   3.58530973e+01],
                        [3.54586483e+01,   1.01212665e+01],
                        [1.11489239e+02,   1.22750852e+02],
                        [6.43708514e+02,   2.21345300e+02],
                        [1.09996107e+03,   1.70969809e+02]],
                       [[2.07782589e+01,   8.83691575e+01],
                        [4.95216235e+01,   3.06779369e+02],
                        [2.12904292e+02,   6.20110076e+02],
                        [6.00173935e+02,   8.55468985e+02],
                        [1.07400507e+03,   8.34634162e+02],
                        [1.26315713e+03,   5.49870658e+02]],
                       [[6.17667297e+02,   7.27129729e+02],
                        [6.16759220e+02,   1.22358912e+03],
                        [7.37019649e+02,   1.60499636e+03],
                        [9.37950901e+02,   1.66971846e+03],
                        [1.09292588e+03,   1.35970016e+03],
                        [1.03004750e+03,   8.27690724e+02]]]
    assert_array_almost_equal(results, expected_result, 5)
    results = four.calc(fast=False)
    assert_array_almost_equal(results, expected_result, 5)
Ejemplo n.º 4
0
 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}
Ejemplo n.º 5
0
 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)
         self.pybut.python = py_template % {
             'n': n,
             'm': m,
             'length': length,
             'symb': symb,
             'bl': bl
         }
Ejemplo n.º 6
0
from ase.io import write
from ase.structure import bulk, 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')
gnr1.set_cell(np.diag(gnr1.cell)[ind])
gnr1.positions = gnr1.positions[:, ind]
Ejemplo n.º 7
0
def constructTube():
   cnt = nanotube(6, 6, length=l)
   write('cnt.xyz', cnt)

   return cnt
Ejemplo n.º 8
0
from ase.structure import molecule
from ase.structure import nanotube
from ase.optimize import BFGS, MDMin
from asap3 import BrennerPotential
from asap3.testtools import ReportTest
import numpy as np

atoms = nanotube(5, 5, length=10)
atoms.set_calculator(BrennerPotential())
uc = atoms.get_cell()
l0 = uc[2,2]

e = -1e100
for eps in np.linspace(0, 0.5, 201):
    uc[2,2] = l0 * (1 + eps)
    atoms.set_cell(uc, scale_atoms=True)
    dyn = MDMin(atoms, logfile=None, dt=0.05)
    dyn.run(fmax=0.01, steps=100)
    epot = atoms.get_potential_energy()
    if epot > e:
        e = epot
    print "%.3f  %f" % (eps, epot)

print "Maximal energy:", e
ReportTest("Maximal energy", e, -969.0, 5.0)
if abs(e - -620.98) < 1.0:
    print "Bug 42 is back!"
Ejemplo n.º 9
0
from ase.structure import nanotube
from gpaw import GPAW, Mixer, PoissonSolver, ConvergenceError
from gpaw.eigensolvers.rmm_diis import RMM_DIIS
from gpaw.mpi import size
from gpaw.mpi import rank
from gpaw.test import equal
from gpaw import use_mic

import time

tube = nanotube(6, 6, 10)

if rank == 0:
    print "Starting solver..."
tstart = time.time()
if use_mic:
    txt = 'out_nanotube_large_mic_p%d.txt' % size
else:
    txt = 'out_nanotube_large_p%d.txt' % size

conv = {'eigenstates': 1e-4, 'density': 1e-2, 'energy': 1e-3}
calc = GPAW(  # gpts=(96, 96, 128), 
    h=0.2,
    nbands=-60,
    width=0.1,
    poissonsolver=PoissonSolver(eps=1e-12),
    eigensolver=RMM_DIIS(keep_htpsit=False),
    # eigensolver=RMM_DIIS(),
    maxiter=6,
    mixer=Mixer(0.1, 5, 50),
    convergence=conv,
Ejemplo n.º 10
0
# creates: a1.png a2.png a3.png cnt1.png cnt2.png gnr1.png gnr2.png
from ase.io import write
from ase.lattice import bulk
from ase.structure 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]
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]
Ejemplo n.º 11
0
from ase.structure import nanotube
from gpaw import GPAW, Mixer, PoissonSolver
from gpaw.mpi import size
from gpaw.test import equal
from gpaw import use_mic
from gpaw.mpi import rank

import time

tube = nanotube(6,6,9)

if rank == 0:
    print "Starting solver..."
tstart = time.time()
if use_mic:
    txt = 'out_nanotube2_mic_p%d.txt' % size
else:
    txt = 'out_nanotube2_p%d.txt' % size
conv = {'eigenstates' : 1e-4, 'density' : 1e-2, 'energy' : 1e-3}
calc = GPAW(gpts=(96, 96, 128), nbands=-20, width=0.1,
            poissonsolver=PoissonSolver(eps=1e-12),
            mixer=Mixer(0.1, 5, 50),
            convergence=conv, txt=txt)
tube.set_calculator(calc)
e = tube.get_potential_energy()
tend = time.time()
if rank == 0:
    print "time for calculation: {0:.2f}sec".format(tend-tstart)
equal(e, -2159.016150, 1e-2)
Ejemplo n.º 12
0
        tube[i + 2].symbol = 'N'
        i += 3
    return tube


def convert_BN(tube):

    i = 0
    while i < len(tube):
        tube[i + 0].symbol = 'B'
        tube[i + 1].symbol = 'N'
        i += 2
    return tube


tube = nanotube(n_inner, m_inner, length=6, bond=cbond, symbol='C')
lx, ly, lz = tube.get_cell()[0][0], tube.get_cell()[1][1], tube.get_cell(
)[2][2]

print 'Set lx and ly to ', lxoverride

tube.set_cell([lxoverride, lxoverride, lz], scale_atoms=False)

if BCN == True: convert_BCN(tube)
if BN == True: convert_BN(tube)

tube.center()

io.write('POSCAR.1', tube, sort=True)

tube2 = nanotube(n_outer, m_outer, length=6, bond=cbond, symbol='C')
Ejemplo n.º 13
0
from ase.structure import nanotube
from gpaw import GPAW, RMM_DIIS
from gpaw.mpi import size
from gpaw.test import equal
from gpaw import use_mic
from gpaw.mpi import rank

import time

tube = nanotube(8,8,8)

if rank == 0:
    print "Starting solver..."
tstart = time.time()
if use_mic:
    txt = 'out_nanotube1_mic_p%d.txt' % size
else:     
    txt = 'out_nanotube1_p%d.txt' % size
conv = {'eigenstates' : 1e-4, 'density' : 1e-2, 'energy' : 1e-2}
calc = GPAW(h=0.2, nbands=-20, width=0.1, kpts=(1,1,2), 
            eigensolver=RMM_DIIS(keep_htpsit=False),
            #convergence=conv, txt=txt)
            convergence=conv)
tube.set_calculator(calc)
e = tube.get_potential_energy()
tend = time.time()
if rank == 0:
    print "time for calculation: {0:.2f}sec".format(tend-tstart)
equal(e, -628.838671, 1e-2)
Ejemplo n.º 14
0
from ase.structure import nanotube
from gpaw import GPAW, RMM_DIIS
from gpaw.mpi import size
from gpaw.test import equal
from gpaw import use_mic
from gpaw.mpi import rank

import time

tube = nanotube(8, 8, 8)

if rank == 0:
    print "Starting solver..."
tstart = time.time()
if use_mic:
    txt = 'out_nanotube1_mic_p%d.txt' % size
else:
    txt = 'out_nanotube1_p%d.txt' % size
conv = {'eigenstates': 1e-4, 'density': 1e-2, 'energy': 1e-2}
calc = GPAW(
    h=0.2,
    nbands=-20,
    width=0.1,
    kpts=(1, 1, 2),
    eigensolver=RMM_DIIS(keep_htpsit=False),
    #convergence=conv, txt=txt)
    convergence=conv)
tube.set_calculator(calc)
e = tube.get_potential_energy()
tend = time.time()
if rank == 0:
Ejemplo n.º 15
0
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