import math


def evap_fract_time_fingas(heavy, c1, time, T, c2 = None):
    """
    Return the evaporated fraction []
    source : (Fingas, 2015)

    Parameters
    ----------
    heavy : True if the fuel need to follow a ln, else it will be a sqrt
    C : fingas constant
    time : Time from the spill [s]
    T : Temperature [K]
    c2 : second fingas constant, can be compute by defaut []

    """
    if c1 is None:
        raise Exception("The mix does not have Fingas constant c1 defined")

    if(time < 60): #else it will cause trouble with the log
        return 0
    b = 0
    T = T - 273.15
    if heavy:
        if c2 is None:
            c2 = 0.045
        #b = 15+273.15
        return (c1 + c2 * (T - b)) * math.log(time/60)  #temperature in [K], time in sec
    else:
        if c2 is None:
            c2 = 0.01
        #b = 15+273.15
        return (c1 + c2 * (T - b)) * math.sqrt(time/60)