import math


def VD_5111(jointType, boltHead, d, d3, lGew, Es, EBI):
    """
    5.1.1.1 Axial Resilience
    
    Joint type :
        ESV - Tapped blind hole joint
        DSV - Through bolted joint with nut
    Bolt head :
        socket
        other
    F  : axial load
    d  : bolt diameter
    d3 : bolt minor diameter of the thread
    lGew : lenght of the free loaded thread
    Es  : Bolt Young's modulus
    EBI : Young's modulus of the component with internal treatd
    """
    
    # Elastic resilience of the engaged thread
    lG = 0.50 * d                     # (5.1/6)
    Ad3 = (math.pi / 4.0) * d3**2     # (5.1/7)
    delta_G = lG / (Es * Ad3)         # (5.1/5)
    
    # The elastic resilience of the nut or tapped thread region
    # ESV Tapped blind hole joint
    if jointType == 'ESV':
        EM = EBI
        lM = 0.33 * d   # (5.1/11)
    # bolted and stud bolted joints
    # DSV Through bolted joint with nut
    else:
        EM = Es
        lM = 0.40 * d  # (5.1/10)
    
    AN = (math.pi / 4.0) * d**2      # (5.1/9)
    delta_M = lM / (EM * AN)         # (5.1/8)
    
    # Elastic resilience of the engaged thread and of the nut
    # or tapped thread region
    delta_GM = delta_G + delta_M   # (5.1/4)
    
    # The resilience of the unengageg loaded part of the thread
    delta_Gew = lGew / (Es * Ad3)      # (5.1/12)
    
    # The elastic resilience of the head of standardized
    # hexagon head bolts and hexagon socket screws
    if boltHead == 'socket': lSK = 0.40 * d    # (5.1/15)
    else : lSK = 0.50 * d                      # (5.1/14)
    delta_SK = lSK / (Es * AN)                 # (5.1/13)
    
    # Elastic resilience of the bolt
    # delta_S = deltaSK + deltai + deltaGew + deltaGM  # (5.1/3)
    #delta_S = deltaSK + deltaGew + deltaGM
    #
    return delta_SK, delta_Gew, delta_GM
    #