# Path: vasppy/units.py

# 
# Path: vasppy/band.py
# class Band():
# 
#     def __init__( self, index, energy, occupancy, negative_occupancies='warn' ):
#         self.index = index
#         self.energy = energy
#         self.occupancy = handle_occupancy( occupancy, negative_occupancies=negative_occupancies )
# 
#     def __eq__( self, other ):
#         return ( ( self.index == other.index ) &
#                  ( self.energy == other.energy ) &
#                  ( self.occupancy == other.occupancy ) )


import numpy as np  # type: ignore
import re
import math
import warnings
import fortranformat as ff  # type: ignore
from .units import angstrom_to_bohr, ev_to_hartree
from .band import Band
from copy import deepcopy
from functools import reduce
    Args:
        points (list(np.array)): list of Cartesian coordinates for each point.
        tolerance (optional:float): the maximum triangle size for these points to be considered colinear. Default is 1e-7.

    Returns:
        (bool): True if all points fall on a straight line (within the allowed tolerance).
    """
    a = points[0]
    b = points[1]
    for c in points[2:]:
        if area_of_a_triangle_in_cartesian_space( a, b, c ) > tolerance:
            return False
    return True

def two_point_effective_mass( cartesian_k_points, eigenvalues ):
    """
    Calculate the effective mass given eigenvalues at two k-points.
    Reimplemented from Aron Walsh's original effective mass Fortran code.

    Args:
        cartesian_k_points (np.array): 2D numpy array containing the k-points in (reciprocal) Cartesian coordinates.
        eigenvalues (np.array):        numpy array containing the eigenvalues at each k-point.

    Returns:
        (float): The effective mass
    """
    assert( cartesian_k_points.shape[0] == 2 )
    assert( eigenvalues.size == 2 )
    dk = cartesian_k_points[ 1 ] - cartesian_k_points[ 0 ]
    mod_dk = np.sqrt( np.dot( dk, dk ) )

# Path: vasppy/units.py

# 
# Path: vasppy/band.py
# class Band():
# 
#     def __init__( self, index, energy, occupancy, negative_occupancies='warn' ):
#         self.index = index
#         self.energy = energy
#         self.occupancy = handle_occupancy( occupancy, negative_occupancies=negative_occupancies )
# 
#     def __eq__( self, other ):
#         return ( ( self.index == other.index ) &
#                  ( self.energy == other.energy ) &
#                  ( self.occupancy == other.occupancy ) )


# Path: vasppy/procar.py
import numpy as np  # type: ignore
import re
import math
import warnings
import fortranformat as ff  # type: ignore
from .units import angstrom_to_bohr, ev_to_hartree
from .band import Band
from copy import deepcopy
from functools import reduce

    Args:
        points (list(np.array)): list of Cartesian coordinates for each point.
        tolerance (optional:float): the maximum triangle size for these points to be considered colinear. Default is 1e-7.

    Returns:
        (bool): True if all points fall on a straight line (within the allowed tolerance).
    """
    a = points[0]
    b = points[1]
    for c in points[2:]:
        if area_of_a_triangle_in_cartesian_space( a, b, c ) > tolerance:
            return False
    return True

def two_point_effective_mass( cartesian_k_points, eigenvalues ):
    """
    Calculate the effective mass given eigenvalues at two k-points.
    Reimplemented from Aron Walsh's original effective mass Fortran code.

    Args:
        cartesian_k_points (np.array): 2D numpy array containing the k-points in (reciprocal) Cartesian coordinates.
        eigenvalues (np.array):        numpy array containing the eigenvalues at each k-point.

    Returns:
        (float): The effective mass
    """
    assert( cartesian_k_points.shape[0] == 2 )
    assert( eigenvalues.size == 2 )
    dk = cartesian_k_points[ 1 ] - cartesian_k_points[ 0 ]
    mod_dk = np.sqrt( np.dot( dk, dk ) )

    delta_e = ( eigenvalues[ 1 ] - eigenvalues[ 0 ] ) * ev_to_hartree * 2.0