How to use the function in ase

To help you get started, we’ve selected a few ase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github libAtoms / matscipy / tests / View on Github external
def test_c2d_input_format_npz_output_format_xyz(self):
        """c2d NaCl.npz"""
        print("  RUN test_c2d_input_format_npz_output_format_xyz")
        with tempfile.TemporaryDirectory() as tmpdir:
                [ 'c2d', os.path.join(self.data_path,'NaCl.npz'), '' ],
                check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                cwd=tmpdir, env=self.myenv)
            xyz =,''))
            self.assertTrue( ( xyz.symbols == self.ref_xyz.symbols ).all() )
            self.assertTrue( ( xyz.get_initial_charges() ==
                self.ref_xyz.get_initial_charges() ).all() )
            self.assertTrue( ( xyz.cell == self.ref_xyz.cell ).all() )
github libAtoms / matscipy / tests / View on Github external
def test_shrink_wrapped_direct_call(self):
        a ='aC.cfg')
        r = a.positions
        j, dr, i, abs_dr, shift = neighbour_list("jDidS", positions=r,

        self.assertTrue((np.bincount(i) == np.bincount(j)).all())

        dr_direct = r[j]-r[i]
        abs_dr_from_dr = np.sqrt(np.sum(dr*dr, axis=1))
        abs_dr_direct = np.sqrt(np.sum(dr_direct*dr_direct, axis=1))

        self.assertTrue(np.all(np.abs(abs_dr-abs_dr_from_dr) < 1e-12))
        self.assertTrue(np.all(np.abs(abs_dr-abs_dr_direct) < 1e-12))

        self.assertTrue(np.all(np.abs(dr-dr_direct) < 1e-12))
github giovannipizzi / seekpath / misc / View on Github external
import ase,

    from seekpath import get_explicit_k_path
    import seekpath.hpkot as hpkot

    with_inv = True
    ext_bravais = 'cP1'

    # Get the POSCAR with the example structure
    hpkot_folder = os.path.split(os.path.abspath(hpkot.__file__))[0]
    folder = os.path.join(hpkot_folder,"band_path_data",ext_bravais)
    poscar_with_inv = os.path.join(folder,'POSCAR_inversion')
    poscar_no_inv = os.path.join(folder,'POSCAR_noinversion')

    poscar = poscar_with_inv if with_inv else poscar_no_inv
    asecell =

    system = (asecell.get_cell(), asecell.get_scaled_positions(), 

    res = get_explicit_k_path(system, with_time_reversal=False) 

    for l, p in zip(res['explicit_kpoints_labels'], res['explicit_kpoints_abs']):
        print "{}\t{}".format(l, p)
    print res['explicit_kpoints_linearcoord']

    for l, p in zip(res['explicit_kpoints_labels'], res['explicit_kpoints_linearcoord']):
        print "{}\t{}".format(l, p)

    print len(res['explicit_kpoints_labels']), len(res['explicit_kpoints_abs']), \
github vanceeasleaf / aces / runners / View on Github external
def stub(self):
		files=shell_exec("ls dirs").split('\n')
		files=map(lambda x:x.replace('dir_',''),files)
		for file in files:
			from ase import io'SPOSCAR')
			for force in f:				
				forces+="  %f %f %f \n"%tuple(force)
	def force_constant(self,files):
github aiidateam / aiida-core / aiida / orm / nodes / data / View on Github external
        A wrapper method that simulates the behavior of the old
        function by using the new generic

        Somewhere from 3.12 to 3.17 the tag concept was bundled with each Atom object. When
        reading a CIF file, this is incremented and signifies the atomic species, even though
        the CIF file do not have specific tags embedded. On reading CIF files we thus force the
        ASE tag to zero for all Atom elements.

        from import read

        # The read function returns a list as a cif file might contain multiple
        # structures.
        struct_list = read(fileobj, index=':', format='cif', **kwargs)

        if index is None:
            # If index is explicitely set to None, the list is returned as such.
            for atoms_entry in struct_list:
            return struct_list
        # Otherwise return the desired structure specified by index, if no index is specified,
        # the last structure is assumed by default.
        return struct_list[index]
github rosswhitfield / ase / ase / cli / View on Github external
def read_band_structure(args, parser):
    # Read first as Atoms object, then try as JSON band structure:
        atoms = read(args.calculation)
    except UnknownFileTypeError:
        return atoms2bandstructure(atoms, parser, args)

        bs = read_json(args.calculation)
    except json.decoder.JSONDecodeError:
        parser.error('File resembles neither atoms nor band structure')

    objtype = getattr(bs, 'ase_objtype', None)
    if objtype != 'bandstructure':
        parser.error('Expected band structure, but this file contains a {}'
                     .format(objtype or type(bs)))

    return bs
github rosswhitfield / ase / doc / tutorials / View on Github external
# creates: WL.png, Ni111slab2x2.png, WL_rot_c.png, WL_rot_a.png, WL_wrap.png, interface-h2o-wrap.png
import numpy as np
from import read, write
from import fcc111

exec(compile(open('').read(), '', 'exec'))

# Use to load atoms object
W = read('WL.traj')
# View the water unit or print the unit cell size.
write('WL.png', W)
# We will need cellW later.
cellW = W.get_cell()

# We will need as close a lattice match as possible. lets try this slab.
# Using the module, we make the fcc111 slab.
slab = fcc111('Ni', size=[2, 4, 3], a=3.55, orthogonal=True)
cell = slab.get_cell()
write('Ni111slab2x2.png', slab)

# Rotate the unit cell first to get the close lattice match with the slab.
W.set_cell([[cellW[1, 1], 0, 0],
            [0, cellW[0, 0], 0],
github rosswhitfield / ase / ase / cli / View on Github external
def run(args, parser):
        from import UnknownFileTypeError

            atoms = read(
        except UnknownFileTypeError:
            # Probably a bandpath/bandstructure:
            obj = read_json(
            if isinstance(obj, BandPath):
                path = obj
            elif hasattr(obj, 'path'):  # Probably band structure
                path = obj.path
                parser.error('Strange object: {}'.format(obj))
            path = atoms2bandpath(atoms, path=args.path,

github vanceeasleaf / aces / materials / View on Github external
def lmp_structure(self):
		return atoms
github SINGROUP / dscribe / examples / View on Github external
Demonstrates the use of the ASE library to load and create atomic
configurations that can be used in the dscribe package.

from dscribe.descriptors import MBTR
from dscribe.descriptors import CoulombMatrix
from dscribe.descriptors import SineMatrix

from dscribe.utils import system_stats

# Load configuration from an XYZ file with ASE. See
# "" for a list of supported file
# formats.
atoms ="")
atoms.set_cell([5.640200, 5.640200, 5.640200])

# There are utilities for automatically detecting statistics for ASE Atoms
# objects. Typically some statistics are needed for the descriptors in order to
# e.g. define a proper zero-padding
stats = system_stats([atoms])
n_atoms_max = stats["n_atoms_max"]
atomic_numbers = stats["atomic_numbers"]

# Create descriptors for this system directly from the ASE atoms
cm = CoulombMatrix(n_atoms_max, permutation="sorted_l2").create(atoms)
sm = SineMatrix(n_atoms_max, permutation="sorted_l2").create(atoms)
mbtr = MBTR(
    k=[1, 2, 3],