code: def _calcEnergyStretchTwist(self, diff, es, which):
          r
  
          if which not in self.enGlobalTypes[:5]:
              raise ValueError('{0} is not a supported energy keywords.\n Use any of the following: \n {1}'.format(
                  which, self.enGlobalTypes[:5]))
  
          energy = None
  
          if which == 'full':
              temp = np.matrix(diff)
              energy = 0.5 * ((temp * es) * temp.T)
              energy = energy[0,0]
  
          if which == 'diag':
              energy = 0.5 * ((diff[0] ** 2 * es[0][0])
                              + (diff[1] ** 2 * es[1][1]))
  
          if which == 'stretch':
              energy = 0.5 * (diff[0] ** 2 * es[0][0])
  
          if which == 'twist':
              energy = 0.5 * (diff[1] ** 2 * es[1][1])
  
          if which == 'st_coupling':
              energy = 0.5 * (diff[0] * diff[1] * es[0][1])
  
          return energy
docs: r"""Calculate energy for ``estype='ST'`` using a difference vector.
  
          It is called in :meth:`dnaEY.getGlobalDeformationEnergy` for energy calculation of each frame.
  
          Parameters
          ----------
          diff : numpy.ndarray
              Array of difference between minimum and current parameter values.
  
              .. math::
  
                  \mathbf{x} =  \begin{bmatrix}
                      (L_i - L_0) & (\phi_i - \phi_0)
                            \end{bmatrix}
  
          es : numpy.ndarray
              Elastic matrix. See in :meth:`dnaEY.getStretchTwistModulus` about elastic matrix.
  
          which : str
              For which type of motions, energy will be calculated.
              See ``which`` parameter in :meth:`dnaEY.getGlobalDeformationEnergy` for keywords.
  
          Return
          ------
          energy : float
              Deformation free energy value