def test_geometry_car_allsame(sisl_tmp): f = sisl_tmp('test_read_write.POSCAR', _dir) atoms = Atom[1] xyz = np.random.rand(10, 3) geom = Geometry(xyz, atoms, 100) geom.write(carSileVASP(f, 'w')) assert carSileVASP(f).read_geometry() == geom
def test_geometry_car_mixed(sisl_tmp): f = sisl_tmp('test_read_write.POSCAR', _dir) atoms = [Atom[1], Atom[2], Atom[2], Atom[1], Atom[1], Atom[2], Atom[3]] xyz = np.random.rand(len(atoms), 3) geom = Geometry(xyz, atoms, 100) geom.write(carSileVASP(f, 'w')) assert carSileVASP(f).read_geometry() == geom
def test_geometry_car_group(sisl_tmp): f = sisl_tmp('test_sort.POSCAR', _dir) atoms = [Atom[1], Atom[2], Atom[2], Atom[1], Atom[1], Atom[2], Atom[3]] xyz = np.random.rand(len(atoms), 3) geom = Geometry(xyz, atoms, 100) geom.write(carSileVASP(f, 'w'), group_species=True) assert carSileVASP(f).read_geometry() != geom geom = carSileVASP(f).geometry_group(geom) assert carSileVASP(f).read_geometry() == geom
def test_geometry_car_dynamic(sisl_tmp): f = sisl_tmp('test_dynamic.POSCAR', _dir) atoms = Atom[1] xyz = np.random.rand(10, 3) geom = Geometry(xyz, atoms, 100) read = carSileVASP(f) # no dynamic (direct geometry) geom.write(carSileVASP(f, 'w'), dynamic=None) g, dyn = read.read_geometry(ret_dynamic=True) assert dyn is None geom.write(carSileVASP(f, 'w'), dynamic=False) g, dyn = read.read_geometry(ret_dynamic=True) assert not np.any(dyn) geom.write(carSileVASP(f, 'w'), dynamic=True) g, dyn = read.read_geometry(ret_dynamic=True) assert np.all(dyn) dynamic = [False] * len(geom) dynamic[0] = [True, False, True] geom.write(carSileVASP(f, 'w'), dynamic=dynamic) g, dyn = read.read_geometry(ret_dynamic=True) assert np.array_equal(dynamic[0], dyn[0]) assert not np.any(dyn[1:])
def test_nc_ghost(sisl_tmp): f = sisl_tmp('ghost.nc', _dir) a1 = Atom(1) am1 = Atom(-1) g = Geometry([[0., 0., i] for i in range(2)], [a1, am1], 2.) g.write(ncSileSiesta(f, 'w')) g2 = ncSileSiesta(f).read_geometry() assert np.allclose(g.cell, g2.cell) assert np.allclose(g.xyz, g2.xyz) assert np.allclose(g.atoms.Z, g2.atoms.Z) assert g.atoms[0].__class__ is g2.atoms[0].__class__ assert g.atoms[1].__class__ is g2.atoms[1].__class__ assert g.atoms[0].__class__ is not g2.atoms[1].__class__