docs: def isentropic_work_compression(T1, k, Z=1, P1=None, P2=None, W=None, eta=None):
      r'''Calculation function for dealing with compressing or expanding a gas
      going through an isentropic, adiabatic process assuming constant Cp and Cv. 
      The polytropic model is the same equation; just provide `n` instead of `k` 
      and use a polytropic efficiency for `eta` instead of a isentropic 
      efficiency. Can calculate any of the following, given all the other inputs:
  
      * W, Work of compression
      * P2, Pressure after compression 
      * P1, Pressure before compression
      * eta, isentropic efficiency of compression
      
      .. math::
          W = \left(\frac{k}{k-1}\right)ZRT_1\left[\left(\frac{P_2}{P_1}
          \right)^{(k-1)/k}-1\right]/\eta_{isentropic}
  
      Parameters
      ----------
      T1 : float
          Initial temperature of the gas, [K]
      k : float
          Isentropic exponent of the gas (Cp/Cv) or polytropic exponent `n` to
          use this as a polytropic model instead [-]
      Z : float, optional
          Constant compressibility factor of the gas, [-]
      P1 : float, optional
          Inlet pressure, [Pa]
      P2 : float, optional
          Outlet pressure, [Pa]
      W : float, optional
          Work performed per mole of gas compressed/expanded [J/mol]
      eta : float, optional
          Isentropic efficiency of the process or polytropic efficiency of the
          process to use this as a polytropic model instead [-]
  
      Returns
      -------
      W, P1, P2, or eta : float
          The missing input which was solved for [base SI]
  
      Notes
      -----
      For the same compression ratio, this is always of larger magnitude than the
      isothermal case.
  
      The full derivation is as follows:
  
      For constant-heat capacity "isentropic" fluid,
  
      .. math::
          V = \frac{P_1^{1/k}V_1}{P^{1/k}}
  
      .. math::
          W = \int_{P_1}^{P_2} V dP = \int_{P_1}^{P_2}\frac{P_1^{1/k}V_1}
          {P^{1/k}}dP
  
      .. math::
          W = \frac{P_1^{1/k} V_1}{1 - \frac{1}{k}}\left[P_2^{1-1/k} -
          P_1^{1-1/k}\right]
  
      After performing the integration and substantial mathematical manipulation
      we can obtain:
  
      .. math::
          W = \left(\frac{k}{k-1}\right) P_1 V_1 \left[\left(\frac{P_2}{P_1}
          \right)^{(k-1)/k}-1\right]
  
      Using PV = ZRT:
  
      .. math::
          W = \left(\frac{k}{k-1}\right)ZRT_1\left[\left(\frac{P_2}{P_1}
          \right)^{(k-1)/k}-1\right]
  
      The work of compression/expansion is the change in enthalpy of the gas.
      Returns negative values for expansion and positive values for compression.
  
      An average compressibility factor should be used as Z changes. For further
      accuracy, this expression can be used repeatedly with small changes in
      pressure and new values of isentropic exponent, and the work from each step
      summed.
  
      For the polytropic case this is not necessary, as `eta` corrects for the
      simplification.
  
      Examples
      --------
      >>> isentropic_work_compression(P1=1E5, P2=1E6, T1=300, k=1.4, eta=0.78)
      10416.876986384483
  
      References
      ----------
      .. [1] Couper, James R., W. Roy Penney, and James R. Fair. Chemical Process
         Equipment: Selection and Design. 2nd ed. Amsterdam ; Boston: Gulf
         Professional Publishing, 2009.
      '''
      if W is None and (None not in [eta, P1, P2]):
          return k/(k - 1.0)*Z*R*T1*((P2/P1)**((k-1.)/k) - 1.0)/eta
      elif P1 is None and (None not in [eta, W, P2]):
          return P2*(1.0 + W*eta/(R*T1*Z) - W*eta/(R*T1*Z*k))**(-k/(k - 1.0))
      elif P2 is None and (None not in [eta, W, P1]):
          return P1*(1.0 + W*eta/(R*T1*Z) - W*eta/(R*T1*Z*k))**(k/(k - 1.0))
      elif eta is None and (None not in [P1, P2, W]):
          return R*T1*Z*k*((P2/P1)**((k - 1.0)/k) - 1.0)/(W*(k - 1.0))
      else:
          raise Exception('Three of W, P1, P2, and eta must be specified.')