#! /usr/bin/env python
"""Example for reading structure from lammps output."""

from ase import io

import tbplas as tb

# Read the last image of lammps dump
atoms = io.read("struct.atom", format="lammps-dump-text", index=-1)

# Get cell lattice vectors in Angstroms
lattice_vectors = atoms.cell

# Create the cell
prim_cell = tb.PrimitiveCell(lat_vec=atoms.cell, unit=tb.ANG)

# Add orbitals
for atom in atoms:
    prim_cell.add_orbital(atom.scaled_position)

# Find hopping neighbors up to 0.145 nm
neighbors = tb.find_neighbors(prim_cell, a_max=1, b_max=1, max_distance=0.145)

# Add hopping terms
for term in neighbors:
    prim_cell.add_hopping(term.rn, term.pair[0], term.pair[1], energy=-2.7)

# Plot the cell
prim_cell.plot(with_cells=False, with_orbitals=False, hop_as_arrows=False)
