def Gibbs(tempK, presPa):
    """Gibbs energy function."""
    Gdict = {(0, 0): 101.342743139674, (3, 2): 499.360390819152, (0, 1): 
        100015.695367145, (3, 3): -239.545330654412, (0, 2): -
        2544.5765420363, (3, 4): 48.8012518593872, (0, 3): 284.517778446287,
        (3, 5): -1.66307106208905, (0, 4): -33.3146754253611, (4, 0): -
        148.185936433658, (0, 5): 4.20263108803084, (4, 1): 
        397.968445406972, (0, 6): -0.546428511471039, (4, 2): -
        301.815380621876, (1, 0): 5.90578347909402, (4, 3): 
        152.196371733841, (1, 1): -270.983805184062, (4, 4): -
        26.3748377232802, (1, 2): 776.153611613101, (5, 0): 
        58.0259125842571, (1, 3): -196.51255088122, (5, 1): -
        194.618310617595, (1, 4): 28.9796526294175, (5, 2): 
        120.520654902025, (1, 5): -2.13290083518327, (5, 3): -
        55.2723052340152, (2, 0): -12357.785933039, (5, 4): 
        6.48190668077221, (2, 1): 1455.0364540468, (6, 0): -
        18.9843846514172, (2, 2): -756.558385769359, (6, 1): 
        63.5113936641785, (2, 3): 273.479662323528, (6, 2): -
        22.2897317140459, (2, 4): -55.5604063817218, (6, 3): 
        8.17060541818112, (2, 5): 4.34420671917197, (7, 0): 
        3.05081646487967, (3, 0): 736.741204151612, (7, 1): -
        9.63108119393062, (3, 1): -672.50778314507}
    ctau = (tempK - 273.15) / 40
    cpi = (presPa - 101325) / 100000000.0
    Gsum = 0
    for j in range(8):
        for k in range(7):
            if (j, k) in Gdict.keys():
                Gsum = Gsum + Gdict[j, k] * ctau ** j * cpi ** k
    return Gsum
