# Path: pyDFTutils/phonon/plotphon.py
# def plot_band_weight(kslist,
#                      ekslist,
#                      wkslist=None,
#                      efermi=0,
#                      yrange=None,
#                      output=None,
#                      style='alpha',
#                      color='blue',
#                      axis=None,
#                      width=2,
#                      xticks=None,
#                      title=None):
#     if axis is None:
#         fig, a = plt.subplots()
#         plt.tight_layout(pad=2.19)
#         plt.axis('tight')
#         plt.gcf().subplots_adjust(left=0.17)
#     else:
#         a = axis
#     if title is not None:
#         a.set_title(title)
# 
#     xmax = max(kslist[0])
#     if yrange is None:
#         yrange = (np.array(ekslist).flatten().min() - 66,
#                   np.array(ekslist).flatten().max() + 66)
# 
#     if wkslist is not None:
#         for i in range(len(kslist)):
#             x = kslist[i]
#             y = ekslist[i]
#             lwidths = np.array(wkslist[i]) * width
#             #lwidths=np.ones(len(x))
#             points = np.array([x, y]).T.reshape(-1, 1, 2)
#             segments = np.concatenate([points[:-1], points[1:]], axis=1)
#             if style == 'width':
#                 lc = LineCollection(segments, linewidths=lwidths, colors=color)
#             elif style == 'alpha':
#                 lc = LineCollection(
#                     segments,
#                     linewidths=[2] * len(x),
#                     colors=[
#                         colorConverter.to_rgba(
#                             color, alpha=np.abs(lwidth / (width + 0.001)))
#                         for lwidth in lwidths
#                     ])
# 
#             a.add_collection(lc)
#     plt.ylabel('Frequency (cm$^{-1}$)')
#     if axis is None:
#         for ks, eks in zip(kslist, ekslist):
#             plt.plot(ks, eks, color='gray', linewidth=0.001)
#         a.set_xlim(0, xmax)
#         a.set_ylim(yrange)
#         if xticks is not None:
#             plt.xticks(xticks[1], xticks[0])
#         for x in xticks[1]:
#             plt.axvline(x, color='gray', linewidth=0.5)
#         if efermi is not None:
#             plt.axhline(linestyle='--', color='black')
#     return a


import abipy.abilab as abilab
import numpy as np
import matplotlib.pyplot as plt
import sys
from ase.build import bulk
from ase.dft.kpoints import get_special_points, bandpath
from pyDFTutils.unfolding.phonon_unfolder import phonon_unfolder
from pyDFTutils.phonon.plotphon import plot_band_weight
#!/usr/bin/env python

atomic_masses = np.array([
    1., 1.008, 4.002602, 6.94, 9.0121831, 10.81, 12.011, 14.007, 15.999,
    18.99840316, 20.1797, 22.98976928, 24.305, 26.9815385, 28.085, 30.973762,
    32.06, 35.45, 39.948, 39.0983, 40.078, 44.955908, 47.867, 50.9415, 51.9961,
    54.938044, 55.845, 58.933194, 58.6934, 63.546, 65.38, 69.723, 72.63,
    74.921595, 78.971, 79.904, 83.798, 85.4678, 87.62, 88.90584, 91.224,
    92.90637, 95.95, 97.90721, 101.07, 102.9055, 106.42, 107.8682, 112.414,
    114.818, 118.71, 121.76, 127.6, 126.90447, 131.293, 132.90545196, 137.327,
    138.90547, 140.116, 140.90766, 144.242, 144.91276, 150.36, 151.964, 157.25,
    158.92535, 162.5, 164.93033, 167.259, 168.93422, 173.054, 174.9668, 178.49,
    180.94788, 183.84, 186.207, 190.23, 192.217, 195.084, 196.966569, 200.592,
    204.38, 207.2, 208.9804, 208.98243, 209.98715, 222.01758, 223.01974,
    226.02541, 227.02775, 232.0377, 231.03588, 238.02891, 237.04817, 244.06421,
    243.06138, 247.07035, 247.07031, 251.07959, 252.083, 257.09511, 258.09843,
    259.101, 262.11, 267.122, 268.126, 271.134, 270.133, 269.1338, 278.156,
    281.165, 281.166, 285.177, 286.182, 289.19, 289.194, 293.204, 293.208,
    294.214
])


def kpath():
    #DDB = abilab.abiopen('out_DDB')
    #struct = DDB.structure
    #atoms = DDB.structure.to_ase_atoms()
    atoms = bulk('Cu','fcc')

# Path: pyDFTutils/phonon/plotphon.py
# def plot_band_weight(kslist,
#                      ekslist,
#                      wkslist=None,
#                      efermi=0,
#                      yrange=None,
#                      output=None,
#                      style='alpha',
#                      color='blue',
#                      axis=None,
#                      width=2,
#                      xticks=None,
#                      title=None):
#     if axis is None:
#         fig, a = plt.subplots()
#         plt.tight_layout(pad=2.19)
#         plt.axis('tight')
#         plt.gcf().subplots_adjust(left=0.17)
#     else:
#         a = axis
#     if title is not None:
#         a.set_title(title)
# 
#     xmax = max(kslist[0])
#     if yrange is None:
#         yrange = (np.array(ekslist).flatten().min() - 66,
#                   np.array(ekslist).flatten().max() + 66)
# 
#     if wkslist is not None:
#         for i in range(len(kslist)):
#             x = kslist[i]
#             y = ekslist[i]
#             lwidths = np.array(wkslist[i]) * width
#             #lwidths=np.ones(len(x))
#             points = np.array([x, y]).T.reshape(-1, 1, 2)
#             segments = np.concatenate([points[:-1], points[1:]], axis=1)
#             if style == 'width':
#                 lc = LineCollection(segments, linewidths=lwidths, colors=color)
#             elif style == 'alpha':
#                 lc = LineCollection(
#                     segments,
#                     linewidths=[2] * len(x),
#                     colors=[
#                         colorConverter.to_rgba(
#                             color, alpha=np.abs(lwidth / (width + 0.001)))
#                         for lwidth in lwidths
#                     ])
# 
#             a.add_collection(lc)
#     plt.ylabel('Frequency (cm$^{-1}$)')
#     if axis is None:
#         for ks, eks in zip(kslist, ekslist):
#             plt.plot(ks, eks, color='gray', linewidth=0.001)
#         a.set_xlim(0, xmax)
#         a.set_ylim(yrange)
#         if xticks is not None:
#             plt.xticks(xticks[1], xticks[0])
#         for x in xticks[1]:
#             plt.axvline(x, color='gray', linewidth=0.5)
#         if efermi is not None:
#             plt.axhline(linestyle='--', color='black')
#     return a


# Path: pyDFTutils/unfolding/DDB_unfolder.py
import abipy.abilab as abilab
import numpy as np
import matplotlib.pyplot as plt
import sys
from ase.build import bulk
from ase.dft.kpoints import get_special_points, bandpath
from pyDFTutils.unfolding.phonon_unfolder import phonon_unfolder
from pyDFTutils.phonon.plotphon import plot_band_weight

#!/usr/bin/env python

atomic_masses = np.array([
    1., 1.008, 4.002602, 6.94, 9.0121831, 10.81, 12.011, 14.007, 15.999,
    18.99840316, 20.1797, 22.98976928, 24.305, 26.9815385, 28.085, 30.973762,
    32.06, 35.45, 39.948, 39.0983, 40.078, 44.955908, 47.867, 50.9415, 51.9961,
    54.938044, 55.845, 58.933194, 58.6934, 63.546, 65.38, 69.723, 72.63,
    74.921595, 78.971, 79.904, 83.798, 85.4678, 87.62, 88.90584, 91.224,
    92.90637, 95.95, 97.90721, 101.07, 102.9055, 106.42, 107.8682, 112.414,
    114.818, 118.71, 121.76, 127.6, 126.90447, 131.293, 132.90545196, 137.327,
    138.90547, 140.116, 140.90766, 144.242, 144.91276, 150.36, 151.964, 157.25,
    158.92535, 162.5, 164.93033, 167.259, 168.93422, 173.054, 174.9668, 178.49,
    180.94788, 183.84, 186.207, 190.23, 192.217, 195.084, 196.966569, 200.592,
    204.38, 207.2, 208.9804, 208.98243, 209.98715, 222.01758, 223.01974,
    226.02541, 227.02775, 232.0377, 231.03588, 238.02891, 237.04817, 244.06421,
    243.06138, 247.07035, 247.07031, 251.07959, 252.083, 257.09511, 258.09843,
    259.101, 262.11, 267.122, 268.126, 271.134, 270.133, 269.1338, 278.156,
    281.165, 281.166, 285.177, 286.182, 289.19, 289.194, 293.204, 293.208,
    294.214
])


def kpath():
    #DDB = abilab.abiopen('out_DDB')
    #struct = DDB.structure
    #atoms = DDB.structure.to_ase_atoms()
    atoms = bulk('Cu','fcc')

    points = get_special_points('fcc', atoms.cell, eps=0.01)