circuit-quantization 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- circuit_quantization/__init__.py +64 -0
- circuit_quantization/circuit.py +258 -0
- circuit_quantization/draw.py +199 -0
- circuit_quantization/flux.py +54 -0
- circuit_quantization/hamiltonian.py +101 -0
- circuit_quantization/io.py +704 -0
- circuit_quantization/lagrangian.py +85 -0
- circuit_quantization/loops.py +248 -0
- circuit_quantization/modes.py +672 -0
- circuit_quantization/numeric_spec.py +199 -0
- circuit_quantization/numerical.py +391 -0
- circuit_quantization/optimize/__init__.py +32 -0
- circuit_quantization/optimize/_utils.py +37 -0
- circuit_quantization/optimize/choose.py +396 -0
- circuit_quantization/optimize/equationset.py +358 -0
- circuit_quantization/optimize/patterns.py +88 -0
- circuit_quantization/optimize/poly_solver.sing +381 -0
- circuit_quantization/optimize/rational_check.py +675 -0
- circuit_quantization/optimize/singular_interface.py +1071 -0
- circuit_quantization/optimize/stages.py +115 -0
- circuit_quantization/optimize/transforms.py +1337 -0
- circuit_quantization/optimize/z3_interface.py +794 -0
- circuit_quantization/qpackage_interface.py +126 -0
- circuit_quantization/quantize.py +186 -0
- circuit_quantization/shear.py +252 -0
- circuit_quantization/units.py +91 -0
- circuit_quantization-0.1.0.dist-info/METADATA +99 -0
- circuit_quantization-0.1.0.dist-info/RECORD +31 -0
- circuit_quantization-0.1.0.dist-info/WHEEL +5 -0
- circuit_quantization-0.1.0.dist-info/licenses/LICENSE +674 -0
- circuit_quantization-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""Frequency-unit Hamiltonian."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
import sympy as sym
|
|
6
|
+
|
|
7
|
+
from .modes import _cancel
|
|
8
|
+
from .units import e, farad_to_ghz, henry_to_ghz, weber_to_phase
|
|
9
|
+
|
|
10
|
+
__all__ = ["Hamiltonian", "hamiltonian", "simplify_hamiltonian"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass(frozen=True)
|
|
14
|
+
class Hamiltonian:
|
|
15
|
+
"""The Hamiltonian H/h in GHz and its coefficient matrices.
|
|
16
|
+
|
|
17
|
+
:ivar H: H/h [GHz] as a SymPy expression.
|
|
18
|
+
:ivar varphi: Dimensionless phase coordinates varphi_1, ..., varphi_N.
|
|
19
|
+
:ivar n: Conjugate charges n_1, ..., n_N [Cooper pairs].
|
|
20
|
+
:ivar n_g: Offset charges [Cooper pairs]. Each compact mode j also carries a sector label n_gj.
|
|
21
|
+
:ivar varphi_ext: Dimensionless external fluxes, in loops order.
|
|
22
|
+
:ivar varphi_b: Dimensionless branch flux offsets placed by B.
|
|
23
|
+
:ivar E_C: Charging-energy matrix [GHz].
|
|
24
|
+
:ivar E_L: Inductive-energy matrix [GHz].
|
|
25
|
+
:ivar E_Lb: Diagonal matrix of branch inductive energies [GHz], inductor branches only.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
H: sym.Expr # H/h in GHz, eq:full_H_dimless
|
|
29
|
+
varphi: sym.ImmutableMatrix
|
|
30
|
+
n: sym.ImmutableMatrix
|
|
31
|
+
n_g: sym.ImmutableMatrix
|
|
32
|
+
varphi_ext: sym.ImmutableMatrix
|
|
33
|
+
varphi_b: sym.ImmutableMatrix # dimensionless branch flux offsets, eq:particular_static_split
|
|
34
|
+
E_C: sym.ImmutableMatrix
|
|
35
|
+
E_L: sym.ImmutableMatrix
|
|
36
|
+
E_Lb: sym.ImmutableMatrix
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def simplify_hamiltonian(H):
|
|
40
|
+
"""Combine trigonometric terms, then factor each term's numerator and denominator.
|
|
41
|
+
|
|
42
|
+
Keep the Hamiltonian as a sum rather than collecting it over one denominator.
|
|
43
|
+
This optional symbolic step can be expensive for large circuits.
|
|
44
|
+
|
|
45
|
+
:param H: SymPy Hamiltonian expression.
|
|
46
|
+
:returns: Algebraically equivalent expression with factored terms and simplified trigonometry.
|
|
47
|
+
"""
|
|
48
|
+
H = sym.sympify(H)
|
|
49
|
+
algebraic, trig = H.as_independent(*H.atoms(sym.sin, sym.cos), as_Add=True)
|
|
50
|
+
H = algebraic + sym.trigsimp(trig, method="fu")
|
|
51
|
+
return sym.Add(*(sym.factor(term) for term in sym.Add.make_args(H)))
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def hamiltonian(lag, coords, loops, B, t, *, simplify=False, B_static=None, static=None):
|
|
55
|
+
"""Hamiltonian H/h in GHz for given coordinates and flux assignment.
|
|
56
|
+
|
|
57
|
+
:param lag: Node Lagrangian matrices.
|
|
58
|
+
:param coords: Decoupled retained coordinates.
|
|
59
|
+
:param loops: Loops supplying the external fluxes.
|
|
60
|
+
:param B: Branch-by-loop flux assignment, with loops.G * B = I.
|
|
61
|
+
:param t: Time symbol of the circuit.
|
|
62
|
+
:param bool simplify: Apply simplify_hamiltonian to H.
|
|
63
|
+
:param B_static: Optional separate assignment for the static part of the loop fluxes, given with static.
|
|
64
|
+
:param static: Column of static loop fluxes [Wb], in loops order.
|
|
65
|
+
:returns: Hamiltonian.
|
|
66
|
+
"""
|
|
67
|
+
N_d = coords.Z.cols
|
|
68
|
+
varphi = sym.ImmutableMatrix(sym.symbols(f"varphi_1:{N_d + 1}", real=True))
|
|
69
|
+
n = sym.ImmutableMatrix(sym.symbols(f"n_1:{N_d + 1}", real=True))
|
|
70
|
+
Phi_ext = loops.Phi_ext
|
|
71
|
+
varphi_ext = weber_to_phase(Phi_ext) # eq:dimless_defs
|
|
72
|
+
# eq:particular_static_split: B_static places the static bias (Wb, loops order), B the rest.
|
|
73
|
+
if B_static is None:
|
|
74
|
+
varphi_b = B * varphi_ext
|
|
75
|
+
else:
|
|
76
|
+
varphi_static = weber_to_phase(static)
|
|
77
|
+
varphi_b = B_static * varphi_static + B * (varphi_ext - varphi_static)
|
|
78
|
+
varphi_b = sym.ImmutableMatrix(varphi_b)
|
|
79
|
+
|
|
80
|
+
# eq:EC_EL_matrix: scale inverse-element matrices by the unit-element energies.
|
|
81
|
+
E_C = _cancel(farad_to_ghz(1) * coords.C_tilde_inv)
|
|
82
|
+
E_L = _cancel(henry_to_ghz(1) * coords.Lstar_tilde)
|
|
83
|
+
E_Lb = _cancel(henry_to_ghz(1) * lag.Lb_inv)
|
|
84
|
+
|
|
85
|
+
# eq:Q_g_tilde_expanded; the flux term vanishes for irrotational B. Only B carries a rate.
|
|
86
|
+
Q_g = coords.Z.T * (-lag.C_int_src * lag.V + lag.Omega_int * lag.C_b * B * Phi_ext.diff(t))
|
|
87
|
+
# Each compact mode also carries a static sector label (Sec IV.B.1).
|
|
88
|
+
sector = [sym.Symbol(f"n_g{j + 1}", real=True) if typ == "c" else 0 for j, typ in enumerate(coords.types)]
|
|
89
|
+
n_g = _cancel(Q_g / (2 * e)) + sym.Matrix(sector)
|
|
90
|
+
|
|
91
|
+
q = n - n_g
|
|
92
|
+
H = 4 * (q.T * E_C * q)[0] # charging
|
|
93
|
+
H += (varphi.T * E_L * varphi)[0] / 2 # inductive
|
|
94
|
+
H += (varphi.T * coords.omega_L_tilde * E_Lb * varphi_b[list(lag.L), :])[0] # inductive-flux cross term
|
|
95
|
+
junction_phase = coords.omega_J_tilde.T * varphi + varphi_b[list(lag.J), :]
|
|
96
|
+
H -= sum(EJ * sym.cos(phase) for EJ, phase in zip(lag.EJ, junction_phase)) # Josephson
|
|
97
|
+
|
|
98
|
+
return Hamiltonian(
|
|
99
|
+
H=simplify_hamiltonian(H) if simplify else H, varphi=varphi, n=n, n_g=n_g,
|
|
100
|
+
varphi_ext=varphi_ext, varphi_b=varphi_b, E_C=E_C, E_L=E_L, E_Lb=E_Lb,
|
|
101
|
+
)
|