pyEPR.calcs.hamiltonian module#

Hamiltonian and Matrix Operations. Hamiltonian operations heavily draw on qutip package. This package must be installed for them to work.

class pyEPR.calcs.hamiltonian.HamOps[source]#

Bases: object

static closest_state_to(s: Qobj, energyMHz, evecs)[source]#

Returns the energy of the closest state to s

static closest_state_to_idx(s: Qobj, evecs)[source]#

Returns the index

static fock_state_on(d: dict, fock_trunc: int, N_modes: int)[source]#

d={mode number: # of photons} In the bare eigen basis

static identify_Fock_levels(fock_trunc: int, evecs, N_modes=2, Fock_max=4)[source]#

Return quantum numbers in terms of the undiagonalized eigenbasis.

class pyEPR.calcs.hamiltonian.MatrixOps[source]#

Bases: object

static apply_scalar_function(op: Qobj, func) Qobj[source]#

Evaluate a real scalar function on a Hermitian operator via eigendecomposition.

For a Hermitian operator H with real eigenvalues λ_i and eigenvectors \(|i\rangle\):

\[f(H) = \sum_i f(\lambda_i) |i\rangle\langle i|\]

This lets you evaluate any analytic scalar function—not just polynomials or exponentials—as an operator, which is needed for generic junction potentials.

Parameters:
  • op (qutip.Qobj) – Hermitian operator (e.g., the phase operator φ in Fock space).

  • func (callable) – Real scalar function func(float) -> float.

Returns:

func(op) in the same Hilbert space.

Return type:

qutip.Qobj

Examples

>>> import qutip, numpy as np
>>> from pyEPR.calcs.hamiltonian import MatrixOps
>>> a = qutip.destroy(8)
>>> phi = 0.3 * (a + a.dag())
>>> cos_phi = MatrixOps.apply_scalar_function(phi, np.cos)
static cos(op_cos_arg: Qobj)[source]#

Exact cosine operator via matrix exponential: (e^{iφ} + e^{-iφ}) / 2.

Parameters:

op_cos_arg (qutip.Qobj) – Phase operator φ (Hermitian).

Returns:

cos(φ) as a matrix in Fock space.

Return type:

qutip.Qobj

static cos_approx(x, cos_trunc=5)[source]#

Create a Taylor series matrix approximation of the cosine, up to some order.

static cos_full_correction(op_cos_arg: Qobj)[source]#

Exact EPR nonlinear correction: cos(φ) - I + φ²/2 (no truncation).

This is the infinite-order equivalent of cos_approx(). In the EPR Hamiltonian the linear eigenfrequencies already account for the harmonic (φ²/2) Josephson energy, so the nonlinear potential that must be subtracted is the remainder:

\[H_{\mathrm{nl}} = -E_J \bigl[\cos(\varphi) - 1 + \tfrac{\varphi^2}{2}\bigr] = -E_J \sum_{n\ge 2} \frac{(-1)^n \varphi^{2n}}{(2n)!}\]

For weakly anharmonic circuits (transmon, φ_zpf ≲ 0.3) the truncated cos_approx() is equivalent and faster. For strongly anharmonic circuits (fluxonium, φ_zpf ≳ 1) use this function to avoid systematic errors from the truncated series.

Parameters:

op_cos_arg (qutip.Qobj) – Phase operator φ (Hermitian), in the full Fock-space tensor product.

Returns:

cos(φ) - I + φ²/2 as a matrix.

Return type:

qutip.Qobj

See also

cos_approx

Truncated Taylor-series version (faster for small φ_zpf).

References

arXiv:2411.15039 — EPR analysis for very anharmonic superconducting circuits.

static dot(ais, bis)[source]#

Dot product