# Path: mpinterfaces/lma.py
# def get_trans_matrices(n):
# def get_uv(ab, t_mat):
# def get_reduced_uv(uv, tm):
# def reduced_supercell_vectors(ab, n):
# def get_r_list(area1, area2, max_area, tol=0.02):
# def get_mismatch(a, b):
# def get_angle(a, b):
# def surface_area(cell):
# def get_area(uv):
# def remove_duplicates(uv_list, tm_list):
# def get_matching_lattices(iface1, iface2, max_area=100,
#                           max_mismatch=0.01, max_angle_diff=1,
#                           r1r2_tol=0.02, opt=False, best_match='area'):
# def get_uniq_layercoords(struct, nlayers, top=True):
# def get_interface(substrate, mat2d, nlayers_2d=2, nlayers_substrate=2,
#                                  separation=5):
# def get_aligned_lattices(slab_sub, slab_2d, max_area=200,
#                          max_mismatch=0.05,
#                          max_angle_diff=1, r1r2_tol=0.2, best_match='area'):
# def run_lat_match(substrate, twod_layer, match_constraints):


from mpinterfaces import lma
from pymatgen import Structure, Lattice
import numpy as np

from __future__ import division, unicode_literals, print_function

"""
Utility script to find if endpoint slabs are matching with substrate

Usage: Provide inputs <path to poscar substrate>, <path to poscar 2D> and
       match constraints using for the search

       python get_matching_matrix.py
"""
# import the lma module

#### Inputs for lattice matching #####
# substrate file path
sub_file = 'POSCAR_sub'
# twod file path
twod_file = 'POSCAR_twod'
sub = Structure.from_file(sub_file)
twod = Structure.from_file(twod_file)

# provide input match constraints as a dictionary
match_constraints = {'max_area':90, 'max_mismatch':0.06, 'max_angle_diff':2,
                     'r1r2_tol':0.04, 'separation': 2.2, 'nlayers_substrate':1,
                     'nlayers_2d':1, 'sd_layers':0, 'best_match': 'area'}
#########################################

# Lowest area (default) or minimum uv mismatched lattice match
# is returned based on 'best_match' option in match_constraints
# best_match should be either 'area' or 'mismatch'

# Path: mpinterfaces/lma.py
# def get_trans_matrices(n):
# def get_uv(ab, t_mat):
# def get_reduced_uv(uv, tm):
# def reduced_supercell_vectors(ab, n):
# def get_r_list(area1, area2, max_area, tol=0.02):
# def get_mismatch(a, b):
# def get_angle(a, b):
# def surface_area(cell):
# def get_area(uv):
# def remove_duplicates(uv_list, tm_list):
# def get_matching_lattices(iface1, iface2, max_area=100,
#                           max_mismatch=0.01, max_angle_diff=1,
#                           r1r2_tol=0.02, opt=False, best_match='area'):
# def get_uniq_layercoords(struct, nlayers, top=True):
# def get_interface(substrate, mat2d, nlayers_2d=2, nlayers_substrate=2,
#                                  separation=5):
# def get_aligned_lattices(slab_sub, slab_2d, max_area=200,
#                          max_mismatch=0.05,
#                          max_angle_diff=1, r1r2_tol=0.2, best_match='area'):
# def run_lat_match(substrate, twod_layer, match_constraints):


# Path: mpinterfaces/tests/test_lma.py
from mpinterfaces import lma
from pymatgen import Structure, Lattice
import numpy as np


from __future__ import division, unicode_literals, print_function

"""
Utility script to find if endpoint slabs are matching with substrate

Usage: Provide inputs <path to poscar substrate>, <path to poscar 2D> and
       match constraints using for the search

       python get_matching_matrix.py
"""
# import the lma module

#### Inputs for lattice matching #####
# substrate file path
sub_file = 'POSCAR_sub'
# twod file path
twod_file = 'POSCAR_twod'
sub = Structure.from_file(sub_file)
twod = Structure.from_file(twod_file)

# provide input match constraints as a dictionary
match_constraints = {'max_area':90, 'max_mismatch':0.06, 'max_angle_diff':2,
                     'r1r2_tol':0.04, 'separation': 2.2, 'nlayers_substrate':1,
                     'nlayers_2d':1, 'sd_layers':0, 'best_match': 'area'}
#########################################

# Lowest area (default) or minimum uv mismatched lattice match
# is returned based on 'best_match' option in match_constraints
# best_match should be either 'area' or 'mismatch'

iface, n_sub, z_ub = lma.run_lat_match(sub, twod, match_constraints)