# Path: pyDFTutils/perovskite/octahedra.py
# def distance(a1,a2):
# def vec_ang(a,b):
# def atom_angle(a1,a2,a3):
# def even_or_odd_path(atoms,from_symnum,node_sym_list,to_symnum_list=None,first_neighbor_min=2.5,first_neighbor_max=4.5):
#     def even_odd(x):
# def rotation_angle_about_axis(vec0,from_vec,axis_vec):
#     def __init__(self):
#     def get_vertex(self,direction):
#     def set_axis(self,x=(1,0,0), y=(0,1,0),z=(0,0,1),axis_type=None):
#     def get_octahedra(self,atoms,center_atom,atom_symbol,max_distance,var_distance=False,do_force_near_0=True,repeat=True):
#     def read_octahedra(self,filename,center_sym_number,vertex_symbol,max_distance,var_distance=False):
#     def pair(self,ang_thr=20):
#     def get_bond_lengths(self):
#     def get_vertex_diag_length(self):
#     def get_directions(self):
#     def get_rotations(self):
#     def get_avg_rotations(self):
#     def get_distortion(self):
#     def get_bond_info(self,show=True):
#     def get_bond_angle(self):
#     def find_neighbouring_octahedron(self,direction='upper',target_symbol_list=None,do_force_near_0=False):
#     def get_vertex_angle(self,direction='upper',target_symbol_list=None,do_force_near_0=False):
#     def get_vertex_angles(self,target_symbol_list=None,do_force_near_0=False):
# def get_octahedron(atoms,center_sym_number,vertex_symbol,max_distance, axis_type=None,x=(1,0,0),y=(0,1,0),z=(0,0,1), var_distance=False):
# def octa_chain(start_octahedron,direction='upper',target_symbol_list=None):
# def rotate_atoms_with_octahedra(atoms,octa):
# def rotate_atoms_with_octahedra_average(atoms,octahedras):
# def write_all_octahedra_info(atoms,center_symbol_list,vertex_symbol,max_distance,output='octa_info.csv',axis_type=None,x=(1,0,0),y=(0,1,0),z=(0,0,1), var_distance=False):
# def main():
#     N=len(node_list)
# class octahedra():


from pyDFTutils.perovskite.octahedra import even_or_odd_path,symnum_to_sym
from ase.io.vasp import read_vasp
import argparse
#!/usr/bin/env python
def test():
    parser=argparse.ArgumentParser(description='Decide AFM structure 1 -1')
    parser.add_argument('-f','--filename',type=str,help='POSCAR filename',default='POSCAR.vasp')
    parser.add_argument('-n','--nodes',type=str,help='symbol of element on the node',nargs='+')
    parser.add_argument('-o','--origin',type=str,help='From which symbol_number')
    parser.add_argument('--xmin',type=float,help='xmin',default=0.5)
    parser.add_argument('--xmax',type=float,help='xmax',default=4.8)
    args=parser.parse_args()

    #plot_all_pdos(element_types=args.element,filename=args.filename,ispin=args.ispin,ymin=args.ymin,ymax=args.ymax,xmin=args.xmin,xmax=args.xmax,output_dir=args.output)

    atoms=read_vasp(args.filename)
    symnums,vals= even_or_odd_path(atoms,args.origin,args.nodes,first_neighbor_min=args.xmin,first_neighbor_max=args.xmax)
    for sym in args.nodes:
        vs=[]
        for i,(s,v) in enumerate(zip(symnums,vals)):
            if symnum_to_sym(s)==sym:
                vs.append(v)
        print('%s: %s'%(sym,vs))


if __name__ == '__main__':

# Path: pyDFTutils/perovskite/octahedra.py
# def distance(a1,a2):
# def vec_ang(a,b):
# def atom_angle(a1,a2,a3):
# def even_or_odd_path(atoms,from_symnum,node_sym_list,to_symnum_list=None,first_neighbor_min=2.5,first_neighbor_max=4.5):
#     def even_odd(x):
# def rotation_angle_about_axis(vec0,from_vec,axis_vec):
#     def __init__(self):
#     def get_vertex(self,direction):
#     def set_axis(self,x=(1,0,0), y=(0,1,0),z=(0,0,1),axis_type=None):
#     def get_octahedra(self,atoms,center_atom,atom_symbol,max_distance,var_distance=False,do_force_near_0=True,repeat=True):
#     def read_octahedra(self,filename,center_sym_number,vertex_symbol,max_distance,var_distance=False):
#     def pair(self,ang_thr=20):
#     def get_bond_lengths(self):
#     def get_vertex_diag_length(self):
#     def get_directions(self):
#     def get_rotations(self):
#     def get_avg_rotations(self):
#     def get_distortion(self):
#     def get_bond_info(self,show=True):
#     def get_bond_angle(self):
#     def find_neighbouring_octahedron(self,direction='upper',target_symbol_list=None,do_force_near_0=False):
#     def get_vertex_angle(self,direction='upper',target_symbol_list=None,do_force_near_0=False):
#     def get_vertex_angles(self,target_symbol_list=None,do_force_near_0=False):
# def get_octahedron(atoms,center_sym_number,vertex_symbol,max_distance, axis_type=None,x=(1,0,0),y=(0,1,0),z=(0,0,1), var_distance=False):
# def octa_chain(start_octahedron,direction='upper',target_symbol_list=None):
# def rotate_atoms_with_octahedra(atoms,octa):
# def rotate_atoms_with_octahedra_average(atoms,octahedras):
# def write_all_octahedra_info(atoms,center_symbol_list,vertex_symbol,max_distance,output='octa_info.csv',axis_type=None,x=(1,0,0),y=(0,1,0),z=(0,0,1), var_distance=False):
# def main():
#     N=len(node_list)
# class octahedra():


# Path: scripts/AFM_parameter.py
from pyDFTutils.perovskite.octahedra import even_or_odd_path,symnum_to_sym
from ase.io.vasp import read_vasp
import argparse

#!/usr/bin/env python
def test():
    parser=argparse.ArgumentParser(description='Decide AFM structure 1 -1')
    parser.add_argument('-f','--filename',type=str,help='POSCAR filename',default='POSCAR.vasp')
    parser.add_argument('-n','--nodes',type=str,help='symbol of element on the node',nargs='+')
    parser.add_argument('-o','--origin',type=str,help='From which symbol_number')
    parser.add_argument('--xmin',type=float,help='xmin',default=0.5)
    parser.add_argument('--xmax',type=float,help='xmax',default=4.8)
    args=parser.parse_args()

    #plot_all_pdos(element_types=args.element,filename=args.filename,ispin=args.ispin,ymin=args.ymin,ymax=args.ymax,xmin=args.xmin,xmax=args.xmax,output_dir=args.output)

    atoms=read_vasp(args.filename)
    symnums,vals= even_or_odd_path(atoms,args.origin,args.nodes,first_neighbor_min=args.xmin,first_neighbor_max=args.xmax)
    for sym in args.nodes:
        vs=[]
        for i,(s,v) in enumerate(zip(symnums,vals)):
            if symnum_to_sym(s)==sym:
                vs.append(v)
        print('%s: %s'%(sym,vs))


if __name__ == '__main__':

    test()