def final_energy_from_outcar( filename='OUTCAR' ):
    """
    Finds and returns the energy from a VASP OUTCAR file, by searching for the last `energy(sigma->0)` entry.

    Args:
        filename (Str, optional): OUTCAR filename. Defaults to 'OUTCAR'.

    Returns:
        (Float): The last energy read from the OUTCAR file.
    """
    with open( filename ) as f:
        outcar = f.read()
    energy_re = re.compile( "energy\(sigma->0\) =\s+([-\d\.]+)" )
    energy = float( energy_re.findall( outcar )[-1] )
    return energy
def final_energy_from_outcar ( filename = 'OUTCAR' ) : with open ( filename ) as f : outcar = f . read ( ) energy_re = re . compile ( "energy\(sigma->0\) =\s+([-\d\.]+)" ) energy = float ( energy_re . findall ( outcar ) [ - 1 ] ) return energy
Finds and returns the energy from a VASP OUTCAR file, by searching for the last `energy(sigma->0)` entry.

    Args:
        filename (Str, optional): OUTCAR filename. Defaults to 'OUTCAR'.

    Returns:
        (Float): The last energy read from the OUTCAR file.