<jupyter_start><jupyter_text>Initialization<jupyter_code>%matplotlib inline
%config InlineBackend.figure_format = 'svg'

import scqubits as qubit
import scqubits.utils.plotting as plot

import numpy as np<jupyter_output><empty_output><jupyter_text>Transmon qubit The transmon qubit and the Cooper pair box are described by the Hamiltonian \begin{equation}H_\text{CPB}=4E_\text{C}(\hat{n}-n_g)^2+\frac{1}{2}E_\text{J}\sum_n(|n\rangle\langle n+1|+\text{h.c.}),\end{equation}expressed in the charge basis. Here,  $E_C$ is the charging energy, $E_J$ the Josephson energy, and $n_g$ the offset charge. Internal representation of the Hamiltonian proceeds via the charge basis with charge-number cutoff specified by `ncut`, which must be chosen sufficiently large for convergence.An instance of the transmon qubit is initialized as follows:<jupyter_code>CPB = qubit.Transmon(
    EJ=30.02,
    EC=1.2,
    ng=0.3,
    ncut=31
    )<jupyter_output><empty_output><jupyter_text>The energy eigenvalues of the transmon Hamiltonian for the given set of model parameters are obtained by calling the `eigenvals()` method. The optional parameter `evals_count` specifies the sought number of eigenenergies.<jupyter_code>CPB.eigenvals(evals_count=12)<jupyter_output><empty_output><jupyter_text>To plot eigenenergies as a function of one of the qubit parameters (`EJ`, `EC`, or `ng`), we generate an array of values for the desired parameter and call the method `plot_evals_vs_paramvals`:<jupyter_code>ng_list = np.linspace(-2, 2, 220)
CPB.plot_evals_vs_paramvals('ng', ng_list, evals_count=6, subtract_ground=False);
CPB.ng = 0.3
ej_vals = CPB.EJ * np.cos(np.linspace(-np.pi/2, np.pi/2, 40))
CPB.plot_evals_vs_paramvals('EJ', ej_vals, evals_count=4, subtract_ground=False);
CPB.plot_n_wavefunction(esys=None, which=0, mode='real');
CPB.plot_wavefunction(esys=None, which=0, mode='real');
CPB.plot_phi_wavefunction(esys=None, which=[1, 2, 3, 4, 5], mode='abs_sqr');<jupyter_output><empty_output><jupyter_text>Charge matrix elements<jupyter_code>CPB.EJ  = 30
CPB.ncut = 80
nmat = CPB.matrixelement_table('n_operator', evals_count=10)
plot.print_matrix(abs(nmat));
CPB.plot_matrixelements('n_operator', evals_count=10);
fig, ax = CPB.plot_matelem_vs_paramvals('n_operator', 'ng', ng_list, select_elems=4, filename='./data/test');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12189905902480752, 'fraction_numerical': 0.019674935842600515, 'mean_word_length': 7.121527777777778, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '192876', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 869, 'n_tokens_neox': 832, 'n_words': 200, 'path': 'examples/demo_transmon.ipynb', 'repo_name': 'zlatko-minev/scqubits', 'size': '2338'}