except ImportError: pass else: w += ['png', 'eps'] for format in w: print(format, 'O', end=' ') fname1 = 'io-test.1.' + format fname2 = 'io-test.2.' + format write(fname1, atoms, format=format) if format not in ['cube', 'png', 'eps', 'cfg', 'struct']: write(fname2, images, format=format) if format in r: print('I') a1 = read(fname1) assert np.all( np.abs(a1.get_positions() - atoms.get_positions()) < 1e-6) if format in ['traj', 'cube', 'cfg', 'struct']: assert np.all(np.abs(a1.get_cell() - atoms.get_cell()) < 1e-6) if format in ['cfg']: assert np.all( np.abs(a1.get_array('extra') - atoms.get_array('extra')) < 1e-6) if format not in ['cube', 'png', 'eps', 'cfg', 'struct']: a2 = read(fname2) a3 = read(fname2, index=0) a4 = read(fname2, index=slice(None)) else: print()
import numpy as np from ase_ext import Atoms, Atom a = Atoms([Atom('Cu')]) a.positions[:] += 1.0 print(a.get_positions(), a.positions) a = a + a a += a a.append(Atom('C')) a += Atoms([]) a += Atom('H', magmom=1) print(a.get_initial_magnetic_moments()) print(a[0].number) print(a[[0, 1]].get_atomic_numbers()) print(a[np.array([1, 1, 0, 0, 1], bool)].get_atomic_numbers()) print(a[::2].get_atomic_numbers()) print(a.get_chemical_symbols()) del a[2] print(a.get_chemical_symbols()) del a[-2:] print(a.get_chemical_symbols())
from ase_ext import Atoms from ase_ext.io import read, write from ase_ext.calculators import Exciting from ase_ext.units import Bohr, Hartree from ase_ext.test import NotAvailable try: import lxml except ImportError: raise NotAvailable('This test need lxml module.') a = Atoms('N3O', [(0, 0, 0), (1, 0, 0), (0, 0, 1), (0.5, 0.5, 0.5)], pbc=True) raise NotAvailable('Problem with lxml module.') write('geo.exi', a) b = read('geo.exi') print(a) print(a.get_positions()) print(b) print(b.get_positions()) calculator = Exciting(dir='excitingtestfiles', kpts=(4, 4, 3), maxscl=3, #bin='/fshome/chm/git/exciting/bin/excitingser' )