### Install CircuitQ using pip Source: https://github.com/philippaumann/circuitq/blob/master/docs/installation.rst Installs the CircuitQ package using Python's standard package manager, pip. This is a common and straightforward method for users. ```bash pip install circuitq ``` -------------------------------- ### Install CircuitQ for development from GitHub repository Source: https://github.com/philippaumann/circuitq/blob/master/docs/installation.rst Installs CircuitQ in 'develop' mode from a cloned GitHub repository. This method is recommended for developers as it creates a link to the source directory, keeping the package up to date with any local changes. ```bash python setup.py develop ``` -------------------------------- ### Install CircuitQ from local source using pip Source: https://github.com/philippaumann/circuitq/blob/master/docs/installation.rst Installs CircuitQ from the current directory (local source) using pip. This is an alternative method for installing the package after cloning its repository, suitable for general use rather than active development. ```bash pip install . ``` -------------------------------- ### Install CircuitQ using conda with direct channel specification Source: https://github.com/philippaumann/circuitq/blob/master/docs/installation.rst Installs CircuitQ using conda by directly specifying the 'conda-forge' channel within the installation command. This approach avoids permanently adding the channel to your configuration. ```bash conda install -c conda-forge circuitq ``` -------------------------------- ### Install CircuitQ using conda via conda-forge channel Source: https://github.com/philippaumann/circuitq/blob/master/docs/installation.rst Installs CircuitQ using the Anaconda distribution's conda package manager. This method first adds the 'conda-forge' channel to your conda configuration and then proceeds with the installation. It's suitable for users who prefer conda for dependency management. ```bash conda config --add channels conda-forge conda install circuitq ``` -------------------------------- ### Analyze Charge Offset Impact on Circuit Spectrum Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb This example investigates the effect of an external charge offset on the energy spectrum of the circuit. It iterates through a range of offset values, calculates the numerical Hamiltonian and its eigenvalues, and then plots the energy spectrum against the charge offset, providing a visual analysis of its impact. ```python eigenvalues = [] phi_ext = np.pi*circuit.phi_0 q_off_list = np.linspace(-10*2*circuit.e,10*2*circuit.e,30) for q_off in q_off_list: circuit.get_numerical_hamiltonian(401, parameter_values=[False, EJ, False, phi_ext, q_off]) eigv, eigs = circuit.get_eigensystem(5) eigenvalues.append(eigv) plt.plot(q_off_list/(2*circuit.e), np.array(eigenvalues)*y_scaling) plt.xlabel(r"Charge offset $\tilde{q}_1 / (2e)$") plt.ylabel(r"Energy in GHz$\cdot$h") plt.show() ``` -------------------------------- ### Get Eigensystem for Numerical Hamiltonian in CircuitQ Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Demonstrates how to obtain the lowest eigenvalues and eigenstates of a numerical Hamiltonian using `circuit.get_eigensystem()`, which wraps SciPy's `eigsh` function for sparse matrices. ```python eigv, eigs = circuit.get_eigensystem() ``` -------------------------------- ### Diagonalize Hamiltonian and Get Eigensystem Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Performs diagonalization of the numerical Hamiltonian to obtain the eigenvalues (energy levels) and eigenstates of the circuit. ```python eigv, eigs = circuit.get_eigensystem() ``` -------------------------------- ### Import CircuitQ and Dependencies Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Imports necessary libraries like CircuitQ, NetworkX, NumPy, and Matplotlib for circuit simulation and plotting. ```python import circuitq as cq import networkx as nx import numpy as np import matplotlib.pyplot as plt ``` -------------------------------- ### Import core CircuitQ and NetworkX libraries Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Imports the `circuitq` library for superconducting circuit analysis and `networkx` for constructing the circuit graph, which is fundamental for defining the circuit topology. ```python import circuitq as cq import networkx as nx ``` -------------------------------- ### Initialize Fluxonium circuit graph with CircuitQ Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Demonstrates how to create a `networkx.MultiGraph` to represent a Fluxonium circuit, adding edges for capacitance, Josephson junction, and linear inductance. This graph is then used to initialize the `CircuitQ` object, which serves as the central component for circuit operations. ```python graph = nx.MultiGraph() graph.add_edge(0,1, element = 'C') graph.add_edge(0,1, element = 'J') graph.add_edge(0,1, element = 'L') circuit = cq.CircuitQ(graph) ``` -------------------------------- ### Import NumPy and Matplotlib for numerical operations and visualization Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Imports `numpy` for efficient numerical computations and `matplotlib.pyplot` for visualizing the results of circuit analysis, enhancing data interpretation. ```python import numpy as np import matplotlib.pyplot as plt ``` -------------------------------- ### Initialize CircuitQ with Charge Offset Node Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb This code initializes a `CircuitQ` instance, specifying node 1 as having a charge offset. It then accesses the Hamiltonian (`circuit.h`) to reflect this configuration, demonstrating how to set up a circuit with tunable charge offsets. ```python circuit = cq.CircuitQ(graph, offset_nodes=[1]) circuit.h ``` -------------------------------- ### Plot Lowest Eigenstates and Potential of a CircuitQ Instance Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Illustrates how to visualize the lowest eigenstates and the potential of a CircuitQ instance. It scales energy to GHz·h and plots against flux, showing the first five eigenstates. ```python h = 6.62607015e-34 y_scaling = 1/(h *1e9) plt.plot(circuit.flux_list, np.array(circuit.potential)*y_scaling, lw=1.5) for n in range(5): plt.plot(circuit.flux_list, (eigv[n]+ abs(eigs[:,n])**2*2e-23)*y_scaling ,label="Eigenstate " +str(n)) plt.legend() plt.xlabel(r"$\Phi_1 / \Phi_o$") plt.ylabel(r"Energy in GHz$\cdot$h") plt.xticks(np.linspace(-2*np.pi, 1*np.pi, 4)*circuit.phi_0 , [r'$-2\pi$', r'$-\pi$',r'$0$',r'$\pi$']) plt.xlim(-2.5*np.pi*circuit.phi_0, 1.5*np.pi*circuit.phi_0) plt.ylim(1,10) plt.show() ``` -------------------------------- ### Importing CircuitQ and Dependencies Source: https://github.com/philippaumann/circuitq/blob/master/docs/lc_circuit.ipynb This snippet imports the necessary Python libraries for quantum circuit simulation and data visualization. It includes 'circuitq' for circuit analysis, 'numpy' for numerical operations, 'networkx' for graph manipulation, and 'matplotlib.pyplot' for plotting. ```python import circuitq as cq import numpy as np import networkx as nx import matplotlib.pyplot as plt ``` -------------------------------- ### Create Transmon Circuit Graph Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Defines a Transmon circuit using a NetworkX MultiGraph, adding a capacitor (C) and a Josephson junction (J) between nodes 0 and 1. Initializes the CircuitQ object with this graph. ```python graph = nx.MultiGraph() graph.add_edge(0,1, element = 'C') graph.add_edge(0,1, element = 'J') circuit = cq.CircuitQ(graph) ``` -------------------------------- ### Import Libraries for CircuitQ Analysis Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Imports necessary Python libraries including CircuitQ for quantum circuit simulation, NumPy for numerical operations, NetworkX for graph manipulation, and Matplotlib for plotting. ```python import circuitq as cq import numpy as np import networkx as nx import matplotlib.pyplot as plt ``` -------------------------------- ### Initialize CircuitQ Instance with Ground Nodes Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Creates a CircuitQ object from the previously defined circuit graph, specifying nodes 0 and 3 as ground nodes. This step prepares the circuit for symbolic Hamiltonian derivation. ```python circuit = cq.CircuitQ(graph, ground_nodes=[0,3]) ``` -------------------------------- ### Recalculate Hamiltonian and Plot Eigenstates for Zero External Flux Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Demonstrates how to reconfigure the numerical Hamiltonian by setting the external flux to zero and then replotting the potential and lowest eigenstates to observe the change in spectrum harmonicity. ```python phi_ext = 0 circuit.get_numerical_hamiltonian(401, parameter_values=[False, EJ, False, phi_ext ]) eigv, eigs = circuit.get_eigensystem() plt.plot(circuit.flux_list, np.array(circuit.potential)*y_scaling, lw=1.5) for n in range(5): plt.plot(circuit.flux_list, (eigv[n]+ abs(eigs[:,n])**2*2e-23)*y_scaling ,label="Eigenstate " +str(n)) plt.legend() plt.xlabel(r"$\Phi_1 / \Phi_o$") plt.ylabel(r"Energy in GHz$\cdot$h") plt.xticks(np.linspace(-2*np.pi, 2*np.pi, 5)*circuit.phi_0 , [r'$-2\pi$', r'$-\pi$',r'$0$',r'$\pi$',r'$2\pi$']) plt.xlim(-2.5*np.pi*circuit.phi_0, 2.5*np.pi*circuit.phi_0) plt.ylim(-5,20) plt.show() ``` -------------------------------- ### Access Hamiltonian Parameters with Charge Offset Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb After initializing `CircuitQ` with an offset node, this snippet shows how to access the Hamiltonian's parameters. It demonstrates that the new offset variable ($\tilde{q}_1$) is automatically included in the parameter list, allowing for its inspection. ```python circuit.h_parameters ``` -------------------------------- ### Plot Eigenenergies as a Function of External Flux Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Visualizes the dependence of the lowest eigenenergies on the external flux, showing how the spectrum changes across a sweep of the parameter. ```python plt.plot(phi_ext_list, np.array(eigenvalues)*y_scaling) plt.xlabel(r"External Flux $ \tilde{\Phi}_{010} / \Phi_o$") plt.ylabel(r"Energy in GHz$\cdot$h") plt.xticks(np.linspace(-2*np.pi, 2*np.pi, 5)*circuit.phi_0 , [r'$-2\pi$', r'$-\pi$',r'$0$',r'$\pi$',r'$2\pi$']) plt.show() ``` -------------------------------- ### Calculate T1 Time Contribution from Quasiparticle Tunneling Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Demonstrates how to evaluate the T1 time contribution due to quasiparticle tunneling using `circuit.get_T1_quasiparticles()` and prints the result. ```python T1_qp = circuit.get_T1_quasiparticles() print("Quasiparticles noise contribution T1 = {:e} s".format(T1_qp)) ``` -------------------------------- ### Generate numerical Hamiltonian for circuit analysis Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Generates a numerical representation of the Hamiltonian, essential for analyzing the circuit's quantum physical properties. The method `get_numerical_hamiltonian()` takes the matrix length and an ordered list of parameter values, returning a sparse `csr_matrix` from SciPy. ```python h_num = circuit.get_numerical_hamiltonian(401, parameter_values=[False, EJ, False, phi_ext ]) ``` -------------------------------- ### Calculate T1 Time Contribution from Dielectric Loss Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Shows how to evaluate the T1 time contribution due to dielectric loss using `circuit.get_T1_dielectric_loss()` and prints the result. ```python T1_c = circuit.get_T1_dielectric_loss() print("Charge noise contribution T1 = {:e} s".format(T1_c)) ``` -------------------------------- ### circuitq Python Package API Documentation Directives Source: https://github.com/philippaumann/circuitq/blob/master/docs/api/circuitq.rst This snippet details the reStructuredText directives used to generate the API documentation for the `circuitq` Python package. It specifies the inclusion of all members, undocumented members, and inheritance information for the main `circuitq` module and its submodules: `circuitq.core` and `circuitq.functions_file`. ```APIDOC circuitq package: - Description: Top-level package for quantum circuit functionalities. - Submodules: - circuitq.core module: - Description: Core functionalities and classes for circuitq. - Documentation Directives: - Include all members (:members:) - Include undocumented members (:undoc-members:) - Show inheritance hierarchy (:show-inheritance:) - circuitq.functions_file module: - Description: Utility functions related to file operations within circuitq. - Documentation Directives: - Include all members (:members:) - Include undocumented members (:undoc-members:) - Show inheritance hierarchy (:show-inheritance:) - Main Module (circuitq): - Description: Overall package contents and top-level definitions. - Documentation Directives: - Include all members (:members:) - Include undocumented members (:undoc-members:) - Show inheritance hierarchy (:show-inheritance:) ``` -------------------------------- ### Calculate Total T1 Time from Combined Noise Contributions Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Calculates the overall T1 time by combining the contributions from quasiparticle tunneling, dielectric loss, and inductive loss, and prints the final result. ```python print("Total T1 = {:e} s".format( 1/( 1/T1_qp + 1/T1_c + 1/T1_f))) ``` -------------------------------- ### Identify symbolic parameters of the circuit Hamiltonian Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Lists the system parameters present in the symbolic Hamiltonian, such as capacitances, Josephson energies, inductances, and automatically detected loop fluxes. These parameters can be adjusted to tune the circuit's properties. ```python circuit.h_parameters ``` -------------------------------- ### Plot Transmon Energy Spectrum and Eigenstates Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Transforms charge basis eigenstates to flux basis and plots the potential energy along with the first few energy eigenstates. Visualizes the energy levels and wavefunctions in the flux domain. ```python circuit.transform_charge_to_flux() eigs = circuit.estates_in_phi_basis n_states = 5 state_scaling = 15 * (eigv[n_states-1]-eigv[0]/n_states) h = 6.62607015e-34 y_scaling = 1/(h *1e9) def potential(phi): return -circuit.c_v["E"]*np.cos(phi/circuit.phi_0) plt.plot(circuit.flux_list, potential(circuit.flux_list)*y_scaling, lw=0.7) for n in range(n_states): plt.plot(circuit.flux_list, (eigv[n] + np.real(eigs[n]*np.conjugate(eigs[n]))*state_scaling)*y_scaling, label="Eigenstate " +str(n)) plt.legend() plt.xticks(np.linspace(-1*np.pi, 1*np.pi, 3)*circuit.phi_0 , [r'$-\pi$',r'$0$',r'$\pi$']) plt.xlabel(r"$\Phi_1/ \Phi_o$") plt.ylabel(r"Energy in GHz$\cdot$h") plt.show() ``` -------------------------------- ### Calculate T1 Time Contribution from Inductive Loss Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Illustrates how to evaluate the T1 time contribution due to inductive loss using `circuit.get_T1_flux()` and prints the result. ```python T1_f = circuit.get_T1_flux() print("Flux noise contribution T1 = {:e} s".format(T1_f)) ``` -------------------------------- ### CircuitQ Core Module API Reference Source: https://github.com/philippaumann/circuitq/blob/master/docs/api_reference.rst Documents the `circuitq.core` module, including its members, undocumented members, and inheritance hierarchy, as specified by Sphinx's `automodule` directive. ```APIDOC .. automodule:: circuitq.core :members: :undoc-members: :show-inheritance: ``` -------------------------------- ### Calculate Total T1 Time Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Combines the T1 contributions from quasiparticle noise and dielectric loss to calculate the total T1 relaxation time for the circuit and prints the result. ```python print("Total T1 = {:e} s".format( 1/( 1/T1_qp + 1/T1_c))) ``` -------------------------------- ### Collect Eigenvalues Across a Range of External Flux Values Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Iterates through a range of external flux values, reconfigures the numerical Hamiltonian for each, and collects the lowest eigenvalues to prepare for a parameter sweep plot. ```python eigenvalues = [] phi_ext_list = np.linspace(-2*np.pi*circuit.phi_0,2*np.pi*circuit.phi_0,100) for phi_ext in phi_ext_list: circuit.get_numerical_hamiltonian(401, parameter_values=[False, EJ, False, phi_ext]) eigv, eigs = circuit.get_eigensystem(5) eigenvalues.append(eigv) ``` -------------------------------- ### Assign numerical values to Josephson energy and external flux Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Assigns specific numerical values to the Josephson energy and external flux, utilizing characteristic parameter values from `circuit.c_v` and the flux quantum `circuit.phi_0` for realistic circuit simulation. ```python EJ = circuit.c_v["E"]/3 phi_ext = np.pi*circuit.phi_0 ``` -------------------------------- ### CircuitQ Functions File Module API Reference Source: https://github.com/philippaumann/circuitq/blob/master/docs/api_reference.rst Documents the `circuitq.functions_file` module, including its members, undocumented members, and inheritance hierarchy, as specified by Sphinx's `automodule` directive. ```APIDOC .. automodule:: circuitq.functions_file :members: :undoc-members: :show-inheritance: ``` -------------------------------- ### Access symbolic Hamiltonian of the circuit Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Retrieves the symbolic Hamiltonian of the circuit as a `SymPy` expression. CircuitQ automatically quantizes the input circuit and provides this symbolic representation for further analytical manipulation. ```python circuit.h ``` -------------------------------- ### Access Hamiltonian Parameters Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Retrieves the parameters associated with the symbolic Hamiltonian, such as capacitance and Josephson energy values. ```python circuit.h_parameters ``` -------------------------------- ### Calculate T1 Time from Quasiparticle Noise Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Calculates the T1 relaxation time contribution due to quasiparticle noise in the circuit and prints the result. ```python T1_qp = circuit.get_T1_quasiparticles() print("Quasiparticles noise contribution T1 = {:e} s".format(T1_qp)) ``` -------------------------------- ### Calculate Spectrum Anharmonicity in CircuitQ Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Shows how to calculate the anharmonicity of the circuit's spectrum using `circuit.get_spectrum_anharmonicity()`. This method considers the closest transition to the qubit transition and returns a normalized anharmonicity value between 0 and 1. ```python circuit.get_spectrum_anharmonicity() ``` -------------------------------- ### Identify Charge Basis Nodes Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Retrieves and displays the list of nodes that CircuitQ has identified for implementation in the charge basis. This is crucial for understanding the mixed basis approach used for the transmon component. ```python circuit.charge_basis_nodes ``` -------------------------------- ### Define Transmon-Resonator Circuit Graph Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Initializes a NetworkX MultiGraph to represent the circuit topology. Edges are added to define the coupling between nodes, including capacitive (C), Josephson junction (J), and inductive (L) elements, modeling a transmon coupled to an LC resonator. ```python graph = nx.MultiGraph() graph.add_edge(0,1, element = 'C') graph.add_edge(0,1, element = 'J') graph.add_edge(1,2, element = 'C') graph.add_edge(3,2, element = 'C') graph.add_edge(3,2, element = 'L'); ``` -------------------------------- ### Calculate Eigenstates and Transform to Flux Basis Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Performs numerical diagonalization of the Hamiltonian to obtain eigenvalues and eigenstates. It then transforms the eigenstates from the mixed charge-flux basis to a pure flux basis using `transform_charge_to_flux()`, preparing them for visualization. ```python dim = 50 h_num = circuit.get_numerical_hamiltonian(50) eigv, eigs = circuit.get_eigensystem() circuit.transform_charge_to_flux() eigs = circuit.estates_in_phi_basis ``` -------------------------------- ### Calculate Numerical Hamiltonian Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Computes the numerical representation of the Hamiltonian given a grid length. This prepares the Hamiltonian for numerical diagonalization. ```python h_num = circuit.get_numerical_hamiltonian(401, grid_length=np.pi*circuit.phi_0) ``` -------------------------------- ### Access Symbolic Hamiltonian Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Retrieves the symbolic Hamiltonian expression for the defined circuit. This provides the mathematical representation of the circuit's energy. ```python circuit.h ``` -------------------------------- ### Display Symbolic Hamiltonian Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Accesses and displays the symbolic Hamiltonian (`circuit.h`) derived by CircuitQ for the defined transmon-resonator system. This Hamiltonian describes the energy of the entire coupled system. ```python circuit.h ``` -------------------------------- ### Calculate T1 Time from Dielectric Loss Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_demo.ipynb Calculates the T1 relaxation time contribution due to dielectric loss (charge noise) in the circuit and prints the result. ```python T1_c = circuit.get_T1_dielectric_loss() print("Charge noise contribution T1 = {:e} s".format(T1_c)) ``` -------------------------------- ### Plot Lowest Eigenstates in Flux Basis Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Iterates through the lowest 10 eigenstates (transformed to the flux basis) and plots their probability densities as contour maps. This visualization helps in understanding the quantum states of the coupled transmon-resonator system. ```python plt.figure(figsize=(13,30)) for n in range(10): plt.subplot(5,2, n+1) plt.contourf(circuit.flux_list, circuit.flux_list, abs(np.array(eigs[n].reshape(circuit.n_dim,circuit.n_dim)).transpose())**2) plt.colorbar() plt.title("Eigenstate " + str(n) ) plt.xticks(np.linspace(-4*np.pi, 4*np.pi, 5)*circuit.phi_0 , [r'$-4\pi$',r'$-2\pi$',r'$0$',r'$2\pi$',r'$4\pi$']) plt.yticks(np.linspace(-4*np.pi, 4*np.pi, 5)*circuit.phi_0 , [r'$-4\pi$',r'$-2\pi$',r'$0$',r'$2\pi$',r'$4\pi$']) plt.xlabel(r"$\Phi_1 / \Phi_o$") plt.ylabel(r"$\Phi_2 / \Phi_o$") plt.show() ``` -------------------------------- ### Visualize Circuit Potential Energy Source: https://github.com/philippaumann/circuitq/blob/master/docs/transmon_c_resonator.ipynb Defines a function to calculate the potential energy of the coupled system, which combines a cosine potential (from the transmon) and a parabolic potential (from the resonator). It then generates and displays a contour plot of this potential energy across the flux basis. ```python def potential(phi_1, phi_2): return (-circuit.c_v['E']*np.cos(phi_1/circuit.phi_0) + phi_2**2/(2*circuit.c_v['L'])) phis = np.linspace(-4*np.pi*circuit.phi_0, 4*np.pi*circuit.phi_0, dim) h = 6.62607015e-34 y_scaling = 1/(h *1e9) potential_list = [potential(phi_1,phi_2)*y_scaling for phi_2 in phis for phi_1 in phis] plt.contourf(phis, phis, np.array(potential_list).reshape(dim,dim)) plt.xticks(np.linspace(-4*np.pi, 4*np.pi, 5)*circuit.phi_0 , [r'$-4pi$',r'$-2pi$',r'$0$',r'$2pi$',r'$4pi$']) plt.yticks(np.linspace(-4*np.pi, 4*np.pi, 5)*circuit.phi_0 , [r'$-4pi$',r'$-2pi$',r'$0$',r'$2pi$',r'$4pi$']) plt.xlabel(r"$\Phi_1 / \Phi_o$") plt.ylabel(r"$\Phi_2 / \Phi_o$") plt.colorbar(label="Potential Energy in GHz$\cdot$h") plt.show() ``` -------------------------------- ### Calculate Spectrum Anharmonicity After Parameter Change Source: https://github.com/philippaumann/circuitq/blob/master/docs/tutorial.ipynb Recalculates and displays the anharmonicity of the circuit's spectrum after the external flux parameter has been changed, reflecting the increased harmonicity. ```python circuit.get_spectrum_anharmonicity() ``` -------------------------------- ### Plotting LC Circuit Eigenstates Source: https://github.com/philippaumann/circuitq/blob/master/docs/lc_circuit.ipynb This code visualizes the square of the absolute values of the LC circuit's eigenstates, overlaid on the potential energy curve. The plots demonstrate that the eigenstates resemble Hermite functions, which are characteristic of a quantum harmonic oscillator, further confirming the analogy. ```python plt.plot(circuit.flux_list, np.array(circuit.potential)*y_scaling, lw=1.5) for n in range(5): plt.plot(circuit.flux_list, (eigv[n]+(abs(eigs[:,n])**2)*1e-23)*y_scaling, label="Eigenstate " + str(n)) plt.xticks(np.linspace(-1*np.pi, 1*np.pi, 3)*circuit.phi_0 , [r'$-\pi$',r'$0$',r'$\pi$']) plt.xlabel(r"$\Phi_1 / \Phi_o$") plt.ylabel(r"Energy in GHz$\cdot$h") plt.xlim(-1.1*np.pi*circuit.phi_0, 1.1*np.pi*circuit.phi_0) plt.ylim(0,15) plt.legend() plt.show() ``` -------------------------------- ### Calculating Symbolic Hamiltonian Source: https://github.com/philippaumann/circuitq/blob/master/docs/lc_circuit.ipynb This snippet initializes a CircuitQ object with the defined LC circuit graph. It then accesses the symbolic Hamiltonian ('circuit.h'), which represents the quantum mechanical energy operator for the circuit, showing it contains a harmonic potential. ```python circuit = cq.CircuitQ(graph) circuit.h ``` -------------------------------- ### Plotting LC Circuit Eigenenergies Source: https://github.com/philippaumann/circuitq/blob/master/docs/lc_circuit.ipynb This snippet plots the calculated eigenenergies of the LC circuit, scaled to GHz·h, and compares them against the expected equidistant energy levels of a quantum harmonic oscillator. This visualization confirms the circuit's analogous behavior to a quantum harmonic oscillator, with energies spaced by ℏω. ```python n_energies = 10 h = 6.62607015e-34 y_scaling = 1/(h *1e9) plt.plot(np.arange(n_energies), eigv[:n_energies]*y_scaling, 'ro', label='CircuitQ LC Circuit Energies') omega = 1/np.sqrt(circuit.c_v["L"]*circuit.c_v["C"]) plt.axhline(eigv[0]*y_scaling, lw=0.5, label='Harmonic Oscillator Energies') for n in range(1,n_energies): plt.axhline((eigv[0]+n*circuit.hbar*omega)*y_scaling, lw=0.5) plt.xlabel("Eigenvalue No.") plt.ylabel(r"Energy in GHz$\cdot$h") plt.legend() plt.show() ``` -------------------------------- ### Diagonalizing Numerical Hamiltonian Source: https://github.com/philippaumann/circuitq/blob/master/docs/lc_circuit.ipynb This code calculates the numerical representation of the Hamiltonian for the LC circuit, specifying a basis size of 200. It then performs diagonalization to obtain the eigenvalues (energy levels) and eigenvectors (quantum states) of the system. ```python h_num = circuit.get_numerical_hamiltonian(200) eigv, eigs = circuit.get_eigensystem() ``` -------------------------------- ### Defining LC Circuit Graph Source: https://github.com/philippaumann/circuitq/blob/master/docs/lc_circuit.ipynb This code defines the LC circuit structure using a NetworkX MultiGraph. It adds two parallel edges between nodes 0 and 1, representing a capacitor ('C') and an inductor ('L'), which together form the LC circuit. ```python graph = nx.MultiGraph() graph.add_edge(0,1, element = 'C') graph.add_edge(0,1, element = 'L'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.