def TWU_a_alpha_common(T, Tc, omega, a, full=True, quick=True, method='<STR_LIT>'):
Tr = T/Tc<EOL>if method == '<STR_LIT>':<EOL><INDENT>if Tr < <NUM_LIT:1>:<EOL><INDENT>L0, M0, N0 = <NUM_LIT>, <NUM_LIT>, <NUM_LIT><EOL>L1, M1, N1 = <NUM_LIT>, <NUM_LIT>, <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>L0, M0, N0 = <NUM_LIT>, <NUM_LIT>, -<NUM_LIT><EOL>L1, M1, N1 = <NUM_LIT>, <NUM_LIT>, -<NUM_LIT>  <EOL><DEDENT><DEDENT>elif method == '<STR_LIT>':<EOL><INDENT>if Tr < <NUM_LIT:1>:<EOL><INDENT>L0, M0, N0 = <NUM_LIT>, <NUM_LIT>, <NUM_LIT><EOL>L1, M1, N1 = <NUM_LIT>, <NUM_LIT>, <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>L0, M0, N0 = <NUM_LIT>, <NUM_LIT>, -<NUM_LIT><EOL>L1, M1, N1 = <NUM_LIT>,  <NUM_LIT>, -<NUM_LIT><EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if not full:<EOL><INDENT>alpha0 = Tr**(N0*(M0-<NUM_LIT:1.>))*exp(L0*(<NUM_LIT:1.>-Tr**(N0*M0)))<EOL>alpha1 = Tr**(N1*(M1-<NUM_LIT:1.>))*exp(L1*(<NUM_LIT:1.>-Tr**(N1*M1)))<EOL>alpha = alpha0 + omega*(alpha1 - alpha0)<EOL>return a*alpha<EOL><DEDENT>else:<EOL><INDENT>if quick:<EOL><INDENT>x0 = T/Tc<EOL>x1 = M0 - <NUM_LIT:1><EOL>x2 = N0*x1<EOL>x3 = x0**x2<EOL>x4 = M0*N0<EOL>x5 = x0**x4<EOL>x6 = exp(-L0*(x5 - <NUM_LIT:1.>))<EOL>x7 = x3*x6<EOL>x8 = M1 - <NUM_LIT:1.><EOL>x9 = N1*x8<EOL>x10 = x0**x9<EOL>x11 = M1*N1<EOL>x12 = x0**x11<EOL>x13 = x2*x7<EOL>x14 = L0*M0*N0*x3*x5*x6<EOL>x15 = x13 - x14<EOL>x16 = exp(-L1*(x12 - <NUM_LIT:1>))<EOL>x17 = -L1*M1*N1*x10*x12*x16 + x10*x16*x9 - x13 + x14<EOL>x18 = N0*N0<EOL>x19 = x18*x3*x6<EOL>x20 = x1**<NUM_LIT:2>*x19<EOL>x21 = M0**<NUM_LIT:2><EOL>x22 = L0*x18*x3*x5*x6<EOL>x23 = x21*x22<EOL>x24 = <NUM_LIT:2>*M0*x1*x22<EOL>x25 = L0**<NUM_LIT:2>*x0**(<NUM_LIT:2>*x4)*x19*x21<EOL>x26 = N1**<NUM_LIT:2><EOL>x27 = x10*x16*x26<EOL>x28 = M1**<NUM_LIT:2><EOL>x29 = L1*x10*x12*x16*x26<EOL>a_alpha = a*(-omega*(-x10*exp(L1*(-x12 + <NUM_LIT:1>)) + x3*exp(L0*(-x5 + <NUM_LIT:1>))) + x7)<EOL>da_alpha_dT = a*(omega*x17 + x15)/T<EOL>d2a_alpha_dT2 = a*(-(omega*(-L1**<NUM_LIT:2>*x0**(<NUM_LIT>*x11)*x27*x28 + <NUM_LIT>*M1*x29*x8 + x17 + x20 - x23 - x24 + x25 - x27*x8**<NUM_LIT:2> + x28*x29) + x15 - x20 + x23 + x24 - x25)/T**<NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>a_alpha = TWU_a_alpha_common(T=T, Tc=Tc, omega=omega, a=a, full=False, quick=quick, method=method)<EOL>da_alpha_dT = a*(-L0*M0*N0*(T/Tc)**(M0*N0)*(T/Tc)**(N0*(M0 - <NUM_LIT:1>))*exp(L0*(-(T/Tc)**(M0*N0) + <NUM_LIT:1>))/T + N0*(T/Tc)**(N0*(M0 - <NUM_LIT:1>))*(M0 - <NUM_LIT:1>)*exp(L0*(-(T/Tc)**(M0*N0) + <NUM_LIT:1>))/T + omega*(L0*M0*N0*(T/Tc)**(M0*N0)*(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M_LIT:1>))*(M0 - <NUM_LIT:1>)**<NUM_LIT:2>*exp(-L0*((T/Tc)**(M0*N0) - <NUM_LIT:1>)) - N0*(T/Tc)**(N0*(M0 - <NUM_LIT:1>))*(M0 - <NUM_LIT:1>)*exp(-L0*((T/Tc)**(M0*N0) - <NUM_LIT:1>)) - N1**<NUM_LIT:2>*(T/Tc)**(N1*(M1 - <NUM_LIT:1>))*(M1 - <NUM_LIT:1>)**<NUM_LIT:2>*exp(-L1*((T/Tc)**(M1*N1) - <NUM_LIT:1>)) + N1*(T/Tc)**(N1*(M1 - <NUM_LIT:1>))*(M1 - <NUM_LIT:1>)*exp(-L1*((T/Tc)**(M1*N1) - <NUM_LIT:1>))))/T**<NUM_LIT:2>)<EOL><DEDENT>return a_alpha, da_alpha_dT, d2a_alpha_dT2<EOL><DEDENT>
r'''Function to calculate `a_alpha` and optionally its first and second
    derivatives for the TWUPR or TWUSRK EOS. Returns 'a_alpha', and 
    optionally 'da_alpha_dT' and 'd2a_alpha_dT2'.
    Used by `TWUPR` and `TWUSRK`; has little purpose on its own.
    See either class for the correct reference, and examples of using the EOS.

    Parameters
    ----------
    T : float
        Temperature, [K]
    Tc : float
        Critical temperature, [K]
    omega : float
        Acentric factor, [-]
    a : float
        Coefficient calculated by EOS-specific method, [J^2/mol^2/Pa]
    full : float
        Whether or not to return its first and second derivatives
    quick : bool, optional
        Whether to use a SymPy cse-derived expression (3x faster) or 
        individual formulas
    method : str
        Either 'PR' or 'SRK'

    Notes
    -----
    The derivatives are somewhat long and are not described here for 
    brevity; they are obtainable from the following SymPy expression.

    >>> from sympy import *
    >>> T, Tc, omega, N1, N0, M1, M0, L1, L0 = symbols('T, Tc, omega, N1, N0, M1, M0, L1, L0')
    >>> Tr = T/Tc
    >>> alpha0 = Tr**(N0*(M0-1))*exp(L0*(1-Tr**(N0*M0)))
    >>> alpha1 = Tr**(N1*(M1-1))*exp(L1*(1-Tr**(N1*M1)))
    >>> alpha = alpha0 + omega*(alpha1-alpha0)
    >>> # diff(alpha, T)
    >>> # diff(alpha, T, T)