Coverage for jaxquantum/devices/superconducting/resonator.py: 0%
31 statements
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-17 21:51 +0000
« prev ^ index » next coverage.py v7.9.2, created at 2025-07-17 21:51 +0000
1"""Resonator."""
3from flax import struct
4from jax import config
6import jax.numpy as jnp
8from jaxquantum.core.operators import identity, destroy, create
9from jaxquantum.devices.superconducting.flux_base import FluxDevice
11config.update("jax_enable_x64", True)
14@struct.dataclass
15class Resonator(FluxDevice):
16 """
17 Resonator Device.
18 """
20 def common_ops(self):
21 """Written in the linear basis."""
22 ops = {}
24 N = self.N_pre_diag
25 ops["id"] = identity(N)
26 ops["a"] = destroy(N)
27 ops["a_dag"] = create(N)
28 ops["phi"] = self.phi_zpf() * (ops["a"] + ops["a_dag"])
29 ops["n"] = 1j * self.n_zpf() * (ops["a_dag"] - ops["a"])
31 return ops
33 def phi_zpf(self):
34 """Return Phase ZPF."""
35 return (2 * self.params["Ec"] / self.params["El"]) ** (0.25)
37 def n_zpf(self):
38 n_zpf = (self.params["El"] / (32.0 * self.params["Ec"])) ** (0.25)
39 return n_zpf
41 def get_linear_ω(self):
42 """Get frequency of linear terms."""
43 return jnp.sqrt(8 * self.params["El"] * self.params["Ec"])
45 def get_H_linear(self):
46 """Return linear terms in H."""
47 w = self.get_linear_ω()
48 return w * (self.linear_ops["a_dag"] @ self.linear_ops["a"] + 1 / 2)
50 def get_H_full(self):
51 """Return full H in linear basis."""
52 return self.get_H_linear()
54 def potential(self, phi):
55 """Return potential energy for a given phi."""
56 return 0.5 * self.params["El"] * (2 * jnp.pi * phi) ** 2