def potential_energy(*body):
 pe_sys = S(0)
 for e in body:
  if isinstance(e, (RigidBody, Particle)):
   pe_sys += e.potential_energy
  else:
   raise TypeError('*body must have only Particle or RigidBody')
 return pe_sys

def potential_energy ( * body ) : pe_sys = S ( 0 ) for e in body : if isinstance ( e , ( RigidBody , Particle ) ) : pe_sys += e . potential_energy else : raise TypeError ( '*body must have only Particle or RigidBody' ) return pe_sys
potential energy of a multibody system .