docs: def V_horiz_ellipsoidal(D, L, a, h, headonly=False):
      r'''Calculates volume of a tank with ellipsoidal ends, according to [1]_.
  
      .. math::
          V_f = A_fL + \pi a h^2\left(1 - \frac{h}{3R}\right)
  
      .. math::
          Af = R^2\cos^{-1}\frac{R-h}{R} - (R-h)\sqrt{2Rh - h^2}
  
      Parameters
      ----------
      D : float
          Diameter of the main cylindrical section, [m]
      L : float
          Length of the main cylindrical section, [m]
      a : float
          Distance the ellipsoidal head extends on one side, [m]
      h : float
          Height, as measured up to where the fluid ends, [m]
      headonly : bool, optional
          Function returns only the volume of a single head side if True
  
      Returns
      -------
      V : float
          Volume [m^3]
  
      Examples
      --------
      Matching example from [1]_, with inputs in inches and volume in gallons.
  
      >>> V_horiz_ellipsoidal(D=108, L=156, a=42, h=36)/231.
      2380.9565415578145
  
      References
      ----------
      .. [1] Jones, D. "Calculating Tank Volume." Text. Accessed December 22, 2015.
         http://www.webcalc.com.br/blog/Tank_Volume.PDF'''
      R = 0.5*D
      Af = R*R*acos((R-h)/R) - (R-h)*(2*R*h - h*h)**0.5
      Vf = pi*a*h*h*(1 - h/(3.*R))
      if headonly:
          Vf = 0.5*Vf
      else:
          Vf += Af*L
      return Vf