qml.labs.trotter_error.vibrational_fragments

vibrational_fragments(modes, freqs, taylor_coeffs, frag_method='harmonic')[source]

Returns a list of fragments summing to a vibrational Hamiltonian.

Parameters:
  • modes (int) – the number of vibrational modes

  • freqs (ndarray) – the harmonic frequences

  • taylor_coeffs (Sequence[ndarray]) – a sequence containing the tensors of coefficients in the Taylor expansion

  • frag_method (string) – the fragmentation method, valid options are harmonic, kinetic, and position

Returns:

a list of RealspaceSum objects representing the fragments of the vibrational Hamiltonian

Return type:

List[RealspaceSum]

Example

>>> from pennylane.labs.trotter_error import vibrational_fragments
>>> import numpy as np
>>> n_modes = 4
>>> r_state = np.random.RandomState(42)
>>> freqs = r_state.random(4)
>>> taylor_coeffs = [np.array(0), r_state.random(size=(n_modes, )), r_state.random(size=(n_modes, n_modes))]
>>> fragments = vibrational_fragments(n_modes, freqs, taylor_coeffs)
>>> for fragment in fragments:
>>>     print(fragment)
RealspaceSum((RealspaceOperator(4, ('PP',), omega[idx0]), RealspaceOperator(4, ('QQ',), omega[idx0])))
RealspaceSum((RealspaceOperator(4, ('Q',), phi[1][idx0]), RealspaceOperator(4, ('Q', 'Q'), phi[2][idx0,idx1])))